- Allow an arbitrary (for arbitrary < 32) number of in_rBAR and !in_rBAR constraints...
[libfirm] / ir / be / arm / arm_spec.pl
index 919b4a2..5441e8a 100644 (file)
@@ -150,18 +150,18 @@ $mode_fpa     = "mode_E";
 ); # %reg_classes
 
 %emit_templates = (
-       M  => "${arch}_emit_mode(env, node);",
-       X  => "${arch}_emit_shift(env, node);",
-       S0 => "${arch}_emit_source_register(env, node, 0);",
-       S1 => "${arch}_emit_source_register(env, node, 1);",
-       S2 => "${arch}_emit_source_register(env, node, 2);",
-       S3 => "${arch}_emit_source_register(env, node, 3);",
-       S4 => "${arch}_emit_source_register(env, node, 4);",
-       D0 => "${arch}_emit_dest_register(env, node, 0);",
-       D1 => "${arch}_emit_dest_register(env, node, 1);",
-       D2 => "${arch}_emit_dest_register(env, node, 2);",
-       C  => "${arch}_emit_immediate(env, node);",
-       O  => "${arch}_emit_offset(env, mode);",
+       M  => "${arch}_emit_mode(node);",
+       X  => "${arch}_emit_shift(node);",
+       S0 => "${arch}_emit_source_register(node, 0);",
+       S1 => "${arch}_emit_source_register(node, 1);",
+       S2 => "${arch}_emit_source_register(node, 2);",
+       S3 => "${arch}_emit_source_register(node, 3);",
+       S4 => "${arch}_emit_source_register(node, 4);",
+       D0 => "${arch}_emit_dest_register(node, 0);",
+       D1 => "${arch}_emit_dest_register(node, 1);",
+       D2 => "${arch}_emit_dest_register(node, 2);",
+       C  => "${arch}_emit_immediate(node);",
+       O  => "${arch}_emit_offset(mode);",
 );
 
 #--------------------------------------------------#
@@ -176,12 +176,13 @@ $mode_fpa     = "mode_E";
 #--------------------------------------------------#
 
 $default_attr_type = "arm_attr_t";
+$default_copy_attr = "arm_copy_attr";
 
 %init_attr = (
-       arm_attr_t           => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
-       arm_SymConst_attr_t  => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
-       arm_CondJmp_attr_t   => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
-       arm_SwitchJmp_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);",
+       arm_attr_t           => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
+       arm_SymConst_attr_t  => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
+       arm_CondJmp_attr_t   => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
+       arm_SwitchJmp_attr_t => "\tinit_arm_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);",
 );
 
 %compare_attr = (
@@ -564,10 +565,10 @@ SymConst => {
        attr_type   => "arm_SymConst_attr_t",
 },
 
-CondJmp => {
+CmpBra => {
        op_flags  => "L|X|Y",
        state     => "pinned",
-       comment   => "construct conditional jump: CMP A, B && JMPxx LABEL",
+       comment   => "construct conditional branch: CMP A, B && JMPxx LABEL",
        mode      => "mode_T",
        attr      => "int proj_num",
        init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
@@ -703,7 +704,7 @@ LoadStackM3 => {
 
 # commutative operations
 
-fpaAdd => {
+fpaAdf => {
        op_flags  => "C",
        irn_flags => "R",
        comment   => "construct FPA Add: Add(a, b) = Add(b, a) = a + b",
@@ -711,15 +712,39 @@ fpaAdd => {
        emit      => '. adf%M %D0, %S0, %S1',
 },
 
-fpaMul => {
+fpaAdf_i => {
        op_flags  => "C",
+       irn_flags => "R",
+       comment   => "construct FPA Add: Add(a, b) = Add(b, a) = a + b",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
+       emit      => '. adf%M %D0, %S0, %C',
+},
+
+fpaMuf => {
+       op_flags  => "C",
+       irn_flags => "R",
        comment   => "construct FPA Mul: Mul(a, b) = Mul(b, a) = a * b",
        reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
        emit      =>'. muf%M %D0, %S0, %S1',
 },
 
-fpaFMul => {
+fpaMuf_i => {
        op_flags  => "C",
+       irn_flags => "R",
+       comment   => "construct FPA Mul: Mul(a, b) = Mul(b, a) = a * b",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
+       emit      => '. muf%M %D0, %S0, %C',
+},
+
+fpaFml => {
+       op_flags  => "C",
+       irn_flags => "R",
        comment   => "construct FPA Fast Mul: Mul(a, b) = Mul(b, a) = a * b",
        reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
        emit      =>'. fml%M %D0, %S0, %S1',
@@ -743,21 +768,41 @@ fpaMin => {
 
 # not commutative operations
 
-fpaSub => {
+fpaSuf => {
        irn_flags => "R",
        comment   => "construct FPA Sub: Sub(a, b) = a - b",
        reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
        emit      => '. suf%M %D0, %S0, %S1'
 },
 
-fpaRsb => {
+fpaSuf_i => {
+       irn_flags => "R",
+       comment   => "construct FPA Sub: Sub(a, b) = a - b",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
+       emit      => '. suf%M %D0, %S0, %C'
+},
+
+fpaRsf => {
        irn_flags => "R",
        comment   => "construct FPA reverse Sub: Sub(a, b) = b - a",
        reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "fpa" ] },
        emit      => '. rsf%M %D0, %S0, %S1'
 },
 
-fpaDiv => {
+fpaRsf_i => {
+       irn_flags => "R",
+       comment   => "construct FPA reverse Sub: Sub(a, b) = b - a",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
+       emit      => '. rsf%M %D0, %S0, %C'
+},
+
+fpaDvf => {
        comment   => "construct FPA Div: Div(a, b) = a / b",
        attr      => "ir_mode *op_mode",
        init_attr => "attr->op_mode = op_mode;",
@@ -766,7 +811,17 @@ fpaDiv => {
        outs      => [ "res", "M" ],
 },
 
-fpaRdv => {
+fpaDvf_i => {
+       comment   => "construct FPA Div: Div(a, b) = a / b",
+       attr      => "ir_mode *op_mode, tarval *tv",
+       init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
+       emit      =>'. dvf%M %D0, %S0, %C',
+       outs      => [ "res", "M" ],
+},
+
+fpaRdf => {
        comment   => "construct FPA reverse Div: Div(a, b) = b / a",
        attr      => "ir_mode *op_mode",
        init_attr => "attr->op_mode = op_mode;",
@@ -775,7 +830,17 @@ fpaRdv => {
        outs      => [ "res", "M" ],
 },
 
-fpaFDiv => {
+fpaRdf_i => {
+       comment   => "construct FPA reverse Div: Div(a, b) = b / a",
+       attr      => "ir_mode *op_mode, tarval *tv",
+       init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
+       emit      =>'. rdf%M %D0, %S0, %S1',
+       outs      => [ "res", "M" ],
+},
+
+fpaFdv => {
        comment   => "construct FPA Fast Div: Div(a, b) = a / b",
        attr      => "ir_mode *op_mode",
        init_attr => "attr->op_mode = op_mode;",
@@ -784,7 +849,17 @@ fpaFDiv => {
        outs      => [ "res", "M" ],
 },
 
-fpaFRdv => {
+fpaFdv_i => {
+       comment   => "construct FPA Fast Div: Div(a, b) = a / b",
+       attr      => "ir_mode *op_mode, tarval *tv",
+       init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
+       emit      =>'. fdv%M %D0, %S0, %C',
+       outs      => [ "res", "M" ],
+},
+
+fpaFrd => {
        comment   => "construct FPA Fast reverse Div: Div(a, b) = b / a",
        attr      => "ir_mode *op_mode",
        init_attr => "attr->op_mode = op_mode;",
@@ -793,20 +868,52 @@ fpaFRdv => {
        outs      => [ "res", "M" ],
 },
 
-fpaMov => {
+fpaFrd_i => {
+       comment   => "construct FPA Fast reverse Div: Div(a, b) = b / a",
+       attr      => "ir_mode *op_mode, tarval *tv",
+       init_attr => 'attr->op_mode = op_mode; ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       cmp_attr  => 'return attr_a->value != attr_b->value;',
+       reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa", "none" ] },
+       emit      =>'. frd%M %D0, %S0, %C',
+       outs      => [ "res", "M" ],
+},
+
+fpaMvf => {
        irn_flags => "R",
        comment   => "construct FPA Move: b = a",
        reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
        emit      => '. mvf%M %S0, %D0',
 },
 
-fpaMnv => {
+fpaMvf_i => {
+       irn_flags => "R",
+       comment   => "represents a float constant",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       reg_req   => { "out" => [ "fpa" ] },
+       mode      => "get_tarval_mode(tv)",
+       emit      => '. mvf %D0, %C',
+       cmp_attr  => 'return attr_a->value != attr_b->value;'
+},
+
+fpaMnf => {
        irn_flags => "R",
        comment   => "construct FPA Move Negated: b = -a",
        reg_req   => { "in" => [ "fpa" ], "out" => [ "fpa" ] },
        emit      => '. mnf%M %S0, %D0',
 },
 
+fpaMnf_i => {
+       irn_flags => "R",
+       comment   => "represents a float constant",
+       attr      => "tarval *tv",
+       init_attr => 'ARM_SET_FPA_IMM(attr); attr->value = tv;',
+       reg_req   => { "out" => [ "fpa" ] },
+       mode      => "get_tarval_mode(tv)",
+       emit      => '. mnf %D0, %C',
+       cmp_attr  => 'return attr_a->value != attr_b->value;'
+},
+
 fpaAbs => {
        irn_flags => "R",
        comment   => "construct FPA Absolute value: fAbsd(a) = |a|",
@@ -830,6 +937,50 @@ fpaFix => {
        emit      => '. fix %D0, %S0',
 },
 
+fpaCmfBra => {
+       op_flags  => "L|X|Y",
+       state     => "pinned",
+       comment   => "construct floating point Compare and Branch: CMF A, B && JMPxx LABEL",
+       mode      => "mode_T",
+       attr      => "int proj_num",
+       init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
+       reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
+       attr_type => "arm_CondJmp_attr_t",
+},
+
+fpaCnfBra => {
+       op_flags  => "L|X|Y",
+       state     => "pinned",
+       comment   => "construct floating point Compare negative and Branch: CMF A, -B && JMPxx LABEL",
+       mode      => "mode_T",
+       attr      => "int proj_num",
+       init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
+       reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
+       attr_type => "arm_CondJmp_attr_t",
+},
+
+fpaCmfeBra => {
+       op_flags  => "L|X|Y",
+       state     => "pinned",
+       comment   => "construct floating point Compare and Branch: CMF A, -B && JMPxx LABEL",
+       mode      => "mode_T",
+       attr      => "int proj_num",
+       init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
+       reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
+       attr_type => "arm_CondJmp_attr_t",
+},
+
+fpaCnfeBra => {
+       op_flags  => "L|X|Y",
+       state     => "pinned",
+       comment   => "construct floating point Compare and Branch: CMF A, -B && JMPxx LABEL",
+       mode      => "mode_T",
+       attr      => "int proj_num",
+       init_attr => "\tset_arm_CondJmp_proj_num(res, proj_num);",
+       reg_req   => { "in" => [ "fpa", "fpa" ], "out" => [ "none", "none"] },
+       attr_type => "arm_CondJmp_attr_t",
+},
+
 # Load / Store
 
 fpaLdf => {
@@ -840,7 +991,7 @@ fpaLdf => {
        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, #0]',
+       emit      => '. ldf%M %D0, [%S0]',
        outs      => [ "res", "M" ],
 },
 
@@ -852,7 +1003,7 @@ fpaStf => {
        attr      => "ir_mode *op_mode",
        init_attr => "attr->op_mode = op_mode;",
        reg_req   => { "in" => [ "gp", "fpa", "none" ], "out" => [ "none" ] },
-       emit      => '. stf%M [%S1, #0], %S0',
+       emit      => '. stf%M %S1, [%S0]',
        mode      => "mode_M",
 },