Refactoring
[libfirm] / ir / be / ia32 / ia32_spec.pl
index a49559d..5bacac4 100644 (file)
@@ -15,7 +15,7 @@ $arch = "ia32";
 # %nodes = (
 #
 # <op-name> => {
-#   op_flags  => "N|L|C|X|I|F|Y|H|c|K",
+#   op_flags  => "N|L|C|X|I|F|Y|H|c|K|n",
 #   irn_flags => "R|N"
 #   arity     => "0|1|2|3 ... |variable|dynamic|any",
 #   state     => "floats|pinned|mem_pinned|exc_pinned",
@@ -220,7 +220,6 @@ $arch = "ia32";
        unop4 => "${arch}_emit_unop(node, n_ia32_binary_right);",
        binop => "${arch}_emit_binop(node);",
        x87_binop => "${arch}_emit_x87_binop(node);",
-       CMP0  => "${arch}_emit_cmp_suffix_node(node, 0);",
        CMP3  => "${arch}_emit_cmp_suffix_node(node, 3);",
 );
 
@@ -339,7 +338,7 @@ Asm => {
 
 # "allocates" a free register
 ProduceVal => {
-       op_flags  => "c",
+       op_flags  => "c|n",
        irn_flags => "R",
        reg_req   => { out => [ "gp" ] },
        emit      => "",
@@ -661,7 +660,8 @@ Sbb => {
 },
 
 Sbb0 => {
-       irn_flags => "R",
+       # Spiller currently fails when rematerializing flag consumers
+       # irn_flags => "R",
        reg_req   => { in => [ "flags" ], out => [ "gp", "flags" ] },
        outs      => [ "res", "flags" ],
        emit      => ". sbb%M %D0, %D0",
@@ -1097,7 +1097,13 @@ Setcc => {
        outs      => [ "res" ],
        attr_type => "ia32_condcode_attr_t",
        attr      => "pn_Cmp pnc",
-       init_attr => "set_ia32_ls_mode(res, mode_Bu);\n",
+       # The way we handle Setcc with float nodes (potentially) destroys the flags
+       # (when we emit the setX; setp; orb and the setX;setnp;andb sequences)
+       init_attr => "set_ia32_ls_mode(res, mode_Bu);\n"
+               . "\tif ((pnc & ia32_pn_Cmp_float) && ((pnc & 0xf) != pn_Cmp_Uo) && ((pnc & 0xf) != pn_Cmp_Leg)) {\n"
+               . "\t\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);\n"
+               . "\t\t/* attr->latency = 3; */\n"
+               . "\t}\n",
        latency   => 1,
        units     => [ "GP" ],
        mode      => $mode_gp,
@@ -1119,17 +1125,16 @@ SetccMem => {
 
 CMovcc => {
        #irn_flags => "R",
+       state     => "exc_pinned",
        # (note: leave the false,true order intact to make it compatible with other
        #  ia32_binary ops)
-       state     => "exc_pinned",
        reg_req   => { in => [ "gp", "gp", "none", "gp", "gp", "eflags" ],
                       out => [ "in_r4 in_r5", "flags", "none" ] },
        ins       => [ "base", "index", "mem", "val_false", "val_true", "eflags" ],
        outs      => [ "res", "flags", "M" ],
        am        => "source,binary",
        attr_type => "ia32_condcode_attr_t",
-       attr      => "int ins_permuted, pn_Cmp pnc",
-       init_attr => "attr->attr.data.ins_permuted = ins_permuted;",
+       attr      => "pn_Cmp pnc",
        latency   => 1,
        units     => [ "GP" ],
        mode      => $mode_gp,