Merge pull request #5714 from alexischr/update_bockbuild
[mono.git] / mono / mini / basic-calls.cs
index 77996ab2ee3d5f7ca499f34f9b67a427594ad5f1..ad3cdde59a1f3284f151948cf5441b6910db2fd8 100644 (file)
@@ -6,7 +6,7 @@ using System.Reflection;
  *
  * Each test needs to be of the form:
  *
- * static int test_<result>_<name> ();
+ * public static int test_<result>_<name> ();
  *
  * where <result> is an integer (the value that needs to be returned by
  * the method to make it pass.
@@ -23,16 +23,23 @@ using System.Reflection;
  * the IL code looks.
  */
 
-class Tests {
+#if __MOBILE__
+class CallsTests
+#else
+class Tests
+#endif
+{
 
-       static int Main () {
-               return TestDriver.RunTests (typeof (Tests));
+#if !__MOBILE__
+       public static int Main (string[] args) {
+               return TestDriver.RunTests (typeof (Tests), args);
        }
+#endif
 
        static void dummy () {
        }
 
-       static int test_0_return () {
+       public static int test_0_return () {
                dummy ();
                return 0;
        }
@@ -41,7 +48,7 @@ class Tests {
                return 1;
        }
 
-       static int test_2_int_return () {
+       public static int test_2_int_return () {
                int r = dummy1 ();
                if (r == 1)
                        return 2;
@@ -52,7 +59,7 @@ class Tests {
                return val + 1;
        }
 
-       static int test_1_int_pass () {
+       public static int test_1_int_pass () {
                int r = add1 (5);
                if (r == 6)
                        return 1;
@@ -63,7 +70,7 @@ class Tests {
                return val + t + b + da;
        }
 
-       static int test_1_int_pass_many () {
+       public static int test_1_int_pass_many () {
                byte b = 6;
                int r = add_many (5, 2, b, 1);
                if (r == 14)
@@ -81,7 +88,7 @@ class Tests {
                }
 
        /* bug #42134 */
-       static int test_2_inline_saved_arg_type () {
+       public static int test_2_inline_saved_arg_type () {
                float f = 100.0f;
                return GetFloat (f) == f? 2: 1;
        }
@@ -90,7 +97,7 @@ class Tests {
                return a + (int)b + c + (int)d;
        }
 
-       static int test_5_pass_longs () {
+       public static int test_5_pass_longs () {
                return pass_many_types (1, 2, -5, 7);
        }
 
@@ -98,7 +105,7 @@ class Tests {
                return a+b+c+d+e+f+g+h+i+j;
        }
 
-       static int test_55_pass_even_more () {
+       public static int test_55_pass_even_more () {
                return overflow_registers (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
 
@@ -106,7 +113,7 @@ class Tests {
                return (int)(a + b + c + d + e + f + g);
        }
 
-       static int test_1_sparc_argument_passing () {
+       public static int test_1_sparc_argument_passing () {
                // The 4. argument tests split reg/mem argument passing
                // The 5. argument tests mem argument passing
                // The 7. argument tests passing longs in misaligned memory
@@ -118,23 +125,23 @@ class Tests {
                return (int)(a + b + c + d + e + f + g);
        }
 
-       static int test_21_sparc_byte_argument_passing () {
+       public static int test_21_sparc_byte_argument_passing () {
                return pass_bytes (0, 1, 2, 3, 4, 5, 6);
        }
 
-       static int pass_sbytes (sbyte a, sbyte b, sbyte c, sbyte d, sbyte e, sbyte f, sbyte g) {
-               return (int)(a + b + c + d + e + f + g);
+       static int pass_sbytes (sbyte a, sbyte b, sbyte c, sbyte d, sbyte e, sbyte f, sbyte g, sbyte h1, sbyte h2, sbyte h3, sbyte h4) {
+               return (int)(a + b + c + d + e + f + g + h1 + h2 + h3 + h4);
        }
 
-       static int test_21_sparc_sbyte_argument_passing () {
-               return pass_sbytes (0, 1, 2, 3, 4, 5, 6);
+       public static int test_55_sparc_sbyte_argument_passing () {
+               return pass_sbytes (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        }
 
        static int pass_shorts (short a, short b, short c, short d, short e, short f, short g) {
                return (int)(a + b + c + d + e + f + g);
        }
 
-       static int test_21_sparc_short_argument_passing () {
+       public static int test_21_sparc_short_argument_passing () {
                return pass_shorts (0, 1, 2, 3, 4, 5, 6);
        }
 
@@ -142,7 +149,7 @@ class Tests {
                return (int)(a + b + c + d + e + f + g);
        }
 
-       static int test_721_sparc_float_argument_passing () {
+       public static int test_721_sparc_float_argument_passing () {
                return pass_floats_doubles (100.0f, 101.0, 102.0, 103.0, 104.0, 105.0f, 106.0);
        }
 
@@ -150,7 +157,7 @@ class Tests {
                return a + b + c + d + e + f + g + h + i + j;
        }
 
-       static int test_55_sparc_float_argument_passing2 () {
+       public static int test_55_sparc_float_argument_passing2 () {
                return (int)pass_floats (1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f);
        }
 
@@ -160,7 +167,7 @@ class Tests {
                return d - d2 < 0.000001;
        }
                
-       static int test_0_float_argument_passing_precision () {
+       public static int test_0_float_argument_passing_precision () {
                float f = 7.183757E-41f;
                return is_small (f) ? 0 : 1;
        }
@@ -176,7 +183,7 @@ class Tests {
 
        // Test that arguments are moved to the stack from incoming registers
        // when the argument must reside in the stack because its address is taken
-       static int test_2_sparc_takeaddr_argument_passing () {
+       public static int test_2_sparc_takeaddr_argument_passing () {
                return pass_takeaddr_ints_longs (1, 2, 253, -253, System.Int64.MaxValue, 0, System.Int64.MinValue);
        }
 
@@ -188,7 +195,7 @@ class Tests {
                return pass_byref_floats_doubles (ref a, ref b, ref c, ref d, ref e, ref f, ref g);
        }
 
-       static int test_721_sparc_takeaddr_argument_passing2 () {
+       public static int test_721_sparc_takeaddr_argument_passing2 () {
                return pass_takeaddr_floats_doubles (100.0f, 101.0, 102.0, 103.0, 104.0, 105.0f, 106.0);
        }
 
@@ -197,7 +204,7 @@ class Tests {
        }
 
        // Test byref double argument passing
-       static int test_0_sparc_byref_double_argument_passing () {
+       public static int test_0_sparc_byref_double_argument_passing () {
                double d;
                pass_byref_double (out d);
                return (d == 5.0) ? 0 : 1;
@@ -210,7 +217,7 @@ class Tests {
        }
 
        // Test that assignment to long arguments work
-       static int test_0_long_arg_assign ()
+       public static int test_0_long_arg_assign ()
        {
                ulong c = 0x800000ff00000000;
                        
@@ -224,7 +231,7 @@ class Tests {
                return ptr;
        }
 
-       static unsafe int test_0_ptr_return ()
+       public static unsafe int test_0_ptr_return ()
        {
                void *ptr = new IntPtr (55).ToPointer ();
 
@@ -238,7 +245,7 @@ class Tests {
                return (f != f);
        }
 
-       static int test_0_isnan () {
+       public static int test_0_isnan () {
                float f = 1.0f;
                return isnan (f) ? 1 : 0;
        }
@@ -248,7 +255,7 @@ class Tests {
                        return -1;
                return v2;
        }
-       static int test_1_handle_dup_stloc () {
+       public static int test_1_handle_dup_stloc () {
                int index = 0;
                int val = first_is_zero (index, ++index);
                if (val != 1)
@@ -276,6 +283,29 @@ class Tests {
                return 0;
        }
 
+       public static void use_long_arg (ulong l) {
+               for (int i = 0; i < 10; ++i)
+                       l ++;
+       }
+
+       public static ulong return_long_arg (object o, ulong perm) {
+               use_long_arg (perm);
+
+        perm = 0x8000000000000FFF;
+
+               use_long_arg (perm);
+
+               return perm;
+       }
+
+    public static int test_0_sparc_long_ret_regress_541577 () {
+        ulong perm = 0x8000000000000FFF;
+
+        ulong work = return_long_arg (null, perm);
+
+               return work == perm ? 0 : 1;
+       }
+
        static void doit (double value, out long m) {
                m = (long) value;
        }
@@ -288,5 +318,28 @@ class Tests {
                return 0;
        }
 
-}
+       public static bool arm64_stack_arg_reg_bool (object o1, object o2, object o3, object o4, object o5, object o6, object o7,
+                                                                                                bool foo, bool bar) {
+               bool res1 = bar || foo;
+               bool res2 = bar || foo;
+               return res1 | res2;
+       }
+
+       public static int arm64_stack_arg_reg_sbyte (object o1, object o2, object o3, object o4, object o5, object o6, object o7,
+                                                                                                sbyte foo, sbyte bar) {
+               int res1 = bar + foo;
+               int res2 = bar + foo;
+               return res1 + res2;
+       }
+
+       // bool argument passed on the stack and promoted to a register
+       public static int test_0_arm64_stack_arg_reg_bool () {
+           bool res = arm64_stack_arg_reg_bool (null, null, null, null, null, null, null, false, false);
+               return res ? 1 : 0;
+       }
 
+       public static int test_0_arm64_stack_arg_reg_sbyte () {
+           int res = arm64_stack_arg_reg_sbyte (null, null, null, null, null, null, null, -4, -7);
+               return res == -22 ? 0 : 1;
+       }
+}