*/
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)
{
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);
{
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);
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);
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);
{
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);
#############################
-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
{{- node.init }}
res = optimize_node(res);
irn_verify_irg(res, irg);
+ {{- node.init_after_opt }}
return res;
}
{{node|nodearguments}}
{% endfilter %});
}
+{% endif %}
+{%- endfor %}
''')
irnode_h_template = env.from_string(
# 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")
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
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*",
)
]
attr_struct = "const_attr"
+ attrs_name = "con"
class Conv(Unop):
"""Converts values between modes"""
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
]
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