Commit 3d75a327 authored by Matthias Braun's avatar Matthias Braun
Browse files

cleanup ir_spec and let the script generate Start,End and Sync now

[r28097]
parent e5880a46
......@@ -1156,7 +1156,7 @@ FIRM_API ir_node *new_rd_Start(dbg_info *db, ir_graph *irg);
* @param *db A pointer for debug information.
* @param *irg The IR graph the node belongs to.
*/
FIRM_API ir_node *new_rd_End(dbg_info *db, ir_graph *irg);
FIRM_API ir_node *new_rd_End(dbg_info *db, ir_graph *irg, int arity, ir_node *in[]);
/** Constructor for a Jmp node.
*
......@@ -1947,7 +1947,7 @@ FIRM_API ir_node *new_r_Block(ir_graph *irg, int arity, ir_node *in[]);
FIRM_API ir_node *new_r_Start(ir_graph *irg);
/** Constructor for a End node. */
FIRM_API ir_node *new_r_End(ir_graph *irg);
FIRM_API ir_node *new_r_End(ir_graph *irg, int arity, ir_node *in[]);
/** Constructor for a Jmp node.
*
......@@ -2662,7 +2662,7 @@ FIRM_API ir_node *new_d_Start(dbg_info *db);
*
* @param *db A pointer for debug information.
*/
FIRM_API ir_node *new_d_End(dbg_info *db);
FIRM_API ir_node *new_d_End(dbg_info *db, int arity, ir_node *in[]);
/** Constructor for a Jmp node.
*
......@@ -3401,7 +3401,7 @@ FIRM_API ir_node *new_Start(void);
*
* Adds the node to the block in current_ir_block.
*/
FIRM_API ir_node *new_End(void);
FIRM_API ir_node *new_End(int arity, ir_node *in[]);
/** Constructor for a Jump node.
*
......
......@@ -51,26 +51,6 @@
*/
static uninitialized_local_variable_func_t *default_initialize_local_variable = NULL;
ir_node *new_rd_Start(dbg_info *db, ir_graph *irg)
{
ir_node *block = get_irg_start_block(irg);
ir_node *res = new_ir_node(db, irg, block, op_Start, mode_T, 0, NULL);
res = optimize_node(res);
irn_verify_irg(res, irg);
return res;
}
ir_node *new_rd_End(dbg_info *db, ir_graph *irg)
{
ir_node *block = get_irg_end_block(irg);
ir_node *res = new_ir_node(db, irg, block, op_End, mode_X, -1, NULL);
res = optimize_node(res);
irn_verify_irg(res, irg);
return res;
}
/**
* Creates a Phi node with all predecessors. Calling this constructor
* is only allowed if the corresponding block is mature.
......@@ -121,20 +101,6 @@ ir_node *new_rd_defaultProj(dbg_info *db, ir_node *arg, long max_proj)
return res;
}
ir_node *new_rd_Sync(dbg_info *db, ir_node *block, int arity, ir_node *in[])
{
ir_graph *irg = get_irn_irg(block);
ir_node *res = new_ir_node(db, irg, block, op_Sync, mode_M, -1, NULL);
int i;
for (i = 0; i < arity; ++i)
add_Sync_pred(res, in[i]);
res = optimize_node(res);
irn_verify_irg(res, irg);
return res;
}
ir_node *new_rd_ASM(dbg_info *db, ir_node *block, int arity, ir_node *in[],
ir_asm_constraint *inputs, int n_outs,
ir_asm_constraint *outputs, int n_clobber,
......@@ -214,14 +180,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_Start(ir_graph *irg)
{
return new_rd_Start(NULL, irg);
}
ir_node *new_r_End(ir_graph *irg)
{
return new_rd_End(NULL, irg);
}
ir_node *new_r_Const(ir_graph *irg, ir_tarval *con)
{
return new_rd_Const(NULL, irg, con);
......@@ -244,10 +202,6 @@ 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_Sync(ir_node *block, int arity, ir_node *in[])
{
return new_rd_Sync(NULL, block, arity, in);
}
ir_node *new_r_defaultProj(ir_node *arg, long max_proj)
{
return new_rd_defaultProj(NULL, arg, max_proj);
......@@ -268,35 +222,6 @@ ir_node *new_r_ASM(ir_node *block,
return new_rd_ASM(NULL, block, arity, in, inputs, n_outs, outputs, n_clobber, clobber, text);
}
/** ********************/
/** public interfaces */
/** construction tools */
ir_node *new_d_Start(dbg_info *db)
{
ir_node *res;
assert(get_irg_phase_state(current_ir_graph) == phase_building);
res = new_ir_node(db, current_ir_graph, current_ir_graph->current_block,
op_Start, mode_T, 0, NULL);
res = optimize_node(res);
irn_verify_irg(res, current_ir_graph);
return res;
}
ir_node *new_d_End(dbg_info *db)
{
ir_node *res;
assert(get_irg_phase_state(current_ir_graph) == phase_building);
res = new_ir_node(db, current_ir_graph, current_ir_graph->current_block,
op_End, mode_X, -1, NULL);
res = optimize_node(res);
irn_verify_irg(res, current_ir_graph);
return res;
}
/* ***********************************************************************/
/* Methods necessary for automatic Phi node creation */
/*
......@@ -691,12 +616,6 @@ ir_node *new_d_SymConst(dbg_info *db, ir_mode *mode, symconst_symbol value,
return new_rd_SymConst(db, current_ir_graph, mode, value, kind);
}
ir_node *new_d_Sync(dbg_info *db, int arity, ir_node *in[])
{
assert(get_irg_phase_state(current_ir_graph) == phase_building);
return new_rd_Sync(db, current_ir_graph->current_block, arity, in);
}
ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
ir_asm_constraint *inputs,
int n_outs, ir_asm_constraint *outputs, int n_clobber,
......@@ -956,14 +875,6 @@ void irp_finalize_cons(void)
irp->phase_state = phase_high;
}
ir_node *new_Start(void)
{
return new_d_Start(NULL);
}
ir_node *new_End(void)
{
return new_d_End(NULL);
}
ir_node *new_Const(ir_tarval *con)
{
return new_d_Const(NULL, con);
......@@ -986,10 +897,6 @@ ir_node *new_Phi(int arity, ir_node **in, ir_mode *mode)
{
return new_d_Phi(NULL, arity, in, mode);
}
ir_node *new_Sync(int arity, ir_node *in[])
{
return new_d_Sync(NULL, arity, in);
}
ir_node *new_defaultProj(ir_node *arg, long max_proj)
{
return new_d_defaultProj(NULL, arg, max_proj);
......@@ -1025,3 +932,18 @@ ir_node *new_r_Anchor(ir_graph *irg)
return res;
}
ir_node *new_r_Block_noopt(ir_graph *irg, int arity, ir_node *in[])
{
ir_node *res = new_ir_node(NULL, irg, NULL, op_Block, mode_BB, arity, in);
res->attr.block.irg.irg = irg;
res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
set_Block_matured(res, 1);
/* Create and initialize array for Phi-node construction. */
if (get_irg_phase_state(irg) == phase_building) {
res->attr.block.graph_arr = NEW_ARR_D(ir_node *, irg->obst, irg->n_loc);
memset(res->attr.block.graph_arr, 0, irg->n_loc * sizeof(ir_node*));
}
irn_verify_irg(res, irg);
return res;
}
......@@ -35,6 +35,10 @@
*/
ir_node *new_r_Anchor(ir_graph *irg);
/** create new block node without immediately optimizing it.
* This is an internal helper function for new_ir_graph() */
ir_node *new_r_Block_noopt(ir_graph *irg, int arity, ir_node *in[]);
/**
* Allocate a frag array for a node if the current graph state is phase_building.
*
......
......@@ -212,10 +212,10 @@ ir_graph *new_r_ir_graph(ir_entity *ent, int n_loc)
/*-- Nodes needed in every graph --*/
set_irg_end_block (res, new_r_immBlock(res));
end = new_r_End(res);
end = new_r_End(res, 0, NULL);
set_irg_end(res, end);
start_block = new_r_Block(res, 0, NULL);
start_block = new_r_Block_noopt(res, 0, NULL);
set_irg_start_block(res, start_block);
bad = new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL);
bad->attr.irg.irg = res;
......@@ -299,13 +299,13 @@ ir_graph *new_const_code_irg(void)
res->anchor = new_r_Anchor(res);
/* -- The end block -- */
end_block = new_r_Block(res, 0, NULL);
end_block = new_r_Block_noopt(res, 0, NULL);
set_irg_end_block(res, end_block);
end = new_r_End(res);
end = new_r_End(res, 0, NULL);
set_irg_end(res, end);
/* -- The start block -- */
start_block = new_r_Block(res, 0, NULL);
start_block = new_r_Block_noopt(res, 0, NULL);
set_irg_start_block(res, start_block);
bad = new_ir_node(NULL, res, start_block, op_Bad, mode_T, 0, NULL);
bad->attr.irg.irg = res;
......
......@@ -285,8 +285,12 @@ ir_node *new_rd_{{node.constrname}}(
{% endfilter %})
{
ir_node *res;
{%- if node.arity == "dynamic" %}
int i;
{%- endif %}
{{node|irgassign}}
{{node|insdecl}}
res = new_ir_node(
{%- filter arguments %}
dbgi
......@@ -296,6 +300,11 @@ ir_node *new_rd_{{node.constrname}}(
{{node.mode}}
{{node|arity_and_ins}}
{% endfilter %});
{%- if node.arity == "dynamic" %}
for (i = 0; i < arity; ++i) {
add_irn_n(res, in[i]);
}
{%- endif %}
{%- for attr in node.attrs %}
res->attr.{{node.attrs_name}}{{attr["initname"]}} =
{%- if "init" in attr %} {{ attr["init"] -}};
......@@ -306,9 +315,7 @@ ir_node *new_rd_{{node.constrname}}(
res->attr.{{node.attrs_name}}{{attr["initname"]}} = {{ attr["init"] -}};
{%- endfor %}
{{- node.init }}
{%- if node.optimize != False %}
res = optimize_node(res);
{%- endif %}
irn_verify_irg(res, irg);
return res;
}
......@@ -568,7 +575,7 @@ def main(argv):
gendir2 = argv[2] + "/../../include/libfirm"
# List of TODOs
niymap = [ "ASM", "Const", "Phi", "SymConst", "Sync"]
niymap = [ "ASM", "Const", "Phi", "SymConst" ]
real_nodes = prepare_nodes()
file = open(gendir + "/gen_ir_cons.c.inl", "w")
......@@ -576,7 +583,7 @@ def main(argv):
if node.name in niymap:
continue
if not isAbstract(node) and not hasattr(node, "singleton"):
if not isAbstract(node) and not hasattr(node, "noconstructor"):
file.write(constructor_template.render(vars()))
if hasattr(node, "special_constructors"):
......
......@@ -53,6 +53,7 @@ class Anchor(Op):
attr_struct = "irg_attr"
knownBlock = True
singleton = True
noconstructor = True
class And(Binop):
flags = [ "commutative" ]
......@@ -93,48 +94,38 @@ class ASM(Op):
type = "ident*",
),
]
java_noconstr = True
class Bad(Op):
mode = "mode_Bad"
flags = [ "cfopcode", "start_block", "dump_noblock" ]
pinned = "yes"
knownBlock = True
singleton = True
attr_struct = "bad_attr"
mode = "mode_Bad"
flags = [ "cfopcode", "start_block", "dump_noblock" ]
pinned = "yes"
knownBlock = True
singleton = True
attr_struct = "bad_attr"
noconstructor = True
init = '''
res->attr.irg.irg = irg;
'''
class Deleted(Op):
mode = "mode_Bad"
flags = [ ]
pinned = "yes"
knownBlock = True
singleton = True
mode = "mode_Bad"
flags = [ ]
pinned = "yes"
noconstructor = True
class Block(Op):
mode = "mode_BB"
knownBlock = True
block = "NULL"
pinned = "yes"
optimize = False
arity = "variable"
flags = [ "labeled" ]
attr_struct = "block_attr"
java_noconstr = True
init = '''
res->attr.block.is_dead = 0;
res->attr.block.irg.irg = irg;
res->attr.block.backedge = new_backedge_arr(irg->obst, arity);
res->attr.block.in_cg = NULL;
res->attr.block.cg_backedge = NULL;
res->attr.block.extblk = NULL;
res->attr.block.entity = NULL;
set_Block_matured(res, 1);
set_Block_block_visited(res, 0);
/* Create and initialize array for Phi-node construction. */
if (get_irg_phase_state(irg) == phase_building) {
......@@ -427,6 +418,8 @@ class End(Op):
pinned = "yes"
arity = "dynamic"
flags = [ "cfopcode" ]
knownBlock = True
block = "get_irg_end_block(irg)"
singleton = True
class Eor(Binop):
......@@ -547,11 +540,12 @@ class Mux(Op):
pinned = "no"
class NoMem(Op):
mode = "mode_M"
flags = [ "dump_noblock", "dump_noinput" ]
pinned = "yes"
knownBlock = True
singleton = True
mode = "mode_M"
flags = [ "dump_noblock", "dump_noinput" ]
pinned = "yes"
knownBlock = True
singleton = True
noconstructor = True
class Not(Unop):
flags = []
......@@ -564,7 +558,6 @@ class Phi(Op):
arity = "variable"
flags = []
attr_struct = "phi_attr"
java_noconstr = True
init = '''
/* Memory Phis in endless loops must be kept alive.
As we can't distinguish these easily we keep all of them alive. */
......@@ -671,6 +664,8 @@ class Start(Op):
pinned = "yes"
flags = [ "cfopcode" ]
singleton = True
knownBlock = True
block = "get_irg_start_block(irg)"
class Store(Op):
ins = [ "mem", "ptr", "value" ]
......@@ -706,13 +701,11 @@ class SymConst(Op):
)
]
attr_struct = "symconst_attr"
java_noconstr = True
class Sync(Op):
mode = "mode_M"
flags = []
pinned = "no"
optimize = False
arity = "dynamic"
class Tuple(Op):
......@@ -720,7 +713,6 @@ class Tuple(Op):
mode = "mode_T"
pinned = "no"
flags = [ "labeled" ]
java_noconstr = True
class Unknown(Op):
knownBlock = True
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment