summaryrefslogtreecommitdiff
path: root/tests/src/JIT/CodeGenBringUpTests/StructReturn.cs
blob: 488c4b962a058aa23731ac6925095d4a317bd385 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
//


using System;
using System.Runtime.CompilerServices;

// int
public struct MyStructInt1
{
    public int int1;
}

public struct MyStructInt2
{
    public int int1;
    public int int2;
}

public struct MyStructInt4
{
    public int int1;
    public int int2;
    public int int3;
    public int int4;
}

// long
public struct MyStructLong1
{
    public long long1;
}

public struct MyStructLong2
{
    public long long1;
    public long long2;
}

public struct MyStructLong4
{
    public long long1;
    public long long2;
    public long long3;
    public long long4;
}

// float
public struct MyStructFloat1
{
    public float float1;
}

public struct MyStructFloat2
{
    public float float1;
    public float float2;
}

public struct MyStructFloat3
{
    public float float1;
    public float float2;
    public float float3;
}

public struct MyStructFloat4
{
    public float float1;
    public float float2;
    public float float3;
    public float float4;
}

public struct MyStructFloat5
{
    public float float1;
    public float float2;
    public float float3;
    public float float4;
    public float float5;
}

public struct MyStructFloat8
{
    public float float1;
    public float float2;
    public float float3;
    public float float4;
    public float float5;
    public float float6;
    public float float7;
    public float float8;
}

// double
public struct MyStructDouble1
{
    public double double1;
}

public struct MyStructDouble2
{
    public double double1;
    public double double2;
}

public struct MyStructDouble3
{
    public double double1;
    public double double2;
    public double double3;
}

public struct MyStructDouble4
{
    public double double1;
    public double double2;
    public double double3;
    public double double4;
}

public struct MyStructDouble5
{
    public double double1;
    public double double2;
    public double double3;
    public double double4;
    public double double5;
}

public struct MyStructDouble8
{
    public double double1;
    public double double2;
    public double double3;
    public double double4;
    public double double5;
    public double double6;
    public double double7;
    public double double8;
}

public class BringUpTest
{
    const int Pass = 100;
    const int Fail = -1;

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructInt1 returnMyStructInt1(int x)
    {
        MyStructInt1 s = new MyStructInt1();
        s.int1 = x + 1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructInt2 returnMyStructInt2(int x)
    {
        MyStructInt2 s = new MyStructInt2();
        s.int1 = x + 1;
        s.int2 = x + 2;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructInt4 returnMyStructInt4(int x)
    {
        MyStructInt4 s = new MyStructInt4();
        s.int1 = x + 1;
        s.int2 = x + 2;
        s.int3 = x + 3;
        s.int4 = x + 4;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructLong1 returnMyStructLong1(long x)
    {
        MyStructLong1 s = new MyStructLong1();
        s.long1 = x + 1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructLong2 returnMyStructLong2(long x)
    {
        MyStructLong2 s = new MyStructLong2();
        s.long1 = x + 1;
        s.long2 = x + 2;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructLong4 returnMyStructLong4(long x)
    {
        MyStructLong4 s = new MyStructLong4();
        s.long1 = x + 1;
        s.long2 = x + 2;
        s.long3 = x + 3;
        s.long4 = x + 4;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat1 returnMyStructFloat1(float x)
    {
        MyStructFloat1 s = new MyStructFloat1();
        s.float1 = x + 1.1f;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat2 returnMyStructFloat2(float x)
    {
        MyStructFloat2 s = new MyStructFloat2();
        s.float1 = x + 1.1f;
        s.float2 = x + 2.1f;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat3 returnMyStructFloat3(float x)
    {
        MyStructFloat3 s = new MyStructFloat3();
        s.float1 = x + 1.1f;
        s.float2 = x + 2.1f;
        s.float3 = x + 3.1f;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat4 returnMyStructFloat4(float x)
    {
        MyStructFloat4 s = new MyStructFloat4();
        s.float1 = x + 1.1f;
        s.float2 = x + 2.1f;
        s.float3 = x + 3.1f;
        s.float4 = x + 4.1f;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat5 returnMyStructFloat5(float x)
    {
        MyStructFloat5 s = new MyStructFloat5();
        s.float1 = x + 1.1f;
        s.float2 = x + 2.1f;
        s.float3 = x + 3.1f;
        s.float4 = x + 4.1f;
        s.float5 = x + 5.1f;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructFloat8 returnMyStructFloat8(float x)
    {
        MyStructFloat8 s = new MyStructFloat8();
        s.float1 = x + 1.1f;
        s.float2 = x + 2.1f;
        s.float3 = x + 3.1f;
        s.float4 = x + 4.1f;
        s.float5 = x + 5.1f;
        s.float6 = x + 6.1f;
        s.float7 = x + 7.1f;
        s.float8 = x + 8.1f;
        return s;
    }

    // double
    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble1 returnMyStructDouble1(double x)
    {
        MyStructDouble1 s = new MyStructDouble1();
        s.double1 = x + 1.1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble2 returnMyStructDouble2(double x)
    {
        MyStructDouble2 s = new MyStructDouble2();
        s.double1 = x + 1.1;
        s.double2 = x + 2.1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble3 returnMyStructDouble3(double x)
    {
        MyStructDouble3 s = new MyStructDouble3();
        s.double1 = x + 1.1;
        s.double2 = x + 2.1;
        s.double3 = x + 3.1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble4 returnMyStructDouble4(double x)
    {
        MyStructDouble4 s = new MyStructDouble4();
        s.double1 = x + 1.1;
        s.double2 = x + 2.1;
        s.double3 = x + 3.1;
        s.double4 = x + 4.1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble5 returnMyStructDouble5(double x)
    {
        MyStructDouble5 s = new MyStructDouble5();
        s.double1 = x + 1.1;
        s.double2 = x + 2.1;
        s.double3 = x + 3.1;
        s.double4 = x + 4.1;
        s.double5 = x + 5.1;
        return s;
    }

    [MethodImplAttribute(MethodImplOptions.NoInlining)]
    public static MyStructDouble8 returnMyStructDouble8(double x)
    {
        MyStructDouble8 s = new MyStructDouble8();
        s.double1 = x + 1.1;
        s.double2 = x + 2.1;
        s.double3 = x + 3.1;
        s.double4 = x + 4.1;
        s.double5 = x + 5.1;
        s.double6 = x + 6.1;
        s.double7 = x + 7.1;
        s.double8 = x + 8.1;
        return s;
    }


    public static int Main()
    {
        // int
        MyStructInt1 sI1 = returnMyStructInt1(100);
        if (sI1.int1 != 101) return Fail;
        Console.WriteLine(sI1);

        MyStructInt2 sI2 = returnMyStructInt2(200);
        if (sI2.int1 != 201 || sI2.int2 != 202) return Fail;
        Console.WriteLine(sI2);

        MyStructInt4 sI4 = returnMyStructInt4(400);
        if (sI4.int1 != 401 || sI4.int2 != 402 || sI4.int3 != 403 || sI4.int4 != 404) return Fail;
        Console.WriteLine(sI4);

        // long
        MyStructLong1 sL1 = returnMyStructLong1(100);
        if (sL1.long1 != 101) return Fail;
        Console.WriteLine(sL1);

        MyStructLong2 sL2 = returnMyStructLong2(200);
        if (sL2.long1 != 201 || sL2.long2 != 202) return Fail;
        Console.WriteLine(sL2);

        MyStructLong4 sL4 = returnMyStructLong4(400);
        if (sL4.long1 != 401 || sL4.long2 != 402 || sL4.long3 != 403 || sL4.long4 != 404) return Fail;
        Console.WriteLine(sL4);


        // float
        MyStructFloat1 sF1 = returnMyStructFloat1(100.0f);
        if (sF1.float1 != 101.1f) return Fail;
        Console.WriteLine(sF1);

        MyStructFloat2 sF2 = returnMyStructFloat2(200.0f);
        if (sF2.float1 != 201.1f || sF2.float2 != 202.1f) return Fail;
        Console.WriteLine(sF2);

        MyStructFloat3 sF3 = returnMyStructFloat3(300.0f);
        if (sF3.float1 != 301.1f || sF3.float2 != 302.1f || sF3.float3 != 303.1f) return Fail;
        Console.WriteLine(sF3);

        MyStructFloat4 sF4 = returnMyStructFloat4(400.0f);
        if (sF4.float1 != 401.1f || sF4.float2 != 402.1f || sF4.float3 != 403.1f || sF4.float4 != 404.1f) return Fail;
        Console.WriteLine(sF4);

        MyStructFloat5 sF5 = returnMyStructFloat5(500.0f);
        if (sF5.float1 != 501.1f || sF5.float2 != 502.1f || sF5.float3 != 503.1f || sF5.float4 != 504.1f || sF5.float5 != 505.1f) return Fail;
        Console.WriteLine(sF5);

        MyStructFloat8 sF8 = returnMyStructFloat8(800.0f);
        if (sF8.float1 != 801.1f || sF8.float2 != 802.1f || sF8.float3 != 803.1f || sF8.float4 != 804.1f || sF8.float5 != 805.1f || sF8.float6 != 806.1f || sF8.float7 != 807.1f || sF8.float8 != 808.1f) return Fail;
        Console.WriteLine(sF8);

        // double
        MyStructDouble1 sD1 = returnMyStructDouble1(100.0d);
        if (sD1.double1 != 101.1d) return Fail;
        Console.WriteLine(sD1);

        MyStructDouble2 sD2 = returnMyStructDouble2(200.0d);
        if (sD2.double1 != 201.1d || sD2.double2 != 202.1d) return Fail;
        Console.WriteLine(sD2);

        MyStructDouble3 sD3 = returnMyStructDouble3(300.0d);
        if (sD3.double1 != 301.1d || sD3.double2 != 302.1d || sD3.double3 != 303.1d) return Fail;
        Console.WriteLine(sD3);

        MyStructDouble4 sD4 = returnMyStructDouble4(400.0d);
        if (sD4.double1 != 401.1d || sD4.double2 != 402.1d || sD4.double3 != 403.1d || sD4.double4 != 404.1d) return Fail;
        Console.WriteLine(sD4);

        MyStructDouble5 sD5 = returnMyStructDouble5(500.0d);
        if (sD5.double1 != 501.1d || sD5.double2 != 502.1d || sD5.double3 != 503.1d || sD5.double4 != 504.1d || sD5.double5 != 505.1d) return Fail;
        Console.WriteLine(sD5);

        MyStructDouble8 sD8 = returnMyStructDouble8(800.0d);
        if (sD8.double1 != 801.1d || sD8.double2 != 802.1d || sD8.double3 != 803.1d || sD8.double4 != 804.1d || sD8.double5 != 805.1d || sD8.double6 != 806.1d || sD8.double7 != 807.1d || sD8.double8 != 808.1d) return Fail;
        Console.WriteLine(sD8);

        return Pass;
    }
}