Add some s390 specific tests
[mono.git] / mono / mini / s390-abi.cs
blobec404b10c83a4fa759d7bb1c42dbd29e502bc54f
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)
96 regStruct.c = 99;
97 return(regStruct);
100 static int spill_struct_void (TestStruct3 regStruct)
102 if (regStruct.c == 255)
103 return 0;
104 else
105 return 7;
108 static int receive_spill_struct (TestStruct2 regStruct)
110 if (regStruct.b == 181)
111 return 0;
112 else
113 return 8;
116 static int pass_spill_struct_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
118 int retVal;
119 retVal = receive_spill_struct_big(regStruct);
120 return retVal;
123 static int receive_spill_struct_big (TestStruct3 regStruct)
125 if (regStruct.c == 999)
126 return 0;
127 else
128 return 9;
131 static int receive_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
133 if (regStruct.b == 181)
134 return 0;
135 else
136 return 10;
139 static int receive_struct_spill_big (int a, int b, int c, int d, int e, TestStruct3 regStruct)
141 if (regStruct.c == 999)
142 return 0;
143 else
144 return 11;
147 static int pass_spill_struct (int a, int b, int c, int d, int e, TestStruct2 regStruct)
149 int retVal;
150 retVal = receive_spill_struct(regStruct);
151 return retVal;
154 static int pass_struct_spill (TestStruct2 regStruct)
156 int retVal;
157 retVal = receive_struct_spill(1,2,3,4,5,regStruct);
158 return retVal;
161 static int pass_struct_spill_big(TestStruct3 regStruct)
163 int retVal;
164 retVal = receive_struct_spill_big(1,2,3,4,5,regStruct);
165 return retVal;
168 static int pass_spill_struct_spill (int a, int b, int c, int d, int e, TestStruct2 regStruct)
170 int retVal;
171 retVal = receive_struct_spill(a,b,c,d,e,regStruct);
172 return retVal;
175 static int pass_spill_struct_spill_big(int a, int b, int c, int d, int e, TestStruct3 regStruct)
177 int retVal;
178 retVal = receive_struct_spill_big(a,b,c,d,e,regStruct);
179 return retVal;
182 static int test_0_spill ()
184 TestStruct3 myStruct;
185 myStruct.a = 64;
186 myStruct.b = 255;
187 myStruct.c = 127;
188 myStruct = spill_struct(myStruct);
189 if (myStruct.c == 99)
190 return 0;
191 return myStruct.c;
194 static int test_0_spill_void ()
196 TestStruct3 myStruct;
197 myStruct.a = 0;
198 myStruct.b = 127;
199 myStruct.c = 255;
200 return (spill_struct_void(myStruct));
203 static int spill_struct_ret (TestStruct3 regStruct)
205 return (regStruct.c);
209 static int test_0_spill_ret ()
211 TestStruct3 myStruct;
212 myStruct.a = 0;
213 myStruct.b = 0;
214 myStruct.c = 69;
215 if (spill_struct_ret(myStruct) == 69)
216 return 0;
217 return 5;
220 static TestStruct2 struct_ret(TestStruct2 regStruct)
222 regStruct.a = -1;
223 regStruct.b = 72;
224 return(regStruct);
227 static int test_0_struct_ret ()
229 TestStruct2 myStruct;
230 myStruct.a = 99;
231 myStruct.b = 14;
232 myStruct = struct_ret(myStruct);
233 if (myStruct.b == 72)
234 return 0;
235 else
236 return myStruct.b;
239 static float TestSingle (float a, float b, float c)
241 return b;
244 static int test_0_TestSingle ()
246 float a = 3F; float b = 4.5F; float c = 900F;
247 if (TestSingle(a, b, c) == b)
248 return 0;
249 else
250 return 6;
253 static int test_0_pass_spill ()
255 TestStruct2 myStruct;
256 myStruct.a = 32;
257 myStruct.b = 181;
258 return (pass_spill_struct (1, 2, 3, 4, 5, myStruct));
261 static int test_0_pass_spill_big ()
263 TestStruct3 myStruct;
264 myStruct.a = 32;
265 myStruct.b = 181;
266 myStruct.c = 999;
267 return (pass_spill_struct_big (1, 2, 3, 4, 5, myStruct));
270 static int test_0_pass_struct_spill ()
272 TestStruct2 myStruct;
273 myStruct.a = 32;
274 myStruct.b = 181;
275 return (pass_struct_spill (myStruct));
278 static int test_0_pass_struct_spill_big ()
280 TestStruct3 myStruct;
281 myStruct.a = 32;
282 myStruct.b = 181;
283 myStruct.c = 999;
284 return (pass_struct_spill_big (myStruct));
287 static int test_0_pass_spill_struct_spill ()
289 TestStruct2 myStruct;
290 myStruct.a = 32;
291 myStruct.b = 181;
292 return (pass_spill_struct_spill (1,2,3,4,5,myStruct));
295 static int test_0_pass_spill_struct_spill_big ()
297 TestStruct3 myStruct;
298 myStruct.a = 32;
299 myStruct.b = 181;
300 myStruct.c = 999;
301 return (pass_spill_struct_spill_big (1,2,3,4,5,myStruct));
304 static long pass_long_odd (int a, long b)
306 return (b);
309 static int test_0_pass_long_odd ()
311 int a = 5;
312 long b = 9000;
313 if (pass_long_odd(a,b) == 9000)
314 return 0;
315 else
316 return 9;