2006-01-21 Martin Baulig <martin@ximian.com>
[mono.git] / mono / mini / basic-calls.cs
index 74dc7391fc17f27f56c0d88480fb7936b3bff4a9..276f4b9cd8c65133bbeb5e92e46806685292fd9b 100644 (file)
@@ -146,18 +146,50 @@ class Tests {
                return pass_floats_doubles (100.0f, 101.0, 102.0, 103.0, 104.0, 105.0f, 106.0);
        }
 
-       static int pass_byref_ints_longs (ref int a, ref long b, ref long c, ref long d, ref long e, ref int f, ref long g) {
+       static float pass_floats (float a, float b, float c, float d, float e, float f, float g, float h, float i, float j) {
+               return a + b + c + d + e + f + g + h + i + j;
+       }
+
+       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);
+       }
+
+       // The first argument must be passed on a dword aligned stack location
+       static int pass_byref_ints_longs (ref long a, ref int b, ref byte c, ref short d, ref long e, ref int f, ref long g) {
                return (int)(a + b + c + d + e + f + g);
        }
 
-       static int pass_takeaddr_ints_longs (int a, long b, long c, long d, long e, int f, long g) {
+       static int pass_takeaddr_ints_longs (long a, int b, byte c, short d, long e, int f, long g) {
                return pass_byref_ints_longs (ref a, ref b, ref c, ref d, ref e, ref f, ref g);
        }
 
        // 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_1_sparc_takeaddr_argument_passing () {
-               return pass_takeaddr_ints_longs (1, 2, System.Int64.MaxValue, System.Int64.MinValue, System.Int64.MaxValue, 0, System.Int64.MinValue);
+       static int test_2_sparc_takeaddr_argument_passing () {
+               return pass_takeaddr_ints_longs (1, 2, 253, -253, System.Int64.MaxValue, 0, System.Int64.MinValue);
+       }
+
+       static int pass_byref_floats_doubles (ref float a, ref double b, ref double c, ref double d, ref double e, ref float f, ref double g) {
+               return (int)(a + b + c + d + e + f + g);
+       }
+
+       static int pass_takeaddr_floats_doubles (float a, double b, double c, double d, double e, float f, double g) {
+               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 () {
+               return pass_takeaddr_floats_doubles (100.0f, 101.0, 102.0, 103.0, 104.0, 105.0f, 106.0);
+       }
+
+       static void pass_byref_double (out double d) {
+               d = 5.0;
+       }
+
+       // Test byref double argument passing
+       static int test_0_sparc_byref_double_argument_passing () {
+               double d;
+               pass_byref_double (out d);
+               return (d == 5.0) ? 0 : 1;
        }
 
        static void shift_un_arg (ulong value) {
@@ -185,7 +217,7 @@ class Tests {
        {
                void *ptr = new IntPtr (55).ToPointer ();
 
-               if (byref_return (ptr) == ptr)
+               if (ptr_return (ptr) == ptr)
                        return 0;
                else
                        return 1;
@@ -199,5 +231,51 @@ class Tests {
                float f = 1.0f;
                return isnan (f) ? 1 : 0;
        }
+
+       static int first_is_zero (int v1, int v2) {
+               if (v1 != 0)
+                       return -1;
+               return v2;
+       }
+       static int test_1_handle_dup_stloc () {
+               int index = 0;
+               int val = first_is_zero (index, ++index);
+               if (val != 1)
+                       return 2;
+               return 1;
+       }
+
+       static long return_5low () {
+               return 5;
+       }
+       
+       static long return_5high () {
+               return 0x500000000;
+       }
+
+       public static int test_3_long_ret () {
+               long val = return_5low ();
+               return (int) (val - 2);
+       }
+
+       public static int test_1_long_ret2 () {
+               long val = return_5high ();
+               if (val > 0xffffffff)
+                       return 1;
+               return 0;
+       }
+
+       static void doit (double value, out long m) {
+               m = (long) value;
+       }
+
+       public static int test_0_ftol_clobber () {
+               long m;
+               doit (1.3, out m);
+               if (m != 1)
+                       return 2;
+               return 0;
+       }
+
 }