Use debug printer instead direct output, fix some size_t related warnings.
[libfirm] / ir / be / TEMPLATE / TEMPLATE_spec.pl
index f5af444..27f3115 100644 (file)
@@ -1,19 +1,22 @@
 # Creation: 2006/02/13
 # $Id$
-# This is a template specification for the Firm-Backend
 
 # the cpu architecture (ia32, ia64, mips, sparc, ppc, ...)
 
 $arch = "TEMPLATE";
 
+#
+# Modes
+#
+$mode_gp  = "mode_Iu"; # mode used by general purpose registers
+$mode_fp  = "mode_E";  # mode used by floatingpoint registers
+
 # The node description is done as a perl hash initializer with the
 # following structure:
 #
 # %nodes = (
 #
 # <op-name> => {
-#   op_flags  => "N|L|C|X|I|F|Y|H|c|K",                 # optional
-#   irn_flags => "R|N|I"                                # optional
 #   arity     => "0|1|2|3 ... |variable|dynamic|any",   # optional
 #   state     => "floats|pinned|mem_pinned|exc_pinned", # optional
 #   args      => [
@@ -40,25 +43,6 @@ $arch = "TEMPLATE";
 #
 # ); # close the %nodes initializer
 
-# op_flags: flags for the operation, OPTIONAL (default is "N")
-# the op_flags correspond to the firm irop_flags:
-#   N   irop_flag_none
-#   L   irop_flag_labeled
-#   C   irop_flag_commutative
-#   X   irop_flag_cfopcode
-#   I   irop_flag_ip_cfopcode
-#   F   irop_flag_fragile
-#   Y   irop_flag_forking
-#   H   irop_flag_highlevel
-#   c   irop_flag_constlike
-#   K   irop_flag_keep
-#
-# irn_flags: special node flags, OPTIONAL (default is 0)
-# following irn_flags are supported:
-#   R   rematerializeable
-#   N   not spillable
-#   I   ignore for register allocation
-#
 # state: state of the operation, OPTIONAL (default is "floats")
 #
 # arity: arity of the operation, MUST NOT BE OMITTED
@@ -75,22 +59,6 @@ $arch = "TEMPLATE";
 #
 # comment: OPTIONAL comment for the node constructor
 #
-# rd_constructor: for every operation there will be a
-#      new_rd_<arch>_<op-name> function with the arguments from above
-#      which creates the ir_node corresponding to the defined operation
-#      you can either put the complete source code of this function here
-#
-#      This key is OPTIONAL. If omitted, the following constructor will
-#      be created:
-#      if (!op_<arch>_<op-name>) assert(0);
-#      for i = 1 to arity
-#         set in[i] = op_i
-#      done
-#      res = new_ir_node(db, irg, block, op_<arch>_<op-name>, mode, arity, in)
-#      return res
-#
-# 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 - caller save (register must be saved by the caller of a function)
@@ -115,7 +83,7 @@ $arch = "TEMPLATE";
                { name => "r13", type => 2 },
                { name => "sp", realname => "r14", type => 4 },  # stackpointer
                { name => "bp", realname => "r15", type => 4 },  # basepointer
-               { mode => "mode_Iu" }
+               { mode => $mode_gp }
        ],
        fp => [
                { name => "f0", type => 1 },
@@ -134,7 +102,7 @@ $arch = "TEMPLATE";
                { name => "f13", type => 1 },
                { name => "f14", type => 1 },
                { name => "f15", type => 1 },
-               { mode => "mode_D" }
+               { mode => $mode_fp }
        ]
 );
 
@@ -154,268 +122,198 @@ $arch = "TEMPLATE";
        C  => "${arch}_emit_immediate(node);"
 );
 
+$default_attr_type = "TEMPLATE_attr_t";
+$default_copy_attr = "TEMPLATE_copy_attr";
+
 %nodes = (
 
 # Integer nodes
 
 Add => {
-       op_flags  => "C",
-       irn_flags => "R",
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. add %S1, %S2, %D1'
-},
-
-Add_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. add %S1, %C, %D1'
+       emit      => '. add %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Mul => {
-       op_flags  => "C",
-       irn_flags => "R",
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      =>'. mul %S1, %S2, %D1'
-},
-
-Mul_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. mul %S1, %C, %D1'
+       emit      =>'. mul %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 And => {
-       op_flags  => "C",
-       irn_flags => "R",
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. and %S1, %S2, %D1'
-},
-
-And_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. and %S1, %C, %D1'
+       emit      => '. and %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Or => {
-       op_flags  => "C",
-       irn_flags => "R",
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. or %S1, %S2, %D1'
+       emit      => '. or %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
-Or_i => {
-       op_flags  => "C",
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. or %S1, %C, %D1'
-},
-
-Eor => {
-       op_flags  => "C",
-       irn_flags => "R",
+Xor => {
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. xor %S1, %S2, %D1'
-},
-
-Eor_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. xor %S1, %C, %D1'
+       emit      => '. xor %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Sub => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. sub %S1, %S2, %D1'
-},
-
-Sub_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. subl %S1, %C, %D1'
+       emit      => '. sub %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Shl => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. shl %S1, %S2, %D1'
-},
-
-Shl_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. shl %S1, %C, %D1'
+       emit      => '. shl %S1, %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Shr => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp", "gp" ], out => [ "in_r1" ] },
-       emit      => '. shr %S2, %D1'
-},
-
-Shr_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. shr %S1, %C, %D1'
-},
-
-RotR => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. ror %S1, %S2, %D1'
-},
-
-RotL => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp", "gp" ], out => [ "gp" ] },
-       emit      => '. rol %S1, %S2, %D1'
-},
-
-RotL_i => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. rol %S1, %C, %D1'
+       emit      => '. shr %S2, %D1',
+       mode      => $mode_gp,
 },
 
 Minus => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. neg %S1, %D1'
-},
-
-Inc => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. inc %S1, %D1'
-},
-
-Dec => {
-       irn_flags => "R",
-       reg_req   => { in => [ "gp" ], out => [ "gp" ] },
-       emit      => '. dec %S1, %D1'
+       emit      => '. neg %S1, %D1',
+       mode      => $mode_gp,
 },
 
 Not => {
-       arity       => 1,
-       remat       => 1,
-       reg_req     => { in => [ "gp" ], out => [ "gp" ] },
-       emit        => '. not %S1, %D1'
+       arity   => 1,
+       remat   => 1,
+       reg_req => { in => [ "gp" ], out => [ "gp" ] },
+       emit    => '. not %S1, %D1',
+       mode    => $mode_gp,
 },
 
 Const => {
-       op_flags  => "c",
-       irn_flags => "R",
-       reg_req   => { out => [ "gp" ] },
-       emit      => '. mov %C, %D1',
-       cmp_attr  =>
+       op_flags   => [ "constlike" ],
+       irn_flags  => [ "rematerializable" ],
+       attr       => "ir_tarval *value",
+       custominit => "set_TEMPLATE_value(res, value);",
+       reg_req    => { out => [ "gp" ] },
+       emit       => '. mov %C, %D1',
+       cmp_attr   =>
 '
        /* TODO: compare Const attributes */
     return 1;
-'
+',
+       mode    => $mode_gp,
 },
 
 # Control Flow
 
 Jmp => {
-       state    => "pinned",
-       op_flags => "X",
-       reg_req  => { out => [ "none" ] },
-       mode     => "mode_X",
+       state     => "pinned",
+       op_flags  => [ "cfopcode" ],
+       irn_flags => [ "simple_jump" ],
+       reg_req   => { out => [ "none" ] },
+       mode      => "mode_X",
 },
 
 # Load / Store
 
 Load => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "gp", "none" ], out => [ "gp" ] },
-       emit      => '. mov (%S1), %D1'
+       emit      => '. mov (%S1), %D1',
 },
 
 Store => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "gp", "gp", "none" ] },
-       emit      => '. movl %S2, (%S1)'
+       emit      => '. movl %S2, (%S1)',
 },
 
 # Floating Point operations
 
 fAdd => {
-       op_flags  => "C",
-       irn_flags => "R",
+       op_flags  => [ "commutative" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      => '. fadd %S1, %S2, %D1'
+       emit      => '. fadd %S1, %S2, %D1',
+       mode    => $mode_fp,
 },
 
 fMul => {
-       op_flags  => "C",
+       op_flags  => [ "commutative" ],
        reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      =>'. fmul %S1, %S2, %D1'
-},
-
-fMax => {
-       op_flags  => "C",
-       irn_flags => "R",
-       reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      =>'. fmax %S1, %S2, %D1'
-},
-
-fMin => {
-       op_flags  => "C",
-       irn_flags => "R",
-       reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      =>'. fmin %S1, %S2, %D1'
+       emit      =>'. fmul %S1, %S2, %D1',
+       mode      => $mode_fp,
 },
 
 fSub => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      => '. fsub %S1, %S2, %D1'
+       emit      => '. fsub %S1, %S2, %D1',
+       mode      => $mode_fp,
 },
 
 fDiv => {
        reg_req   => { in => [ "fp", "fp" ], out => [ "fp" ] },
-       emit      => '. fdiv %S1, %S2, %D1'
+       emit      => '. fdiv %S1, %S2, %D1',
+       mode      => $mode_fp,
 },
 
 fMinus => {
-       irn_flags => "R",
+       irn_flags => [ "rematerializable" ],
        reg_req   => { in => [ "fp" ], out => [ "fp" ] },
-       emit      => '. fneg %S1, %D1'
+       emit      => '. fneg %S1, %D1',
+       mode      => $mode_fp,
 },
 
 fConst => {
-       op_flags  => "c",
-       irn_flags => "R",
+       op_flags  => [ "constlike" ],
+       irn_flags => [ "rematerializable" ],
        reg_req   => { out => [ "fp" ] },
        emit      => '. fmov %C, %D1',
        cmp_attr  =>
 '
        /* TODO: compare fConst attributes */
        return 1;
-'
+',
+       mode      => $mode_fp,
 },
 
 # Load / Store
 
 fLoad => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "gp", "none" ], out => [ "fp" ] },
-       emit      => '. fmov (%S1), %D1'
+       emit      => '. fmov (%S1), %D1',
 },
 
 fStore => {
-       op_flags  => "L|F",
-       irn_flags => "R",
+       op_flags  => [ "labeled", "fragile" ],
+       irn_flags => [ "rematerializable" ],
        state     => "exc_pinned",
        reg_req   => { in => [ "gp", "fp", "none" ] },
-       emit      => '. fmov %S2, (%S1)'
+       emit      => '. fmov %S2, (%S1)',
 },
 
 );