Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / s390-abi.cs
1 using System;
2 using System.Reflection;
3
4 /*
5  * Regression tests for the mono JIT.
6  *
7  * Each test needs to be of the form:
8  *
9  * static int test_<result>_<name> ();
10  *
11  * where <result> is an integer (the value that needs to be returned by
12  * the method to make it pass.
13  * <name> is a user-displayed name used to identify the test.
14  *
15  * The tests can be driven in two ways:
16  * *) running the program directly: Main() uses reflection to find and invoke
17  *      the test methods (this is useful mostly to check that the tests are correct)
18  * *) with the --regression switch of the jit (this is the preferred way since
19  *      all the tests will be run with optimizations on and off)
20  *
21  * The reflection logic could be moved to a .dll since we need at least another
22  * regression test file written in IL code to have better control on how
23  * the IL code looks.
24  */
25
26 class Tests {
27
28         public struct TestStruct1 
29         {
30                 public int a;
31         }
32         
33         public struct TestStruct2
34         {       
35                 public int a;
36                 public int b;
37         }
38
39         public struct TestStruct3
40         {
41                 public int a;
42                 public int b;
43                 public int c;
44         }
45
46         static int Main () {
47                 return TestDriver.RunTests (typeof (Tests));
48         }
49
50         static void reg_struct(TestStruct1 regStruct) 
51         {
52                 regStruct.a = 1;
53         }
54
55         static int test_0_regstruct () 
56         {
57                 TestStruct1 myStruct;
58                 myStruct.a = 1;
59                 reg_struct(myStruct);
60                 if (myStruct.a == 1)
61                         return 0;
62                 else
63                         return 1;
64         }
65
66         static int reg_struct_ret(TestStruct2 regStruct) 
67         {
68                 return regStruct.b;
69         }
70
71         static int test_0_reg_return () 
72         {
73                 TestStruct2 myStruct;
74                 myStruct.a = 0;
75                 myStruct.b = 42;
76                 if (reg_struct_ret(myStruct) == 42)
77                         return 0;
78                 return 2;
79         }
80
81         static int spill_regs (int a, int b, int c, int d, int e, int f)
82         {
83                 return f;
84         }
85
86         static int test_0_spill_regs ()
87         {
88                 if (spill_regs (1, 2, 3, 4, 5, 6) == 6)
89                         return 0;
90                 else
91                         return 3;
92         }
93
94         static TestStruct3 spill_struct (TestStruct3 regStruct, int value)
95         {
96                 regStruct.c = value;
97                 return(regStruct);
98         }
99
100         static TestStruct3 ret_big_struct (int value_a, int value_c)
101         {
102                 TestStruct3 regStruct = new TestStruct3();
103                 regStruct.a = value_a;
104                 regStruct.c = value_c;
105                 return(regStruct);
106         }
107
108         static int spill_struct_void (TestStruct3 regStruct)
109         {
110                 if (regStruct.c == 255)
111                         return 0;
112                 else
113                         return 7;
114         }
115
116         static int receive_spill_struct (TestStruct2 regStruct)
117         {
118                 if (regStruct.b == 181)
119                         return 0;
120                 else
121                         return 8;
122         }
123
124         static int pass_spill_struct_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
125         {
126                 int retVal;
127                 retVal = receive_spill_struct_big(regStruct);
128                 return retVal;
129         }
130
131         static int receive_spill_struct_big (TestStruct3 regStruct)
132         {
133                 if (regStruct.c == 999)
134                         return 0;
135                 else
136                         return 9;
137         }
138
139         static int receive_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
140         {
141                 if (regStruct.b == 181)
142                         return 0;
143                 else
144                         return 10;
145         }
146
147         static int receive_struct_spill_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
148         {
149                 if (regStruct.c == 999)
150                         return 0;
151                 else
152                         return 11;
153         }
154
155         static int pass_spill_struct (int a, int b, int c, int d, int e, TestStruct2 regStruct)
156         {
157                 int retVal;
158                 retVal = receive_spill_struct(regStruct);
159                 return retVal;
160         }
161
162         static int pass_struct_spill (TestStruct2 regStruct)
163         {
164                 int retVal;
165                 retVal = receive_struct_spill(1,2,3,4,5,regStruct);
166                 return retVal;
167         }
168
169         static int pass_struct_spill_big(TestStruct3 regStruct)
170         {
171                 int retVal;
172                 retVal = receive_struct_spill_big(1,2,3,4,5,regStruct);
173                 return retVal;
174         }
175
176         static int pass_spill_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
177         {
178                 int retVal;
179                 retVal = receive_struct_spill(a,b,c,d,e,regStruct);
180                 return retVal;
181         }
182
183         static int pass_spill_struct_spill_big(int a, int b, int c, int d, int e, TestStruct3 regStruct)
184         {
185                 int retVal;
186                 retVal = receive_struct_spill_big(a,b,c,d,e,regStruct);
187                 return retVal;
188         }
189
190         static int test_0_spill () 
191         {
192                 TestStruct3 myStruct;
193                 myStruct.a = 64;        
194                 myStruct.b = 255;
195                 myStruct.c = 127;
196                 myStruct = spill_struct(myStruct, 99);
197                 if (myStruct.c == 99)
198                         return 0;
199                 return myStruct.c;
200         }
201
202         static int test_0_spill_void ()
203         {
204                 TestStruct3 myStruct;
205                 myStruct.a = 0;
206                 myStruct.b = 127;
207                 myStruct.c = 255;
208                 return (spill_struct_void(myStruct));
209         }
210
211         static int spill_struct_ret (TestStruct3 regStruct)
212         {
213                 return (regStruct.c);
214                 
215         }
216
217         static int test_0_spill_ret ()
218         {
219                 TestStruct3 myStruct;
220                 myStruct.a = 0; 
221                 myStruct.b = 0;
222                 myStruct.c = 69;
223                 if (spill_struct_ret(myStruct) == 69)
224                         return 0;
225                 return 5;
226         }
227
228         static TestStruct2 struct_ret(TestStruct2 regStruct)
229         {
230                 regStruct.a = -1;
231                 regStruct.b = 72;
232                 return(regStruct);
233         }
234
235         static int test_0_struct_ret ()
236         {
237                 TestStruct2 myStruct;
238                 myStruct.a = 99;
239                 myStruct.b = 14;
240                 myStruct = struct_ret(myStruct);
241                 if (myStruct.b == 72)
242                         return 0;
243                 else
244                         return myStruct.b;
245         }
246
247         static float TestSingle (float a, float b, float c)
248         {
249                 return b;
250         }
251
252         static int test_0_TestSingle ()
253         {
254                 float a = 3F; float b = 4.5F; float c = 900F;
255                 if (TestSingle(a, b, c) == b)
256                         return 0;
257                 else
258                         return 6;
259         }
260
261         static int test_0_pass_spill ()
262         {
263                 TestStruct2 myStruct;
264                 myStruct.a = 32;
265                 myStruct.b = 181;
266                 return (pass_spill_struct (1, 2, 3, 4, 5, myStruct));
267         }
268                 
269         static int test_0_pass_spill_big ()
270         {
271                 TestStruct3 myStruct;
272                 myStruct.a = 32;
273                 myStruct.b = 181;
274                 myStruct.c = 999;
275                 return (pass_spill_struct_big (1, 2, 3, 4, 5, myStruct));
276         }
277                 
278         static int test_0_pass_struct_spill ()
279         {
280                 TestStruct2 myStruct;
281                 myStruct.a = 32;
282                 myStruct.b = 181;
283                 return (pass_struct_spill (myStruct));
284         }
285                 
286         static int test_0_pass_struct_spill_big ()
287         {
288                 TestStruct3 myStruct;
289                 myStruct.a = 32;
290                 myStruct.b = 181;
291                 myStruct.c = 999;
292                 return (pass_struct_spill_big (myStruct));
293         }
294                 
295         static int test_0_pass_ret_big_struct ()
296         {
297                 TestStruct3 myStruct;
298                 myStruct = ret_big_struct(10,132);
299                 if (myStruct.c == 132)
300                         return 0;
301                 else
302                         return 1;
303         }
304                 
305         static int test_0_pass_spill_struct_spill ()
306         {
307                 TestStruct2 myStruct;
308                 myStruct.a = 32;
309                 myStruct.b = 181;
310                 return (pass_spill_struct_spill (1,2,3,4,5,myStruct));
311         }
312                 
313         static int test_0_pass_spill_struct_spill_big ()
314         {
315                 TestStruct3 myStruct;
316                 myStruct.a = 32;
317                 myStruct.b = 181;
318                 myStruct.c = 999;
319                 return (pass_spill_struct_spill_big (1,2,3,4,5,myStruct));
320         }
321
322         static long pass_long_odd (int a, long b)
323         {
324                 return (b);
325         }
326                 
327         static int test_0_pass_long_odd ()
328         {
329                 int a = 5;
330                 long b = 9000;
331                 if (pass_long_odd(a,b) == 9000)
332                         return 0;
333                 else
334                         return 9;
335         }
336
337         static float pass_double_ret_float(double a)
338         {
339                 float b;
340                 b = (float) a;
341                 return b;
342         }
343
344         static int test_0_pass_double_ret_float ()
345         {
346                 double a = 654.34;
347                 float b = 654.34f;
348                 if (pass_double_ret_float(a) == b)
349                         return 0;
350                 else
351                         return 10;
352         }
353
354         static double pass_float_ret_double(float a)
355         {
356                 double b;
357                 b = (double) a;
358                 return b;
359         }
360
361         static int test_0_pass_float_ret_double ()
362         {
363                 float a = 654.34f;
364                 double b = 654.34;
365                 if (pass_float_ret_double(a) == b)
366                         return 0;
367                 else
368                         return 11;
369         }
370
371 }