Commit 853027b0 authored by Moritz Kroll's avatar Moritz Kroll
Browse files

Added gen_ir.py support for Call. Sort generated irio code

[r25772]
parent e789d592
......@@ -463,7 +463,6 @@ new_bd_Cond(dbg_info *db, ir_node *block, ir_node *c) {
IRN_VRFY_IRG(res, irg);
return res;
} /* new_bd_Cond */
#endif
static ir_node *
new_bd_Call(dbg_info *db, ir_node *block, ir_node *store,
......@@ -489,6 +488,7 @@ new_bd_Call(dbg_info *db, ir_node *block, ir_node *store,
IRN_VRFY_IRG(res, irg);
return res;
} /* new_bd_Call */
#endif
static ir_node *
new_bd_Builtin(dbg_info *db, ir_node *block, ir_node *store,
......@@ -1144,7 +1144,6 @@ new_rd_Cond(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *c) {
return res;
} /* new_rd_Cond */
#endif
ir_node *
new_rd_Call(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
......@@ -1158,6 +1157,7 @@ new_rd_Call(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
return res;
} /* new_rd_Call */
#endif
ir_node *
new_rd_Builtin(dbg_info *db, ir_graph *irg, ir_node *block, ir_node *store,
......@@ -1562,12 +1562,12 @@ ir_node *new_r_Sel(ir_graph *irg, ir_node *block, ir_node *store,
ir_entity *ent) {
return new_rd_Sel(NULL, irg, block, store, objptr, n_index, index, ent);
}
#endif
ir_node *new_r_Call(ir_graph *irg, ir_node *block, ir_node *store,
ir_node *callee, int arity, ir_node **in,
ir_type *tp) {
return new_rd_Call(NULL, irg, block, store, callee, arity, in, tp);
}
#endif
ir_node *new_r_Builtin(ir_graph *irg, ir_node *block, ir_node *store,
ir_builtin_kind kind, int arity, ir_node **in,
ir_type *tp) {
......@@ -2557,7 +2557,6 @@ ir_node *
new_d_Cond(dbg_info *db, ir_node *c) {
return new_bd_Cond(db, current_ir_graph->current_block, c);
} /* new_d_Cond */
#endif
ir_node *
new_d_Call(dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node **in,
......@@ -2571,6 +2570,7 @@ new_d_Call(dbg_info *db, ir_node *store, ir_node *callee, int arity, ir_node **i
return res;
} /* new_d_Call */
#endif
ir_node *
new_d_Builtin(dbg_info *db, ir_node *store, ir_builtin_kind kind, int arity, ir_node **in,
......@@ -3031,11 +3031,11 @@ ir_node *new_Sel(ir_node *store, ir_node *objptr, int arity, ir_node **in,
ir_entity *ent) {
return new_d_Sel(NULL, store, objptr, arity, in, ent);
}
#endif
ir_node *new_Call(ir_node *store, ir_node *callee, int arity, ir_node **in,
ir_type *tp) {
return new_d_Call(NULL, store, callee, arity, in, tp);
}
#endif
ir_node *new_Builtin(ir_node *store, ir_builtin_kind kind, int arity, ir_node **in,
ir_type *tp) {
return new_d_Builtin(NULL, store, kind, arity, in, tp);
......
......@@ -284,7 +284,7 @@ def main(argv):
# List of TODOs
niymap = ["Alloc", "Anchor", "ASM", "Bad", "Bound", "Break", "Builtin",
"Call", "CallBegin", "Const", "Const_type", "Const_long", "CopyB",
"CallBegin", "Const", "Const_type", "Const_long", "CopyB",
"defaultProj", "Dummy", "EndReg", "EndExcept",
"Filter", "InstOf", "NoMem", "Phi", "Raise",
"simpleSel", "SymConst", "SymConst_type", "Sync"]
......
#!/usr/bin/env python
import sys
from jinja2 import Environment, Template
from jinja2.filters import do_dictsort
import ir_spec
def format_args(arglist):
......@@ -206,7 +207,11 @@ def preprocess_node(nodename, node):
)
)
elif "init" in attr:
initargs.append(attr["name"])
if attr["type"] == "op_pin_state":
initfunc = "set_irn_pinned"
else:
initfunc = "set_" + nodename + "_" + attr["name"]
initargs.append((attr["name"], initfunc))
else:
arguments.append(attr["name"])
......@@ -238,7 +243,7 @@ import_attrs_template = env.from_string('''
newnode = new_r_{{special.constrname}}(current_ir_graph{{node|block}}{{node["arguments"]|args}});
else{% endfor %}
newnode = new_r_{{nodename}}(current_ir_graph{{node|block}}{{node["arguments"]|args}});
{% for initarg in node.initargs %}set_{{nodename}}_{{initarg}}(newnode, {{initarg}});
{% for (initarg, initfunc) in node.initargs %}{{initfunc}}(newnode, {{initarg}});
{% endfor %}
break;
}
......@@ -253,8 +258,10 @@ def main(argv):
gendir = argv[2]
sortednodes = do_dictsort(ir_spec.nodes)
file = open(gendir + "/gen_irio_export.inl", "w");
for nodename, node in ir_spec.nodes.iteritems():
for nodename, node in sortednodes:
preprocess_node(nodename, node)
if not "abstract" in node:
file.write(export_attrs_template.render(vars()))
......@@ -262,7 +269,7 @@ def main(argv):
file.close()
file = open(gendir + "/gen_irio_import.inl", "w");
for nodename, node in ir_spec.nodes.iteritems():
for nodename, node in sortednodes:
if not "abstract" in node and nodename != "Start" and nodename != "End" and nodename != "Anchor" and nodename != "SymConst" and nodename != "Block":
file.write(import_attrs_template.render(vars()))
# TODO: SymConst
......@@ -270,7 +277,7 @@ def main(argv):
file.close()
file = open(gendir + "/gen_irio_lex.inl", "w");
for nodename, node in ir_spec.nodes.iteritems():
for nodename, node in sortednodes:
if not "abstract" in node:
file.write("\tINSERT(\"" + nodename + "\", tt_iro, iro_" + nodename + ");\n");
file.close()
......
......@@ -162,8 +162,22 @@ Call = dict(
dict(
type = "ir_type*",
name = "type"
),
dict(
name = "state",
type = "op_pin_state",
initname = ".exc.pin_state",
init = "op_pin_state_pinned"
)
]
],
init = '''
assert((get_unknown_type() == type) || is_Method_type(type));
''',
d_post = '''
#if PRECISE_EXC_CONTEXT
firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
#endif
'''
),
Carry = dict(
......
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