Commit 604fda63 authored by Matthias Braun's avatar Matthias Braun
Browse files

automatically generate code to allocate the 'frag_arr' for fragile nodes;...

automatically generate code to allocate the 'frag_arr' for fragile nodes; improve readability of autogenerated code

[r27832]
parent 115b9e0e
......@@ -57,18 +57,19 @@ def format_insdecl(node):
if arity == "variable":
insarity = len(node.ins)
res = "int r_arity = arity + " + `insarity` + ";\n\tir_node **r_in;\n\t" \
+ "NEW_ARR_A(ir_node *, r_in, r_arity);\n\t"
res = "int r_arity = arity + " + `insarity` + ";"
res += "\n\tir_node **r_in;"
res += "\n\tNEW_ARR_A(ir_node *, r_in, r_arity);"
i = 0
for input in node.ins:
res += "r_in[" + `i` + "] = irn_" + input + ";\n\t"
res += "\n\tr_in[" + `i` + "] = irn_" + input + ";"
i += 1
res += "memcpy(&r_in[" + `insarity` + "], in, sizeof(ir_node *) * arity);\n\t"
res += "\n\tmemcpy(&r_in[" + `insarity` + "], in, sizeof(ir_node *) * arity);\n\t"
else:
res = "ir_node *in[" + `arity` + "];\n\t"
res = "ir_node *in[" + `arity` + "];"
i = 0
for input in node.ins:
res += "in[" + `i` + "] = irn_" + input + ";\n\t"
res += "\n\tin[" + `i` + "] = irn_" + input + ";"
i += 1
return res
......@@ -290,19 +291,19 @@ ir_node *new_rd_{{node.constrname}}(
{{node.mode}}
{{node|arity_and_ins}}
{% endfilter %});
{% for attr in node.attrs -%}
res->attr.{{node.attrs_name}}{{attr["initname"]}} =
{%- for attr in node.attrs %}
res->attr.{{node.attrs_name}}{{attr["initname"]}} =
{%- if "init" in attr %} {{ attr["init"] -}};
{%- else %} {{ attr["name"] -}};
{% endif %}
{% endfor %}
{%- for attr in node.initattrs -%}
res->attr.{{node.attrs_name}}{{attr["initname"]}} = {{ attr["init"] -}};
{%- endif %}
{%- endfor %}
{%- for attr in node.initattrs %}
res->attr.{{node.attrs_name}}{{attr["initname"]}} = {{ attr["init"] -}};
{%- endfor %}
{{- node.init }}
{% if node.optimize != False -%}
res = optimize_node(res);
{% endif -%}
{%- if node.optimize != False %}
res = optimize_node(res);
{%- endif %}
IRN_VRFY_IRG(res, irg);
current_ir_graph = rem;
return res;
......@@ -329,14 +330,15 @@ ir_node *new_d_{{node.constrname}}(
{% endfilter %})
{
ir_node *res;
{{ node.d_pre }}
res = new_rd_{{node.constrname}}(
{%- filter parameters %}
dbgi
{{node|curblock}}
{{node|nodearguments}}
{% endfilter %});
{{ node.d_post }}
{%- if "fragile" in node.flags %}
firm_alloc_frag_arr(res, op_{{node.name}}, &res->attr.except.frag_arr);
{%- endif %}
return res;
}
......
......@@ -47,9 +47,6 @@ class Alloc(Op):
]
pinned = "yes"
attr_struct = "alloc_attr"
d_post = '''
firm_alloc_frag_arr(res, op_Alloc, &res->attr.alloc.exc.frag_arr);
'''
class Anchor(Op):
mode = "mode_ANY"
......@@ -102,7 +99,7 @@ class ASM(Op):
class Bad(Op):
mode = "mode_Bad"
flags = [ "cfopcode", "fragile", "start_block", "dump_noblock" ]
flags = [ "cfopcode", "start_block", "dump_noblock" ]
pinned = "yes"
knownBlock = True
singleton = True
......@@ -186,9 +183,6 @@ class Bound(Op):
pinned_init = "op_pin_state_pinned"
attr_struct = "bound_attr"
attrs_name = "bound"
d_post = '''
firm_alloc_frag_arr(res, op_Bound, &res->attr.bound.exc.frag_arr);
'''
class Builtin(Op):
ins = [ "mem" ]
......@@ -244,9 +238,6 @@ class Call(Op):
init = '''
assert((get_unknown_type() == type) || is_Method_type(type));
'''
d_post = '''
firm_alloc_frag_arr(res, op_Call, &res->attr.call.exc.frag_arr);
'''
class Cast(Unop):
mode = "get_irn_mode(irn_op)"
......@@ -365,9 +356,6 @@ class CopyB(Op):
attrs_name = "copyb"
pinned = "memory"
pinned_init = "op_pin_state_pinned"
d_post = '''
firm_alloc_frag_arr(res, op_CopyB, &res->attr.copyb.exc.frag_arr);
'''
class Div(Op):
ins = [ "mem", "left", "right" ]
......@@ -398,9 +386,6 @@ class Div(Op):
pinned = "exception"
op_index = 1
arity_override = "oparity_binary"
d_post = '''
firm_alloc_frag_arr(res, op_Div, &res->attr.except.frag_arr);
'''
class DivMod(Op):
ins = [ "mem", "left", "right" ]
......@@ -423,14 +408,10 @@ class DivMod(Op):
pinned = "exception"
op_index = 1
arity_override = "oparity_binary"
d_post = '''
firm_alloc_frag_arr(res, op_DivMod, &res->attr.except.frag_arr);
'''
class Dummy(Op):
ins = []
flags = [ "cfopcode", "fragile", "start_block", "constlike",
"dump_noblock" ]
flags = [ "cfopcode", "start_block", "constlike", "dump_noblock" ]
knownBlock = True
pinned = "yes"
block = "get_irg_start_block(irg)"
......@@ -523,9 +504,6 @@ class Load(Op):
name = "flags",
),
]
d_post = '''
firm_alloc_frag_arr(res, op_Load, &res->attr.load.exc.frag_arr);
'''
class Minus(Unop):
flags = []
......@@ -550,9 +528,6 @@ class Mod(Op):
pinned = "exception"
op_index = 1
arity_override = "oparity_binary"
d_post = '''
firm_alloc_frag_arr(res, op_Mod, &res->attr.except.frag_arr);
'''
class Mul(Binop):
flags = [ "commutative" ]
......@@ -635,9 +610,6 @@ class Quot(Op):
pinned = "exception"
op_index = 1
arity_override = "oparity_binary"
d_post = '''
firm_alloc_frag_arr(res, op_Quot, &res->attr.except.frag_arr);
'''
class Raise(Op):
ins = [ "mem", "exo_ptr" ]
......@@ -711,9 +683,6 @@ class Store(Op):
name = "flags",
),
]
d_post = '''
firm_alloc_frag_arr(res, op_Store, &res->attr.store.exc.frag_arr);
'''
class Sub(Binop):
flags = []
......@@ -751,8 +720,7 @@ class Unknown(Op):
knownBlock = True
pinned = "yes"
block = "get_irg_start_block(irg)"
flags = [ "cfopcode", "fragile", "start_block", "constlike",
"dump_noblock" ]
flags = [ "cfopcode", "start_block", "constlike", "dump_noblock" ]
# Prepare node list
......
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