2004-07-26 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mono / mini / iltests.il
index 6747bce98965d6ef9d0387197e05744b7e791b38..0c68cfc57b9674761c7e71db0dd2ca951c7cf25b 100644 (file)
@@ -1,31 +1,31 @@
-.assembly iltests {}\r
-.assembly extern TestDriver {}\r
-.assembly extern mscorlib {}\r
-\r
-.class public auto ansi sealed beforefieldinit Tests {\r
-\r
-       .method static public int32 Main() il managed {\r
-               .entrypoint\r
-               \r
-               ldtoken Tests\r
-               call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)\r
-               call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)\r
-               ret\r
-       }\r
-\r
-       // make sure the register allocator works when the return value of\r
-       // 'div' is discarded\r
-       .method static public int32 test_0_div_regalloc () il managed {\r
-               .locals init (\r
-                       int32 i\r
-               )\r
-\r
-               ldloc 0\r
-               ldc.i4.s 0xa\r
-               div\r
-               pop\r
-               ldc.i4.0\r
-               ret\r
+.assembly iltests {}
+.assembly extern TestDriver {}
+.assembly extern mscorlib {}
+
+.class public auto ansi sealed beforefieldinit Tests {
+
+       .method static public int32 Main() il managed {
+               .entrypoint
+               
+               ldtoken Tests
+               call       class [mscorlib]System.Type [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)
+               call       int32 [TestDriver]TestDriver::RunTests(class [mscorlib]System.Type)
+               ret
+       }
+
+       // make sure the register allocator works when the return value of
+       // 'div' is discarded
+       .method static public int32 test_0_div_regalloc () il managed {
+               .locals init (
+                       int32 i
+               )
+
+               ldloc 0
+               ldc.i4.s 0xa
+               div
+               pop
+               ldc.i4.0
+               ret
        }
        
        
                ret
        }
        
+       .method static public int32 test_3_shl_regvars () il managed {
+               .locals init (
+                       int32   a,
+                       int32   b,
+                       int32   r1,
+                       int32   r2,
+                       int32   r3
+               )
+                       
+               ldc.i4.2
+               stloc      a
+               ldc.i4.1
+               stloc      b
+       
+               ldloc      a
+               ldloc      b
+               shl 
+               stloc      r1
+               
+               ldloc      a
+               ldloc      b
+               shl 
+               stloc      r2
+               
+               ldloc      a
+               ldloc      b
+               shl 
+               stloc      r3
+               
+               ldloc      r1
+               ldc.i4.4
+               ceq
+               
+               ldloc      r2
+               ldc.i4.4
+               ceq
+               
+               ldloc      r3
+               ldc.i4.4
+               ceq
+               
+               add
+               add
+               
+               ret
+       }
+       
        .method static public int32 test_1_fceq_to_i4 () il managed {
        
                .locals init (
                
                ret
        }
-       \r
-       .method static public int32 test_3_copy_used_bug () il managed {\r
-\r
-               .locals init (\r
-                       int32 size,\r
-                       int32 res\r
-               )\r
-\r
-               ldc.i4 0\r
-               stloc res\r
-\r
-               ldc.i4 1\r
-               stloc size\r
-\r
-               ldloc size\r
-               ldloc size\r
-               ldloc size\r
-               add\r
-               stloc size\r
-               ldloc size\r
-               add\r
-               stloc res\r
-\r
-               ldloc res\r
-               ret\r
-       }\r
-\r
-       // demonstrate that the copy_used_var is not a fix for the above bug\r
-       .method static public int32 test_3_copy_used_indir_bug () il managed {\r
-\r
-               .locals init (\r
-                       int32 size,\r
-                       int32 res\r
-               )\r
-\r
-               ldc.i4 0\r
-               stloc res\r
-\r
-               ldc.i4 1\r
-               stloc size\r
-\r
-               ldloc size\r
-               ldloca size\r
-               ldloc size\r
-               ldloc size\r
-               add\r
-               stind.i4\r
-               ldloc size\r
-               add\r
-               stloc res\r
-\r
-               ldloc res\r
-               ret\r
-       }\r
-\r
-       .method static public void do_nothing (int32 a) il managed {\r
-               ret\r
-       }\r
-       \r
-       // demonstrate the block_split failure: needs -O=inline\r
-       // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe\r
-       .method static public int32 test_0_split_block_bug () il managed {\r
-\r
-               .locals init (\r
-                       int32 i1\r
-               )\r
-\r
-               ldc.i4 1\r
-               stloc i1\r
- test_label:\r
-               ldloc i1\r
-               call void class Tests::do_nothing (int32)\r
-               ldc.i4 0\r
-               brtrue test_label\r
-               \r
-               ldc.i4 0\r
-               ret\r
-       }\r
-\r
-       .method public void inline_do_nothing () il managed {\r
-               ret\r
-       }\r
-       .method static public int32 test_1_checkthis_inlining () il managed {\r
-               ldnull\r
-               call instance void class Tests::inline_do_nothing ()\r
-               ldc.i4 1\r
-               ret\r
-       }\r
-\r
-       .class nested private auto ansi sealed beforefieldinit TailCallStruct \r
-               extends [mscorlib]System.ValueType {\r
-               .field public int32 a\r
-               .field public int32 b\r
-       }\r
-\r
-       .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {\r
-               ldarga 0\r
-               ldarga 0\r
-               ldfld int32 Tests/TailCallStruct::a\r
-               ldc.i4.1\r
-               add\r
-               stfld int32 Tests/TailCallStruct::a\r
-               ldarga 0\r
-               ldarga 0\r
-               ldfld int32 Tests/TailCallStruct::a\r
-               ldc.i4.2\r
-               add\r
-               stfld int32 Tests/TailCallStruct::a\r
-               ldarg.0\r
-               ret\r
-       }\r
-\r
-       .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {\r
-               ldarg.0\r
-               tail.\r
-               call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)\r
-               ret\r
-       }\r
-\r
-       .method static public int32 test_0_tail_calls () il managed {\r
-               .maxstack 16\r
-               .locals init (\r
-                       valuetype Tests/TailCallStruct arg\r
-               )\r
-               ldloca 0\r
-               ldc.i4.2\r
-               stfld int32 Tests/TailCallStruct::a\r
-               ldloca 0\r
-               ldc.i4.4\r
-               stfld int32 Tests/TailCallStruct::b\r
-               ldloc.0\r
-               call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)\r
-               stloc.0\r
-               ldloca 0\r
-               ldfld int32 Tests/TailCallStruct::a\r
-               ldloca 0\r
-               ldfld int32 Tests/TailCallStruct::b\r
-               add\r
-               ldc.i4 9\r
-               sub\r
-               ret\r
-       }\r
-\r
-       .method static public int32 test_11_switch_with_nonempty_stack () il managed {\r
-               .maxstack 16\r
-\r
-               ldc.i4.5\r
-               ldc.i4.6\r
-               ldc.i4.1\r
-               switch (L0, L1)\r
-       L0: \r
-               add\r
-               ret\r
-       L1:\r
-               add\r
-               ret\r
-       }\r
\r
-    .method public static int32 test_5_endfinally_with_nonempty_stack () il managed {\r
-               .maxstack 16\r
-\r
-        .try {\r
-          leave IL_0\r
-        }\r
-        finally  {\r
-          ldc.i4.0\r
-          endfinally\r
-        }\r
-        IL_0:  ldc.i4.5\r
-               ret\r
-    }\r
-\r
-       .method public static int32 test_0_conv_ovf_i8_neg () il managed {\r
-               .maxstack 16\r
-\r
-               ldc.i4.m1\r
-               conv.ovf.i8\r
-               conv.i4\r
-               ldc.i4.m1\r
-               beq L_OK\r
-               ldc.i4.1\r
-               ret\r
-       L_OK:\r
-               ldc.i4.0\r
-               ret\r
-       }               \r
-               \r
-}\r
+       
+       .method static public int32 test_3_copy_used_bug () il managed {
+
+               .locals init (
+                       int32 size,
+                       int32 res
+               )
+
+               ldc.i4 0
+               stloc res
+
+               ldc.i4 1
+               stloc size
+
+               ldloc size
+               ldloc size
+               ldloc size
+               add
+               stloc size
+               ldloc size
+               add
+               stloc res
+
+               ldloc res
+               ret
+       }
+
+       // demonstrate that the copy_used_var is not a fix for the above bug
+       .method static public int32 test_3_copy_used_indir_bug () il managed {
+
+               .locals init (
+                       int32 size,
+                       int32 res
+               )
+
+               ldc.i4 0
+               stloc res
+
+               ldc.i4 1
+               stloc size
+
+               ldloc size
+               ldloca size
+               ldloc size
+               ldloc size
+               add
+               stind.i4
+               ldloc size
+               add
+               stloc res
+
+               ldloc res
+               ret
+       }
+
+       .method static public void do_nothing (int32 a) il managed {
+               ret
+       }
+       
+       // demonstrate the block_split failure: needs -O=inline
+       // mini -O=inline --compile Tests:test_0_split_block_bug iltests.exe
+       .method static public int32 test_0_split_block_bug () il managed {
+
+               .locals init (
+                       int32 i1
+               )
+
+               ldc.i4 1
+               stloc i1
+ test_label:
+               ldloc i1
+               call void class Tests::do_nothing (int32)
+               ldc.i4 0
+               brtrue test_label
+               
+               ldc.i4 0
+               ret
+       }
+
+       .method public void inline_do_nothing () il managed {
+               ret
+       }
+       .method static public int32 test_1_checkthis_inlining () il managed {
+               ldnull
+               call instance void class Tests::inline_do_nothing ()
+               ldc.i4 1
+               ret
+       }
+
+       .class nested private auto ansi sealed beforefieldinit TailCallStruct 
+               extends [mscorlib]System.ValueType {
+               .field public int32 a
+               .field public int32 b
+       }
+
+       .method static valuetype Tests/TailCallStruct tail1 (valuetype Tests/TailCallStruct arg) {
+               ldarga 0
+               ldarga 0
+               ldfld int32 Tests/TailCallStruct::a
+               ldc.i4.1
+               add
+               stfld int32 Tests/TailCallStruct::a
+               ldarga 0
+               ldarga 0
+               ldfld int32 Tests/TailCallStruct::a
+               ldc.i4.2
+               add
+               stfld int32 Tests/TailCallStruct::a
+               ldarg.0
+               ret
+       }
+
+       .method static valuetype Tests/TailCallStruct tail2 (valuetype Tests/TailCallStruct arg) {
+               ldarg.0
+               tail.
+               call valuetype Tests/TailCallStruct Tests::tail1 (valuetype Tests/TailCallStruct)
+               ret
+       }
+
+       .method static public int32 test_0_tail_calls () il managed {
+               .maxstack 16
+               .locals init (
+                       valuetype Tests/TailCallStruct arg
+               )
+               ldloca 0
+               ldc.i4.2
+               stfld int32 Tests/TailCallStruct::a
+               ldloca 0
+               ldc.i4.4
+               stfld int32 Tests/TailCallStruct::b
+               ldloc.0
+               call valuetype Tests/TailCallStruct Tests::tail2 (valuetype Tests/TailCallStruct)
+               stloc.0
+               ldloca 0
+               ldfld int32 Tests/TailCallStruct::a
+               ldloca 0
+               ldfld int32 Tests/TailCallStruct::b
+               add
+               ldc.i4 9
+               sub
+               ret
+       }
+
+       .method static public int32 test_11_switch_with_nonempty_stack () il managed {
+               .maxstack 16
+
+               ldc.i4.5
+               ldc.i4.6
+               ldc.i4.1
+               switch (L0, L1)
+       L0: 
+               add
+               ret
+       L1:
+               add
+               ret
+       }
+    .method public static int32 test_5_endfinally_with_nonempty_stack () il managed {
+               .maxstack 16
+
+        .try {
+          leave IL_0
+        }
+        finally  {
+          ldc.i4.0
+          endfinally
+        }
+        IL_0:  ldc.i4.5
+               ret
+    }
+
+       .method public static int32 test_0_conv_ovf_i8_neg () il managed {
+               .maxstack 16
+
+               ldc.i4.m1
+               conv.ovf.i8
+               conv.i4
+               ldc.i4.m1
+               beq L_OK
+               ldc.i4.1
+               ret
+       L_OK:
+               ldc.i4.0
+               ret
+       }               
+
+       .method public static int32 test_0_get_type_from_handle_on_bblock_boundary () cil managed 
+       {
+               .entrypoint
+               .maxstack 16
+       
+               ldc.i4.1
+               brfalse OBJECT
+       
+               ldtoken [mscorlib]System.String
+               br AFTER
+       OBJECT:
+               ldtoken [mscorlib]System.Object
+       AFTER:
+               call class [mscorlib]'System.Type' class [mscorlib]'System.Type'::'GetTypeFromHandle'(valuetype [mscorlib]'System.RuntimeTypeHandle')
+               callvirt string class [mscorlib]System.Type::get_FullName ()
+               ldstr "System.String"
+               callvirt bool class [mscorlib]System.Object::Equals(object)
+               ldc.i4.0
+               ceq
+               ret 
+       }
+               
+       .method public static int32 test_0_bug59580  ()
+       {
+               ldc.r4          float32(0x7FC00000)
+               ldc.r4          float32(0x7FC00000)
+               bge.un          pass
+               br              fail
+       pass:
+               ldc.i4.0
+               ret
+       fail:
+               ldc.i4.1
+               ret
+       }
+       
+       .method public static int32 test_1_bug60056  () {
+               .locals init (int32 m5)
+                       
+               ldc.i4.m1
+               stloc.0
+               
+               ldc.i4.1
+               conv.u8
+               
+               ldloc.0
+               conv.i8
+               mul
+               
+               ldc.i4.m1
+               conv.i8
+               ceq
+               ret
+       }
+}