kill the niymap exception from generator
authorMatthias Braun <matze@braunis.de>
Sat, 8 Jan 2011 12:32:15 +0000 (12:32 +0000)
committerMatthias Braun <matze@braunis.de>
Sat, 8 Jan 2011 12:32:15 +0000 (12:32 +0000)
[r28236]

ir/ir/ircons.c
scripts/gen_ir.py
scripts/ir_spec.py

index bb4e3a0..9299df3 100644 (file)
  */
 static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL;
 
-/**
- * Creates a Phi node with all predecessors.  Calling this constructor
- * is only allowed if the corresponding block is mature.
- */
-ir_node *new_rd_Phi(dbg_info *db, ir_node *block, int arity, ir_node **in,
-                    ir_mode *mode)
-{
-       ir_graph *irg = get_irn_irg(block);
-       ir_node  *res = new_ir_node(db, irg, block, op_Phi, mode, arity, in);
-       res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);
-
-       res = optimize_node(res);
-       irn_verify_irg(res, irg);
-
-       /* Memory Phis in endless loops must be kept alive.
-          As we can't distinguish these easily we keep all of them alive. */
-       if (is_Phi(res) && mode == mode_M)
-               add_End_keepalive(get_irg_end(irg), res);
-       return res;
-}
-
-ir_node *new_rd_Const(dbg_info *db, ir_graph *irg, ir_tarval *con)
-{
-       ir_node  *block = get_irg_start_block(irg);
-       ir_mode  *mode  = get_tarval_mode(con);
-       ir_node  *res   = new_ir_node(db, irg, block, op_Const, mode, 0, NULL);
-       res->attr.con.tarval = con;
-
-       res = optimize_node (res);
-       irn_verify_irg(res, irg);
-
-       return res;
-}
-
 ir_node *new_rd_Const_long(dbg_info *db, ir_graph *irg, ir_mode *mode,
                            long value)
 {
@@ -180,10 +146,6 @@ ir_node *new_rd_SymConst_align(dbg_info *db, ir_graph *irg, ir_mode *mode, ir_ty
        return new_rd_SymConst(db, irg, mode, sym, symconst_type_align);
 }
 
-ir_node *new_r_Const(ir_graph *irg, ir_tarval *con)
-{
-       return new_rd_Const(NULL, irg, con);
-}
 ir_node *new_r_Const_long(ir_graph *irg, ir_mode *mode, long value)
 {
        return new_rd_Const_long(NULL, irg, mode, value);
@@ -198,10 +160,6 @@ ir_node *new_r_simpleSel(ir_node *block, ir_node *store, ir_node *objptr,
 {
        return new_rd_Sel(NULL, block, store, objptr, 0, NULL, ent);
 }
-ir_node *new_r_Phi(ir_node *block, int arity, ir_node **in, ir_mode *mode)
-{
-       return new_rd_Phi(NULL, block, arity, in, mode);
-}
 ir_node *new_r_defaultProj(ir_node *arg, long max_proj)
 {
        return new_rd_defaultProj(NULL, arg, max_proj);
@@ -567,18 +525,6 @@ void mature_immBlock(ir_node *block)
        irn_verify_irg(block, irg);
 }
 
-ir_node *new_d_Phi(dbg_info *db, int arity, ir_node **in, ir_mode *mode)
-{
-       assert(get_irg_phase_state(current_ir_graph) == phase_building);
-       return new_rd_Phi(db, current_ir_graph->current_block, arity, in, mode);
-}
-
-ir_node *new_d_Const(dbg_info *db, ir_tarval *con)
-{
-       assert(get_irg_phase_state(current_ir_graph) == phase_building);
-       return new_rd_Const(db, current_ir_graph, con);
-}
-
 ir_node *new_d_Const_long(dbg_info *db, ir_mode *mode, long value)
 {
        assert(get_irg_phase_state(current_ir_graph) == phase_building);
@@ -954,11 +900,6 @@ void irp_finalize_cons(void)
        irp->phase_state = phase_high;
 }
 
-ir_node *new_Const(ir_tarval *con)
-{
-       return new_d_Const(NULL, con);
-}
-
 ir_node *new_Const_long(ir_mode *mode, long value)
 {
        return new_d_Const_long(NULL, mode, value);
@@ -972,10 +913,6 @@ ir_node *new_simpleSel(ir_node *store, ir_node *objptr, ir_entity *ent)
 {
        return new_d_simpleSel(NULL, store, objptr, ent);
 }
-ir_node *new_Phi(int arity, ir_node **in, ir_mode *mode)
-{
-       return new_d_Phi(NULL, arity, in, mode);
-}
 ir_node *new_defaultProj(ir_node *arg, long max_proj)
 {
        return new_d_defaultProj(NULL, arg, max_proj);
index 351f3c6..1d83e0e 100755 (executable)
@@ -239,8 +239,11 @@ def preprocess_node(node):
 
 #############################
 
-constructor_template = env.from_string('''
+gen_ircons_c_inl_template = env.from_string(
+'''/* Warning: automatically generated code */
 
+{%- for node in nodes %}
+{%- if not node.noconstructor %}
 ir_node *new_rd_{{node.name}}(
        {%- filter parameters %}
                dbg_info *dbgi
@@ -281,6 +284,7 @@ ir_node *new_rd_{{node.name}}(
        {{- node.init }}
        res = optimize_node(res);
        irn_verify_irg(res, irg);
+       {{- node.init_after_opt }}
        return res;
 }
 
@@ -326,6 +330,8 @@ ir_node *new_{{node.name}}(
                        {{node|nodearguments}}
                {% endfilter %});
 }
+{% endif %}
+{%- endfor %}
 ''')
 
 irnode_h_template = env.from_string(
@@ -538,19 +544,10 @@ def main(argv):
        # hardcoded path to libfirm/include/libfirm
        gendir2 = argv[2] + "/../../include/libfirm"
 
-       # List of TODOs
-       niymap = [ "ASM", "Const", "Phi", "SymConst" ]
-
        real_nodes = prepare_nodes()
-       file = open(gendir + "/gen_ir_cons.c.inl", "w")
-       for node in real_nodes:
-               if node.name in niymap:
-                       continue
 
-               if not isAbstract(node) and not hasattr(node, "noconstructor"):
-                       file.write(constructor_template.render(vars()))
-
-       file.write("\n")
+       file = open(gendir + "/gen_ir_cons.c.inl", "w")
+       file.write(gen_ircons_c_inl_template.render(nodes = real_nodes))
        file.close()
 
        file = open(gendir + "/gen_irnode.h", "w")
index d03bfd6..5ce3c87 100755 (executable)
@@ -80,6 +80,37 @@ class ASM(Op):
        attr_struct      = "asm_attr"
        attrs_name       = "assem"
        customSerializer = True
+       attrs = [
+               dict(
+                       name = "input_constraints",
+                       type = "ir_asm_constraint*",
+               ),
+               dict(
+                       name = "n_output_constraints",
+                       type = "int",
+                       noprop = True,
+               ),
+               dict(
+                       name = "output_constraints",
+                       type = "ir_asm_constraint*",
+               ),
+               dict(
+                       name = "n_clobbers",
+                       type = "int",
+                       noprop = True,
+               ),
+               dict(
+                       name = "clobbers",
+                       type = "ident**",
+               ),
+               dict(
+                       name = "text",
+                       type = "ident*",
+               ),
+       ]
+       # constructor is written manually at the moment, because of the clobbers+
+       # constraints arrays needing special handling (2 arguments for 1 attribute)
+       noconstructor = True
 
 class Bad(Op):
        """Bad nodes indicate invalid input, which is values which should never be
@@ -322,11 +353,11 @@ class Confirm(Op):
 
 class Const(Op):
        """Returns a constant value."""
-       mode       = ""
        flags      = [ "constlike", "start_block" ]
+       block      = "get_irg_start_block(irg)"
+       mode       = "get_tarval_mode(tarval)"
        knownBlock = True
        pinned     = "no"
-       attrs_name = "con"
        attrs      = [
                dict(
                        type = "ir_tarval*",
@@ -334,6 +365,7 @@ class Const(Op):
                )
        ]
        attr_struct = "const_attr"
+       attrs_name  = "con"
 
 class Conv(Unop):
        """Converts values between modes"""
@@ -611,12 +643,13 @@ class Phi(Op):
        arity         = "variable"
        flags         = []
        attr_struct   = "phi_attr"
-       init = '''
+       init          = '''
+       res->attr.phi.u.backedge = new_backedge_arr(irg->obst, arity);'''
+       init_after_opt = '''
        /* Memory Phis in endless loops must be kept alive.
           As we can't distinguish these easily we keep all of them alive. */
-       if (is_Phi(res) && mode == mode_M)
-               add_End_keepalive(get_irg_end(irg), res);
-       '''
+       if (is_Phi(res) && mode == mode_M)
+               add_End_keepalive(get_irg_end(irg), res);'''
 
 class Pin(Op):
        """Pin the value of the node node in the current block. No users of the Pin
@@ -800,6 +833,9 @@ class SymConst(Op):
        ]
        attr_struct = "symconst_attr"
        customSerializer = True
+       # constructor is written manually at the moment, because of the strange
+       # union argument
+       noconstructor = True
 
 class Sync(Op):
        """The Sync operation unifies several partial memory blocks. These blocks