replace psets with arrays to make the compiler more predictable across runs (and...
[libfirm] / ir / be / arm / arm_spec.pl
index 1732dba..9c1c25f 100644 (file)
@@ -1,16 +1,16 @@
 # Creation: 2006/02/13
+# Arm Architecure Specification
+# Author: Matthias Braun, Michael Beck, Oliver Richter, Tobias Gneist
 # $Id$
 
-# the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
-
 $arch = "arm";
 
 #
 # Modes
 #
-$mode_gp      = "mode_Iu";
-$mode_flags   = "mode_Bu";
-$mode_fp    = "mode_E";
+$mode_gp    = "mode_Iu";
+$mode_flags = "mode_Bu";
+$mode_fp    = "mode_E";
 
 # register types:
 $normal      =  0; # no special type
@@ -41,7 +41,7 @@ $state       = 32; # register represents a state
                { name => "pc",  type => $ignore }, # this is our program counter
                { mode => $mode_gp }
        ],
-       fpa  => [
+       fpa => [
                { name => "f0", type => $caller_save },
                { name => "f1", type => $caller_save },
                { name => "f2", type => $caller_save },
@@ -50,7 +50,7 @@ $state       = 32; # register represents a state
                { name => "f5", type => $caller_save },
                { name => "f6", type => $caller_save },
                { name => "f7", type => $caller_save },
-               { mode => $mode_fpa }
+               { mode => $mode_fp }
        ],
        flags => [
                { name => "fl", type => 0 },
@@ -59,7 +59,8 @@ $state       = 32; # register represents a state
 );
 
 %emit_templates = (
-       M   => "${arch}_emit_mode(node);",
+       FM  => "${arch}_emit_float_load_store_mode(node);",
+       AM  => "${arch}_emit_float_arithmetic_mode(node);",
        LM  => "${arch}_emit_load_mode(node);",
        SM  => "${arch}_emit_store_mode(node);",
        SO  => "${arch}_emit_shifter_operand(node);",
@@ -85,7 +86,7 @@ $default_copy_attr = "arm_copy_attr";
                "\tinit_arm_SymConst_attributes(res, entity, symconst_offset);",
        arm_CondJmp_attr_t   => "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);",
        arm_SwitchJmp_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);",
-       arm_fpaConst_attr_t  => "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);",
+       arm_fConst_attr_t    => "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);",
        arm_load_store_attr_t =>
                "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);\n".
                "\tinit_arm_load_store_attributes(res, ls_mode, entity, entity_sign, offset, is_frame_entity);",
@@ -93,6 +94,9 @@ $default_copy_attr = "arm_copy_attr";
                "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);\n",
        arm_cmp_attr_t =>
                "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);\n",
+       arm_farith_attr_t =>
+               "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);\n".
+               "\tinit_arm_farith_attributes(res, op_mode);",
        arm_CopyB_attr_t =>
                "\tinit_arm_attributes(res, flags, in_reqs, exec_units, n_res);\n".
                "\tinit_arm_CopyB_attributes(res, size);",
@@ -103,11 +107,12 @@ $default_copy_attr = "arm_copy_attr";
        arm_SymConst_attr_t   => "cmp_attr_arm_SymConst",
        arm_CondJmp_attr_t    => "cmp_attr_arm_CondJmp",
        arm_SwitchJmp_attr_t  => "cmp_attr_arm_SwitchJmp",
-       arm_fpaConst_attr_t   => "cmp_attr_arm_fpaConst",
+       arm_fConst_attr_t     => "cmp_attr_arm_fConst",
        arm_load_store_attr_t => "cmp_attr_arm_load_store",
        arm_shifter_operand_t => "cmp_attr_arm_shifter_operand",
        arm_CopyB_attr_t      => "cmp_attr_arm_CopyB",
        arm_cmp_attr_t        => "cmp_attr_arm_cmp",
+       arm_farith_attr_t     => "cmp_attr_arm_farith",
 );
 
 my %unop_shifter_operand_constructors = (
@@ -197,7 +202,7 @@ my %cmp_shifter_operand_constructors = (
 %nodes = (
 
 Add => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. add %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -205,21 +210,21 @@ Add => {
 },
 
 Mul => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "!in_r1" ] },
        emit      =>'. mul %D0, %S0, %S1',
        mode      => $mode_gp,
 },
 
 Smull => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp", "gp" ] },
        emit      =>'. smull %D0, %D1, %S0, %S1',
        outs      => [ "low", "high" ],
 },
 
 Umull => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp", "gp" ] },
        emit      =>'. umull %D0, %D1, %S0, %S1',
        outs      => [ "low", "high" ],
@@ -227,14 +232,14 @@ Umull => {
 },
 
 Mla => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp", "gp" ], out => [ "!in_r1" ] },
        emit      =>'. mla %D0, %S0, %S1, %S2',
        mode      => $mode_gp,
 },
 
 And => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. and %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -242,7 +247,7 @@ And => {
 },
 
 Or => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. orr %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -250,7 +255,7 @@ Or => {
 },
 
 Eor => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. eor %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -258,7 +263,7 @@ Eor => {
 },
 
 Bic => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. bic %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -266,7 +271,7 @@ Bic => {
 },
 
 Sub => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. sub %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -274,7 +279,7 @@ Sub => {
 },
 
 Rsb => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        emit      => '. rsb %D0, %S0, %SO',
        mode      => $mode_gp,
        attr_type => "arm_shifter_operand_t",
@@ -282,7 +287,7 @@ Rsb => {
 },
 
 Mov => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        arity     => "variable",
        emit      => '. mov %D0, %SO',
        mode      => $mode_gp,
@@ -291,7 +296,7 @@ Mov => {
 },
 
 Mvn => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        attr_type => "arm_shifter_operand_t",
        arity     => "variable",
        emit      => '. mvn %D0, %SO',
@@ -299,13 +304,10 @@ Mvn => {
        constructors => \%unop_shifter_operand_constructors,
 },
 
-# Deprecated - we should construct the movs and rsbmi directly...
-Abs => {
-       irn_flags => "R",
+Clz => {
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      =>
-'. movs %S0, %S0, #0
-. rsbmi %D0, %S0, #0',
+       emit      =>'. clz %D0, %S0',
        mode      => $mode_gp,
 },
 
@@ -321,7 +323,6 @@ LinkMovPC => {
                        "\tarch_irn_add_flags(res, arch_irn_flags_modify_flags);",
        emit         => ". mov lr, pc\n".
                        ". mov pc, %SO",
-       mode         => "mode_T",
 },
 
 # mov lr, pc\n ldr pc, XXX -- This combination is used for calls to function
@@ -335,7 +336,6 @@ LinkLdrPC => {
        custominit   => "arch_irn_add_flags(res, arch_irn_flags_modify_flags);",
        emit         => ". mov lr, pc\n".
                        ". ldr pc, %SO",
-       mode         => "mode_T",
 },
 
 Bl => {
@@ -346,13 +346,12 @@ Bl => {
        attr       => "ir_entity *entity, int symconst_offset",
        custominit => "arch_irn_add_flags(res, arch_irn_flags_modify_flags);",
        emit       => '. bl %SC',
-       mode       => "mode_T",
 },
 
 # this node produces ALWAYS an empty (tempary) gp reg and cannot be CSE'd
 EmptyReg => {
-       op_flags  => "c",
-       irn_flags => "R",
+       op_flags  => [ "constlike" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { out => [ "gp" ] },
        emit      => '. /* %D0 now available for calculations */',
        cmp_attr  => 'return 1;',
@@ -360,7 +359,7 @@ EmptyReg => {
 },
 
 CopyB => {
-       op_flags  => "F|H",
+       op_flags  => [ "fragile" ],
        state     => "pinned",
        attr      => "unsigned size",
        attr_type => "arm_CopyB_attr_t",
@@ -369,8 +368,8 @@ CopyB => {
 },
 
 FrameAddr => {
-       op_flags  => "c",
-       irn_flags => "R",
+       op_flags  => [ "constlike" ],
+       irn_flags => [ "rematerializable" ],
        attr      => "ir_entity *entity, int symconst_offset",
        reg_req   => { in => [ "gp" ], out => [ "gp" ] },
        ins       => [ "base" ],
@@ -379,8 +378,8 @@ FrameAddr => {
 },
 
 SymConst => {
-       op_flags  => "c",
-       irn_flags => "R",
+       op_flags  => [ "constlike" ],
+       irn_flags => [ "rematerializable" ],
        attr      => "ir_entity *entity, int symconst_offset",
        reg_req   => { out => [ "gp" ] },
        attr_type => "arm_SymConst_attr_t",
@@ -388,7 +387,7 @@ SymConst => {
 },
 
 Cmp => {
-       irn_flags    => "R|F",
+       irn_flags    => [ "rematerializable", "modify_flags" ],
        emit         => '. cmp %S0, %SO',
        mode         => $mode_flags,
        attr_type    => "arm_cmp_attr_t",
@@ -396,7 +395,7 @@ Cmp => {
 },
 
 Tst => {
-       irn_flags    => "R|F",
+       irn_flags    => [ "rematerializable", "modify_flags" ],
        emit         => '. tst %S0, %SO',
        mode         => $mode_flags,
        attr_type    => "arm_cmp_attr_t",
@@ -404,7 +403,7 @@ Tst => {
 },
 
 B => {
-       op_flags  => "L|X|Y",
+       op_flags  => [ "labeled", "cfopcode", "forking" ],
        state     => "pinned",
        mode      => "mode_T",
        reg_req   => { in => [ "flags" ], out => [ "none", "none" ] },
@@ -415,14 +414,14 @@ B => {
 
 Jmp => {
        state     => "pinned",
-       op_flags  => "X",
-       irn_flags => "J",
+       op_flags  => [ "cfopcode" ],
+       irn_flags => [ "simple_jump" ],
        reg_req   => { out => [ "none" ] },
        mode      => "mode_X",
 },
 
 SwitchJmp => {
-       op_flags  => "L|X|Y",
+       op_flags  => [ "labeled", "cfopcode", "forking" ],
        state     => "pinned",
        mode      => "mode_T",
        attr      => "int n_projs, long def_proj_num",
@@ -433,7 +432,7 @@ SwitchJmp => {
 },
 
 Ldr => {
-       op_flags  => "L|F",
+       op_flags  => [ "labeled", "fragile" ],
        state     => "exc_pinned",
        ins       => [ "ptr", "mem" ],
        outs      => [ "res", "M" ],
@@ -444,10 +443,10 @@ Ldr => {
 },
 
 Str => {
-       op_flags  => "L|F",
+       op_flags  => [ "labeled", "fragile" ],
        state     => "exc_pinned",
        ins       => [ "ptr", "val", "mem" ],
-       outs      => [ "mem" ],
+       outs      => [ "M" ],
        reg_req   => { in => [ "gp", "gp", "none" ], out => [ "none" ] },
        emit      => '. str%SM %S1, [%S0, #%O]',
        mode      => "mode_M",
@@ -456,8 +455,8 @@ Str => {
 },
 
 StoreStackM4Inc => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "sp", "gp", "gp", "gp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
        emit      => '. stmfd %S0!, {%S1, %S2, %S3, %S4}',
@@ -465,8 +464,8 @@ StoreStackM4Inc => {
 },
 
 LoadStackM3Epilogue => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "sp", "none" ], out => [ "r11:I", "sp:I|S", "pc:I", "none" ] },
        emit      => '. ldmfd %S0, {%D0, %D1, %D2}',
@@ -475,122 +474,62 @@ LoadStackM3Epilogue => {
 
 
 
-fpaAdf => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      => '. adf%M %D0, %S0, %S1',
-},
-
-fpaMuf => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      =>'. muf%M %D0, %S0, %S1',
-},
-
-fpaFml => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      =>'. fml%M %D0, %S0, %S1',
-},
-
-fpaMax => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      =>'. fmax %S0, %S1, %D0',
-},
-
-fpaMin => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      =>'. fmin %S0, %S1, %D0',
-},
-
-fpaSuf => {
-       irn_flags => "R",
+Adf => {
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      => '. suf%M %D0, %S0, %S1'
+       emit      => '. adf%AM %D0, %S0, %S1',
+       attr_type => "arm_farith_attr_t",
+       attr      => "ir_mode *op_mode",
+       mode      => $mode_fp,
 },
 
-fpaRsf => {
-       irn_flags => "R",
+Muf => {
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
-       emit      => '. rsf%M %D0, %S0, %S1'
-},
-
-fpaDvf => {
+       emit      =>'. muf%AM %D0, %S0, %S1',
+       attr_type => "arm_farith_attr_t",
        attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa", "none" ] },
-       emit      =>'. dvf%M %D0, %S0, %S1',
-       outs      => [ "res", "M" ],
+       mode      => $mode_fp,
 },
 
-fpaRdf => {
+Suf => {
+       irn_flags => [ "rematerializable" ],
+       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa" ] },
+       emit      => '. suf%AM %D0, %S0, %S1',
+       attr_type => "arm_farith_attr_t",
        attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa", "none" ] },
-       emit      =>'. rdf%M %D0, %S0, %S1',
-       outs      => [ "res", "M" ],
+       mode      => $mode_fp,
 },
 
-fpaFdv => {
-       attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
+Dvf => {
        reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa", "none" ] },
-       emit      =>'. fdv%M %D0, %S0, %S1',
+       emit      =>'. dvf%AM %D0, %S0, %S1',
        outs      => [ "res", "M" ],
-},
-
-fpaFrd => {
+       attr_type => "arm_farith_attr_t",
        attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "fpa", "none" ] },
-       emit      =>'. frd%M %D0, %S0, %S1',
-       outs      => [ "res", "M" ],
-},
-
-fpaMvf => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa" ], out => [ "fpa" ] },
-       emit      => '. mvf%M %S0, %D0',
-},
-
-fpaMnf => {
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa" ], out => [ "fpa" ] },
-       emit      => '. mnf%M %S0, %D0',
+       mode      => $mode_fp,
 },
 
-fpaAbs => {
-       irn_flags => "R",
+Mvf => {
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fpa" ], out => [ "fpa" ] },
-       emit      => '. abs%M %D0, %S0',
-},
-
-fpaFlt => {
-       irn_flags => "R",
-       reg_req   => { in => ["gp"], out => [ "fpa" ] },
-       emit      => '. flt%M %D0, %S0',
-},
-
-fpaFix => {
-       irn_flags => "R",
-       reg_req   => { in => ["fpa"], out => [ "gp" ] },
-       emit      => '. fix %D0, %S0',
+       emit      => '. mvf%AM %S0, %D0',
+       attr_type => "arm_farith_attr_t",
+       attr      => "ir_mode *op_mode",
+       mode      => $mode_fp,
 },
 
-Cmf => {
-       irn_flags => "R|F",
-       mode      => $mode_flags,
-       attr_type => "arm_cmp_attr_t",
-       attr      => "bool ins_permuted",
-       init_attr => "init_arm_cmp_attr(res, ins_permuted, false);",
-       reg_req   => { in => [ "fpa", "fpa" ], out => [ "flags" ] },
-       emit      => '. cmf %S0, %S1',
+FltX => {
+       irn_flags => [ "rematerializable" ],
+       reg_req   => { in => [ "gp" ], out => [ "fpa" ] },
+       emit      => '. flt%AM %D0, %S0',
+       attr_type => "arm_farith_attr_t",
+       attr      => "ir_mode *op_mode",
+       mode      => $mode_fp,
 },
 
 Cmfe => {
-       irn_flags => "R|F",
+       irn_flags => [ "rematerializable", "modify_flags" ],
        mode      => $mode_flags,
        attr_type => "arm_cmp_attr_t",
        attr      => "bool ins_permuted",
@@ -599,67 +538,40 @@ Cmfe => {
        emit      => '. cmfe %S0, %S1',
 },
 
-fpaLdf => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+Ldf => {
+       op_flags  => [ "labeled", "fragile" ],
        state     => "exc_pinned",
-       attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
-       reg_req   => { in => [ "gp", "none" ], out => [ "fpa", "none" ] },
-       emit      => '. ldf%M %D0, [%S0]',
+       ins       => [ "ptr", "mem" ],
        outs      => [ "res", "M" ],
+       reg_req   => { in => [ "gp", "none" ], out => [ "fpa", "none" ] },
+       emit      => '. ldf%FM %D0, [%S0, #%O]',
+       attr_type => "arm_load_store_attr_t",
+       attr      => "ir_mode *ls_mode, ir_entity *entity, int entity_sign, long offset, bool is_frame_entity",
 },
 
-fpaStf => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+Stf => {
+       op_flags  => [ "labeled", "fragile" ],
        state     => "exc_pinned",
-       attr      => "ir_mode *op_mode",
-       init_attr => "attr->op_mode = op_mode;",
-       reg_req   => { in => [ "gp", "fpa", "none" ], out => [ "none" ] },
-       emit      => '. stf%M %S1, [%S0]',
+       ins       => [ "ptr", "val", "mem" ],
+       outs      => [ "M" ],
        mode      => "mode_M",
+       reg_req   => { in => [ "gp", "fpa", "none" ], out => [ "none" ] },
+       emit      => '. stf%FM %S1, [%S0, #%O]',
+       attr_type => "arm_load_store_attr_t",
+       attr      => "ir_mode *ls_mode, ir_entity *entity, int entity_sign, long offset, bool is_frame_entity",
 },
 
-fpaDbl2GP => {
-       op_flags  => "L|F",
-       irn_flags => "R",
-       reg_req   => { in => [ "fpa", "none" ], out => [ "gp", "gp", "none" ] },
-       outs      => [ "low", "high", "M" ],
-},
-
-AddSP => {
-       reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "none" ] },
-       emit      => '. add %D0, %S0, %S1',
-       outs      => [ "stack", "M" ],
-},
-
-SubSPandCopy => {
-       reg_req   => { in => [ "sp", "gp", "none" ], out => [ "sp:I|S", "gp", "none" ] },
-       ins       => [ "stack", "size", "mem" ],
-       emit      => ". sub %D0, %S0, %S1\n".
-                    ". mov sp, %D1",
-       outs      => [ "stack", "addr", "M" ],
-},
-
-LdTls => {
-       irn_flags => "R",
-       reg_req   => { out => [ "gp" ] },
-       mode      => $mode_gp,
-},
-
-
 #
 # floating point constants
 #
-fpaConst => {
-       op_flags  => "c",
-       irn_flags => "R",
+fConst => {
+       op_flags  => [ "constlike" ],
+       irn_flags => [ "rematerializable" ],
        attr      => "tarval *tv",
        init_attr => "attr->tv = tv;",
        mode      => "get_tarval_mode(tv)",
        reg_req   => { out => [ "fpa" ] },
-       attr_type => "arm_fpaConst_attr_t",
+       attr_type => "arm_fConst_attr_t",
 }
 
 ); # end of %nodes