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

remove the 'special-constructor' feature. This removes a bunch of strange...

remove the 'special-constructor' feature. This removes a bunch of strange exceptions in the node generation scripts

[r28233]
parent b50ba7aa
......@@ -621,6 +621,76 @@ ir_node *new_d_ASM(dbg_info *db, int arity, ir_node *in[],
n_outs, outputs, n_clobber, clobber, text);
}
ir_node *new_rd_strictConv(dbg_info *dbgi, ir_node *block, ir_node * irn_op, ir_mode * mode)
{
ir_node *res;
ir_graph *irg = get_Block_irg(block);
ir_node *in[1];
in[0] = irn_op;
res = new_ir_node(dbgi, irg, block, op_Conv, mode, 1, in);
res->attr.conv.strict = 1;
res = optimize_node(res);
irn_verify_irg(res, irg);
return res;
}
ir_node *new_r_strictConv(ir_node *block, ir_node * irn_op, ir_mode * mode)
{
return new_rd_strictConv(NULL, block, irn_op, mode);
}
ir_node *new_d_strictConv(dbg_info *dbgi, ir_node * irn_op, ir_mode * mode)
{
ir_node *res;
assert(get_irg_phase_state(current_ir_graph) == phase_building);
res = new_rd_strictConv(dbgi, current_ir_graph->current_block, irn_op, mode);
return res;
}
ir_node *new_strictConv(ir_node * irn_op, ir_mode * mode)
{
return new_d_strictConv(NULL, irn_op, mode);
}
ir_node *new_rd_DivRL(dbg_info *dbgi, ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
{
ir_node *res;
ir_graph *irg = get_Block_irg(block);
ir_node *in[3];
in[0] = irn_mem;
in[1] = irn_left;
in[2] = irn_right;
res = new_ir_node(dbgi, irg, block, op_Div, mode_T, 3, in);
res->attr.divmod.resmode = resmode;
res->attr.divmod.no_remainder = 1;
res->attr.divmod.exc.pin_state = pin_state;
res = optimize_node(res);
irn_verify_irg(res, irg);
return res;
}
ir_node *new_r_DivRL(ir_node *block, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
{
return new_rd_DivRL(NULL, block, irn_mem, irn_left, irn_right, resmode, pin_state);
}
ir_node *new_d_DivRL(dbg_info *dbgi, ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
{
ir_node *res;
assert(get_irg_phase_state(current_ir_graph) == phase_building);
res = new_rd_DivRL(dbgi, current_ir_graph->current_block, irn_mem, irn_left, irn_right, resmode, pin_state);
return res;
}
ir_node *new_DivRL(ir_node * irn_mem, ir_node * irn_left, ir_node * irn_right, ir_mode* resmode, op_pin_state pin_state)
{
return new_d_DivRL(NULL, irn_mem, irn_left, irn_right, resmode, pin_state);
}
ir_node *new_rd_immBlock(dbg_info *dbgi, ir_graph *irg)
{
ir_node *res;
......
......@@ -195,7 +195,6 @@ def preprocess_node(node):
# construct node arguments
arguments = [ ]
initattrs = [ ]
specialconstrs = [ ]
for input in node.ins:
arguments.append(dict(type = "ir_node *", name = "irn_" + input))
......@@ -207,36 +206,10 @@ def preprocess_node(node):
arguments.append(dict(type = "ir_mode *", name = "mode"))
node.mode = "mode"
attrs_with_special = 0
for attr in node.attrs:
attr.setdefault("initname", "." + attr["name"])
if "special" in attr:
if not "init" in attr:
print "Node type %s has an attribute with a \"special\" entry but without \"init\"" % node.name
sys.exit(1)
if attrs_with_special != 0:
print "Node type %s has more than one attribute with a \"special\" entry" % node.name
sys.exit(1)
attrs_with_special += 1
if "prefix" in attr["special"]:
specialname = attr["special"]["prefix"] + node.name
elif "suffix" in attr["special"]:
specialname = node.name + attr["special"]["suffix"]
else:
print "Unknown special constructor type for node type %s" % node.name
sys.exit(1)
specialconstrs.append(
dict(
constrname = specialname,
attr = attr
)
)
elif not "init" in attr:
if not "init" in attr:
arguments.append(prepare_attr(attr))
# dynamic pin state means more constructor arguments
......@@ -271,13 +244,12 @@ def preprocess_node(node):
node.arguments = arguments
node.initattrs = initattrs
node.special_constructors = specialconstrs
#############################
constructor_template = env.from_string('''
ir_node *new_rd_{{node.constrname}}(
ir_node *new_rd_{{node.name}}(
{%- filter parameters %}
dbg_info *dbgi
{{node|blockparameter}}
......@@ -320,13 +292,13 @@ ir_node *new_rd_{{node.constrname}}(
return res;
}
ir_node *new_r_{{node.constrname}}(
ir_node *new_r_{{node.name}}(
{%- filter parameters %}
{{node|blockparameter}}
{{node|nodeparameters}}
{% endfilter %})
{
return new_rd_{{node.constrname}}(
return new_rd_{{node.name}}(
{%- filter arguments %}
NULL
{{node|blockargument}}
......@@ -334,7 +306,7 @@ ir_node *new_r_{{node.constrname}}(
{% endfilter %});
}
ir_node *new_d_{{node.constrname}}(
ir_node *new_d_{{node.name}}(
{%- filter parameters %}
dbg_info *dbgi
{{node|nodeparameters}}
......@@ -342,7 +314,7 @@ ir_node *new_d_{{node.constrname}}(
{
ir_node *res;
assert(get_irg_phase_state(current_ir_graph) == phase_building);
res = new_rd_{{node.constrname}}(
res = new_rd_{{node.name}}(
{%- filter parameters %}
dbgi
{{node|curblock}}
......@@ -351,12 +323,12 @@ ir_node *new_d_{{node.constrname}}(
return res;
}
ir_node *new_{{node.constrname}}(
ir_node *new_{{node.name}}(
{%- filter parameters %}
{{node|nodeparameters}}
{% endfilter %})
{
return new_d_{{node.constrname}}(
return new_d_{{node.name}}(
{%- filter arguments %}
NULL
{{node|nodearguments}}
......@@ -586,11 +558,6 @@ def main(argv):
if not isAbstract(node) and not hasattr(node, "noconstructor"):
file.write(constructor_template.render(vars()))
if hasattr(node, "special_constructors"):
for special in node.special_constructors:
node.constrname = special["constrname"]
special["attr"]["init"] = special["attr"]["special"]["init"]
file.write(constructor_template.render(vars()))
file.write("\n")
file.close()
......
......@@ -123,7 +123,6 @@ def preprocess_node(node):
# construct node arguments
arguments = [ ]
initargs = [ ]
specialconstrs = [ ]
i = 1
for input in node.ins:
arguments.append("preds[%i]" % i)
......@@ -136,36 +135,9 @@ def preprocess_node(node):
if not hasattr(node, "mode"):
arguments.append("mode")
attrs_with_special = 0
for attr in node.attrs:
prepare_attr(node, attr)
if "special" in attr:
if not "init" in attr:
warning("Node type %s has an attribute with a \"special\" entry but without \"init\"" % node.name)
sys.exit(1)
if attrs_with_special != 0:
warning("Node type %s has more than one attribute with a \"special\" entry" % node.name)
sys.exit(1)
attrs_with_special += 1
if "prefix" in attr["special"]:
specialname = attr["special"]["prefix"] + node.name
elif "suffix" in attr["special"]:
specialname = node.name + attr["special"]["suffix"]
else:
error("Unknown special constructor type for node type %s" % node.name)
sys.exit(1)
specialconstrs.append(
dict(
constrname = specialname,
attrname = attr["name"],
value = attr["special"]["init"]
)
)
elif "init" in attr:
if "init" in attr:
if attr["type"] == "op_pin_state":
initfunc = "set_irn_pinned"
else:
......@@ -180,7 +152,6 @@ def preprocess_node(node):
node.arguments = arguments
node.initargs = initargs
node.special_constructors = specialconstrs
export_attrs_template = env.from_string('''
case iro_{{node.name}}:
......@@ -199,15 +170,6 @@ import_attrs_template = env.from_string('''
{% for attr in node.constructor_args %}
{{attr.importcmd}}
{% endfor -%}
{% for special in node.special_constructors %}
if ({{special.attrname}} == {{special.value}})
newnode = new_r_{{special.constrname}}(
{%- filter arguments %}
{{node|block}}
{{node.arguments|args}}
{% endfilter %});
else
{% endfor -%}
newnode = new_r_{{node.name}}(
{%- filter arguments %}
{{node|block}}
......
......@@ -343,10 +343,6 @@ class Conv(Unop):
name = "strict",
type = "int",
init = "0",
special = dict(
prefix = "strict",
init = "1"
)
)
]
attr_struct = "conv_attr"
......@@ -392,10 +388,6 @@ class Div(Op):
name = "no_remainder",
type = "int",
init = "0",
special = dict(
suffix = "RL",
init = "1"
)
)
]
attr_struct = "divmod_attr"
......
......@@ -39,6 +39,5 @@ def setnodedefaults(node):
setdefault(node, "attrs", [])
setdefault(node, "constructor_args", [])
setdefault(node, "customSerializer", False)
setldefault(node, "constrname", node.name)
if hasattr(node, "outs"):
node.mode = "mode_T"
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