[interp] Fix interp logging (#17636)
[mono-project.git] / mono / mini / s390-abi.cs
blob88f99a99493256d3c1424426bf3f9f8d6996f7b9
1 using System;
2 using System.Reflection;
4 /*
5 * Regression tests for the mono JIT.
7 * Each test needs to be of the form:
9 * static int test_<result>_<name> ();
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.
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)
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.
26 class Tests {
28 public struct TestStruct1
30 public int a;
33 public struct TestStruct2
35 public int a;
36 public int b;
39 public struct TestStruct3
41 public int a;
42 public int b;
43 public int c;
46 static int Main () {
47 return TestDriver.RunTests (typeof (Tests));
50 static void reg_struct(TestStruct1 regStruct)
52 regStruct.a = 1;
55 static int test_0_regstruct ()
57 TestStruct1 myStruct;
58 myStruct.a = 1;
59 reg_struct(myStruct);
60 if (myStruct.a == 1)
61 return 0;
62 else
63 return 1;
66 static int reg_struct_ret(TestStruct2 regStruct)
68 return regStruct.b;
71 static int test_0_reg_return ()
73 TestStruct2 myStruct;
74 myStruct.a = 0;
75 myStruct.b = 42;
76 if (reg_struct_ret(myStruct) == 42)
77 return 0;
78 return 2;
81 static int spill_regs (int a, int b, int c, int d, int e, int f)
83 return f;
86 static int test_0_spill_regs ()
88 if (spill_regs (1, 2, 3, 4, 5, 6) == 6)
89 return 0;
90 else
91 return 3;
94 static TestStruct3 spill_struct (TestStruct3 regStruct, int value)
96 regStruct.c = value;
97 return(regStruct);
100 static TestStruct3 ret_big_struct (int value_a, int value_c)
102 TestStruct3 regStruct = new TestStruct3();
103 regStruct.a = value_a;
104 regStruct.c = value_c;
105 return(regStruct);
108 static int spill_struct_void (TestStruct3 regStruct)
110 if (regStruct.c == 255)
111 return 0;
112 else
113 return 7;
116 static int receive_spill_struct (TestStruct2 regStruct)
118 if (regStruct.b == 181)
119 return 0;
120 else
121 return 8;
124 static int pass_spill_struct_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
126 int retVal;
127 retVal = receive_spill_struct_big(regStruct);
128 return retVal;
131 static int receive_spill_struct_big (TestStruct3 regStruct)
133 if (regStruct.c == 999)
134 return 0;
135 else
136 return 9;
139 static int receive_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
141 if (regStruct.b == 181)
142 return 0;
143 else
144 return 10;
147 static int receive_struct_spill_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
149 if (regStruct.c == 999)
150 return 0;
151 else
152 return 11;
155 static int pass_spill_struct (int a, int b, int c, int d, int e, TestStruct2 regStruct)
157 int retVal;
158 retVal = receive_spill_struct(regStruct);
159 return retVal;
162 static int pass_struct_spill (TestStruct2 regStruct)
164 int retVal;
165 retVal = receive_struct_spill(1,2,3,4,5,regStruct);
166 return retVal;
169 static int pass_struct_spill_big(TestStruct3 regStruct)
171 int retVal;
172 retVal = receive_struct_spill_big(1,2,3,4,5,regStruct);
173 return retVal;
176 static int pass_spill_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
178 int retVal;
179 retVal = receive_struct_spill(a,b,c,d,e,regStruct);
180 return retVal;
183 static int pass_spill_struct_spill_big(int a, int b, int c, int d, int e, TestStruct3 regStruct)
185 int retVal;
186 retVal = receive_struct_spill_big(a,b,c,d,e,regStruct);
187 return retVal;
190 static int test_0_spill ()
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;
202 static int test_0_spill_void ()
204 TestStruct3 myStruct;
205 myStruct.a = 0;
206 myStruct.b = 127;
207 myStruct.c = 255;
208 return (spill_struct_void(myStruct));
211 static int spill_struct_ret (TestStruct3 regStruct)
213 return (regStruct.c);
217 static int test_0_spill_ret ()
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;
228 static TestStruct2 struct_ret(TestStruct2 regStruct)
230 regStruct.a = -1;
231 regStruct.b = 72;
232 return(regStruct);
235 static int test_0_struct_ret ()
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;
247 static float TestSingle (float a, float b, float c)
249 return b;
252 static int test_0_TestSingle ()
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;
261 static int test_0_pass_spill ()
263 TestStruct2 myStruct;
264 myStruct.a = 32;
265 myStruct.b = 181;
266 return (pass_spill_struct (1, 2, 3, 4, 5, myStruct));
269 static int test_0_pass_spill_big ()
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));
278 static int test_0_pass_struct_spill ()
280 TestStruct2 myStruct;
281 myStruct.a = 32;
282 myStruct.b = 181;
283 return (pass_struct_spill (myStruct));
286 static int test_0_pass_struct_spill_big ()
288 TestStruct3 myStruct;
289 myStruct.a = 32;
290 myStruct.b = 181;
291 myStruct.c = 999;
292 return (pass_struct_spill_big (myStruct));
295 static int test_0_pass_ret_big_struct ()
297 TestStruct3 myStruct;
298 myStruct = ret_big_struct(10,132);
299 if (myStruct.c == 132)
300 return 0;
301 else
302 return 1;
305 static int test_0_pass_spill_struct_spill ()
307 TestStruct2 myStruct;
308 myStruct.a = 32;
309 myStruct.b = 181;
310 return (pass_spill_struct_spill (1,2,3,4,5,myStruct));
313 static int test_0_pass_spill_struct_spill_big ()
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));
322 static long pass_long_odd (int a, long b)
324 return (b);
327 static int test_0_pass_long_odd ()
329 int a = 5;
330 long b = 9000;
331 if (pass_long_odd(a,b) == 9000)
332 return 0;
333 else
334 return 9;
337 static float pass_double_ret_float(double a)
339 float b;
340 b = (float) a;
341 return b;
344 static int test_0_pass_double_ret_float ()
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;
354 static double pass_float_ret_double(float a)
356 double b;
357 b = (double) a;
358 return b;
361 static int test_0_pass_float_ret_double ()
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;