Adapted to API
[libfirm] / ir / be / ia32 / ia32_spec.pl
index 664099d..790f757 100644 (file)
@@ -70,25 +70,35 @@ $arch = "ia32";
 #
 # NOTE: rd_constructor and args are only optional if and only if arity is 0,1,2 or 3
 
+# register types:
+#   0 - no special type
+#   1 - write invariant (writes to this register doesn't change it's content)
+#   2 - caller save (register must be saved by the caller of a function)
+#   3 - callee save (register must be saved by the called function)
+#   4 - ignore (do not assign this register)
+# NOTE: Make sure to list the registers returning the call-result before all other
+#       caller save registers and in the correct order, otherwise it will break
+#       the magic!
 %reg_classes = (
   "general_purpose" => [
-                         { "name" => "eax", "type" => 0 },
-                         { "name" => "ebx", "type" => 0 },
-                         { "name" => "ecx", "type" => 0 },
-                         { "name" => "edx", "type" => 0 },
-                         { "name" => "edi", "type" => 0 },
-                         { "name" => "esi", "type" => 0 },
-                         { "name" => "ebp", "type" => 0 }
+                         { "name" => "eax", "type" => 2 },
+                         { "name" => "edx", "type" => 2 },
+                         { "name" => "ebx", "type" => 3 },
+                         { "name" => "ecx", "type" => 2 },
+                         { "name" => "esi", "type" => 3 },
+                         { "name" => "edi", "type" => 3 },
+                         { "name" => "ebp", "type" => 3 },
+                         { "name" => "esp", "type" => 4 }  # we don't want esp to be assigned
                        ],
   "floating_point"  => [
-                         { "name" => "xmm0", "type" => 0 },
-                         { "name" => "xmm1", "type" => 0 },
-                         { "name" => "xmm2", "type" => 0 },
-                         { "name" => "xmm3", "type" => 0 },
-                         { "name" => "xmm4", "type" => 0 },
-                         { "name" => "xmm5", "type" => 0 },
-                         { "name" => "xmm6", "type" => 0 },
-                         { "name" => "xmm7", "type" => 0 },
+                         { "name" => "xmm0", "type" => 2 },
+                         { "name" => "xmm1", "type" => 2 },
+                         { "name" => "xmm2", "type" => 2 },
+                         { "name" => "xmm3", "type" => 2 },
+                         { "name" => "xmm4", "type" => 2 },
+                         { "name" => "xmm5", "type" => 2 },
+                         { "name" => "xmm6", "type" => 2 },
+                         { "name" => "xmm7", "type" => 2 },
                        ]
 ); # %reg_classes
 
@@ -516,18 +526,9 @@ $arch = "ia32";
   "emit"     => '. leal %C(%S1), %D1\t\t\t/* %D1 = %S1 + %C, (%A1)*/'
 },
 
-"RegParam" => {
-  "arity"    => 1,
-  "comment"  => "constructs a Register Parameter to cover parameters passed in register",
-  "reg_req"  => { "in" => [ "none" ], "out" => [ "none" ] },
-  "cmp_attr" =>
-'
-  return (attr_a->pn_code != attr_b->pn_code);
-'
-},
-
 "StackParam" => {
   "arity"    => 1,
+  "remat"    => 1,
   "comment"  => "constructs a Stack Parameter to retrieve a parameter from Stack",
   "reg_req"  => { "in" => [ "none" ], "out" => [ "general_purpose" ] },
   "cmp_attr" =>
@@ -695,6 +696,7 @@ $arch = "ia32";
 
 "fStackParam" => {
   "arity"    => 1,
+  "remat"    => 1,
   "comment"  => "constructs a Stack Parameter to retrieve a SSE parameter from Stack",
   "reg_req"  => { "in" => [ "none" ], "out" => [ "floating_point" ] },
   "cmp_attr" =>
@@ -719,7 +721,6 @@ $arch = "ia32";
   "op_flags" => "L|F",
   "state"    => "mem_pinned",
   "arity"    => "variable",
-  "spill"    => 0,
   "comment"  => "construct Call: Call(...)",
   "args"     => [
                   { "type" => "int",        "name" => "n" },
@@ -729,6 +730,41 @@ $arch = "ia32";
 "  if (!op_ia32_Call) assert(0);
   return new_ir_node(db, irg, block, op_ia32_Call, mode_T, n, in);
 "
+},
+
+# Return
+
+"Return" => {
+  "op_flags" => "L|X",
+  "state"    => "pinned",
+  "arity"    => "variable",
+  "comment"  => "construct Return: Return(...)",
+  "args"     => [
+                  { "type" => "int",        "name" => "n" },
+                  { "type" => "ir_node **", "name" => "in" }
+                ],
+  "rd_constructor" =>
+"  if (!op_ia32_Return) assert(0);
+  return new_ir_node(db, irg, block, op_ia32_Return, mode_X, n, in);
+"
+},
+
+# M/Alloc
+
+"Alloca" => {
+  "op_flags" => "L|F",
+  "state"    => "pinned",
+  "arity"    => "2",
+  "comment"  => "construct Alloca: allocate memory on Stack",
+  "reg_req"  => { "in" => [ "general_purpose" ], "out" => [ "general_purpose" ] }
+},
+
+"Alloca_i" => {
+  "op_flags" => "L|F",
+  "state"    => "pinned",
+  "arity"    => "1",
+  "comment"  => "construct Alloca: allocate memory on Stack",
+  "reg_req"  => { "out" => [ "general_purpose" ] }
 }
 
 ); # end of %nodes