Commit 772a0897 authored by Moritz Kroll's avatar Moritz Kroll
Browse files

Added gen_ir.py support for DivRL and strictConv

[r25769]
parent 955ab695
......@@ -337,6 +337,7 @@ new_bd_defaultProj(dbg_info *db, ir_node *block, ir_node *arg,
return res;
} /* new_bd_defaultProj */
#ifdef USE_ORIGINAL
static ir_node *
new_bd_Conv(dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode, int strict_flag) {
ir_node *res;
......@@ -349,7 +350,6 @@ new_bd_Conv(dbg_info *db, ir_node *block, ir_node *op, ir_mode *mode, int strict
return res;
} /* new_bd_Conv */
#ifdef USE_ORIGINAL
static ir_node *
new_bd_Cast(dbg_info *db, ir_node *block, ir_node *op, ir_type *to_tp) {
ir_node *res;
......@@ -395,7 +395,6 @@ NEW_BD_BINOP(Rotl)
NEW_BD_UNOP(Abs)
NEW_BD_BINOP(Carry)
NEW_BD_BINOP(Borrow)
#endif
/** Creates a remainderless Div node. */
static ir_node *new_bd_DivRL(dbg_info *db, ir_node *block,
......@@ -416,7 +415,6 @@ static ir_node *new_bd_DivRL(dbg_info *db, ir_node *block,
return res;
}
#ifdef USE_ORIGINAL
static ir_node *
new_bd_Cmp(dbg_info *db, ir_node *block, ir_node *op1, ir_node *op2) {
ir_node *in[2];
......@@ -1028,7 +1026,6 @@ new_rd_Conv(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *m
return res;
} /* new_rd_Conv */
#endif
ir_node *
new_rd_strictConv(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_mode *mode) {
......@@ -1042,7 +1039,6 @@ new_rd_strictConv(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_m
return res;
} /* new_rd_strictConv */
#ifdef USE_ORIGINAL
ir_node *
new_rd_Cast(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *op, ir_type *to_tp) {
ir_node *res;
......@@ -1087,7 +1083,6 @@ NEW_RD_BINOP(Rotl)
NEW_RD_UNOP(Abs)
NEW_RD_BINOP(Carry)
NEW_RD_BINOP(Borrow)
#endif
/* creates a rd constructor for an divRL */
ir_node *new_rd_DivRL(dbg_info *db, ir_graph *irg, ir_node *block,
......@@ -1101,7 +1096,6 @@ ir_node *new_rd_DivRL(dbg_info *db, ir_graph *irg, ir_node *block,
return res;
}
#ifdef USE_ORIGINAL
ir_node *
new_rd_Cmp(dbg_info *db, ir_graph *irg, ir_node *block,
ir_node *op1, ir_node *op2) {
......@@ -1612,12 +1606,10 @@ ir_node *new_r_Div(ir_graph *irg, ir_node *block,
ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_rd_Div(NULL, irg, block, memop, op1, op2, mode, state);
}
#endif
ir_node *new_r_DivRL(ir_graph *irg, ir_node *block,
ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_rd_DivRL(NULL, irg, block, memop, op1, op2, mode, state);
}
#ifdef USE_ORIGINAL
ir_node *new_r_Mod(ir_graph *irg, ir_node *block,
ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_rd_Mod(NULL, irg, block, memop, op1, op2, mode, state);
......@@ -1674,11 +1666,11 @@ ir_node *new_r_Conv(ir_graph *irg, ir_node *block,
ir_node *op, ir_mode *mode) {
return new_rd_Conv(NULL, irg, block, op, mode);
}
#endif
ir_node *new_r_strictConv(ir_graph *irg, ir_node *block,
ir_node *op, ir_mode *mode) {
return new_rd_strictConv(NULL, irg, block, op, mode);
}
#endif
ir_node *new_r_Phi(ir_graph *irg, ir_node *block, int arity,
ir_node **in, ir_mode *mode) {
return new_rd_Phi(NULL, irg, block, arity, in, mode);
......@@ -2436,14 +2428,12 @@ ir_node *
new_d_Conv(dbg_info *db, ir_node *op, ir_mode *mode) {
return new_bd_Conv(db, current_ir_graph->current_block, op, mode, 0);
} /* new_d_Conv */
#endif
ir_node *
new_d_strictConv(dbg_info *db, ir_node *op, ir_mode *mode) {
return new_bd_Conv(db, current_ir_graph->current_block, op, mode, 1);
} /* new_d_strictConv */
#ifdef USE_ORIGINAL
ir_node *
new_d_Cast(dbg_info *db, ir_node *op, ir_type *to_tp) {
return new_bd_Cast(db, current_ir_graph->current_block, op, to_tp);
......@@ -2513,7 +2503,6 @@ new_d_Div(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mod
return res;
} /* new_d_Div */
#endif
ir_node *
new_d_DivRL(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
......@@ -2526,7 +2515,6 @@ new_d_DivRL(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *m
return res;
} /* new_d_DivRL */
#ifdef USE_ORIGINAL
ir_node *
new_d_Mod(dbg_info *db, ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
ir_node *res;
......@@ -3077,11 +3065,9 @@ ir_node *new_DivMod(ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, o
ir_node *new_Div(ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_d_Div(NULL, memop, op1, op2, mode, state);
}
#endif
ir_node *new_DivRL(ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_d_DivRL(NULL, memop, op1, op2, mode, state);
}
#ifdef USE_ORIGINAL
ir_node *new_Mod(ir_node *memop, ir_node *op1, ir_node *op2, ir_mode *mode, op_pin_state state) {
return new_d_Mod(NULL, memop, op1, op2, mode, state);
}
......@@ -3124,10 +3110,10 @@ ir_node *new_Cmp(ir_node *op1, ir_node *op2) {
ir_node *new_Conv(ir_node *op, ir_mode *mode) {
return new_d_Conv(NULL, op, mode);
}
#endif
ir_node *new_strictConv(ir_node *op, ir_mode *mode) {
return new_d_strictConv(NULL, op, mode);
}
#endif
ir_node *new_Phi(int arity, ir_node **in, ir_mode *mode) {
return new_d_Phi(NULL, arity, in, mode);
}
......
......@@ -134,13 +134,13 @@ def preprocess_node(nodename, node):
node.setdefault("ins", [])
node.setdefault("arity", len(node["ins"]))
node.setdefault("attrs", [])
node.setdefault("constrname", nodename);
node.setdefault("constructor_args", [])
node.setdefault("attrs_name", nodename.lower())
node.setdefault("block", "block")
# construct node arguments
arguments = [ ]
initargs = [ ]
initattrs = [ ]
specialconstrs = [ ]
for input in node["ins"]:
......@@ -167,7 +167,6 @@ def preprocess_node(nodename, node):
attr.setdefault("initname", "." + attr["name"])
# "special" stuff does not work at all, yet
if "special" in attr:
if not "init" in attr:
print "Node type %s has an attribute with a \"special\" entry but without \"init\"" % nodename
......@@ -190,13 +189,10 @@ def preprocess_node(nodename, node):
specialconstrs.append(
dict(
constrname = specialname,
attrname = attr["name"],
value = attr["special"]["init"]
attr = attr
)
)
elif "init" in attr:
initargs.append(attr["name"])
else:
elif not "init" in attr:
arguments.append(prepare_attr(attr))
for arg in node["constructor_args"]:
......@@ -211,14 +207,13 @@ def preprocess_node(nodename, node):
init = name + " & cons_unaligned ? align_non_aligned : align_is_aligned"))
node["args"] = arguments
node["initargs"] = initargs
node["initattrs"] = initattrs
node["special_constructors"] = specialconstrs
#############################
node_template = env.from_string('''
ir_node *new_rd_{{nodename}}({{node["dbdecl"]}}ir_graph *irg{{node|blockdecl}}{{node|argdecls}})
ir_node *new_rd_{{node["constrname"]}}({{node["dbdecl"]}}ir_graph *irg{{node|blockdecl}}{{node|argdecls}})
{
ir_node *res;
ir_graph *rem = current_ir_graph;
......@@ -243,34 +238,34 @@ ir_node *new_rd_{{nodename}}({{node["dbdecl"]}}ir_graph *irg{{node|blockdecl}}{{
return res;
}
ir_node *new_r_{{nodename}}(ir_graph *irg{{node|blockdecl}}{{node|argdecls}})
ir_node *new_r_{{node["constrname"]}}(ir_graph *irg{{node|blockdecl}}{{node|argdecls}})
{
{% if node["nodbginfo"] -%}
return new_rd_{{nodename}}(irg{{node|block}}{{node|args}});
return new_rd_{{node["constrname"]}}(irg{{node|block}}{{node|args}});
{%- else -%}
return new_rd_{{nodename}}(NULL, irg{{node|block}}{{node|args}});
return new_rd_{{node["constrname"]}}(NULL, irg{{node|block}}{{node|args}});
{%- endif %}
}
ir_node *new_d_{{nodename}}({{node["dbdeclnocomma"]}}{{node|argdecls(node["nodbginfo"])}})
ir_node *new_d_{{node["constrname"]}}({{node["dbdeclnocomma"]}}{{node|argdecls(node["nodbginfo"])}})
{
ir_node *res;
{{ node["d_pre"] }}
{% if node["nodbginfo"] -%}
res = new_rd_{{nodename}}(current_ir_graph{{node|curblock}}{{node|args}});
res = new_rd_{{node["constrname"]}}(current_ir_graph{{node|curblock}}{{node|args}});
{%- else -%}
res = new_rd_{{nodename}}(db, current_ir_graph{{node|curblock}}{{node|args}});
res = new_rd_{{node["constrname"]}}(db, current_ir_graph{{node|curblock}}{{node|args}});
{%- endif %}
{{ node["d_post"] }}
return res;
}
ir_node *new_{{nodename}}({{node|argdecls(True, True)}})
ir_node *new_{{node["constrname"]}}({{node|argdecls(True, True)}})
{
{% if node["nodbginfo"] -%}
return new_d_{{nodename}}({{node|args(True)}});
return new_d_{{node["constrname"]}}({{node|args(True)}});
{%- else -%}
return new_d_{{nodename}}(NULL{{node|args}});
return new_d_{{node["constrname"]}}(NULL{{node|args}});
{%- endif %}
}
......@@ -290,9 +285,9 @@ def main(argv):
# List of TODOs
niymap = ["Alloc", "Anchor", "ASM", "Bad", "Bound", "Break", "Builtin",
"Call", "CallBegin", "Const", "Const_type", "Const_long", "CopyB",
"defaultProj", "DivRL", "Dummy", "EndReg", "EndExcept",
"defaultProj", "Dummy", "EndReg", "EndExcept",
"Filter", "InstOf", "NoMem", "Phi", "Raise",
"simpleSel", "strictConv", "SymConst", "SymConst_type", "Sync"]
"simpleSel", "SymConst", "SymConst_type", "Sync"]
file = open(gendir + "/gen_ir_cons.c.inl", "w")
for nodename, node in do_dictsort(ir_spec.nodes):
......@@ -301,6 +296,12 @@ def main(argv):
preprocess_node(nodename, node)
if not "abstract" in node:
file.write(node_template.render(vars()))
if "special_constructors" in node:
for special in node["special_constructors"]:
node["constrname"] = special["constrname"]
special["attr"]["init"] = special["attr"]["special"]["init"]
file.write(node_template.render(vars()))
file.write("\n")
file.close()
......
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