Commit 68a3a77f authored by Matthias Braun's avatar Matthias Braun
Browse files

be: rework op_attr handling

parent 51e652d8
......@@ -1727,10 +1727,10 @@ static backend_params ia32_backend_params = {
*/
static void ia32_init(void)
{
ir_mode *mode_long_long;
ir_mode *mode_unsigned_long_long;
ir_type *type_long_long;
ir_type *type_unsigned_long_long;
ir_mode *mode_long_long;
ir_mode *mode_unsigned_long_long;
ir_type *type_long_long;
ir_type *type_unsigned_long_long;
ia32_setup_cg_config();
......@@ -1763,6 +1763,7 @@ static void ia32_init(void)
}
ia32_register_init();
obstack_init(&opcodes_obst);
ia32_create_opcodes(&ia32_irn_ops);
}
......@@ -1773,6 +1774,7 @@ static void ia32_finish(void)
between_type = NULL;
}
ia32_free_opcodes();
obstack_free(&opcodes_obst, NULL);
}
/**
......
......@@ -54,6 +54,8 @@
#include "ia32_new_nodes.h"
#include "gen_ia32_regalloc_if.h"
struct obstack opcodes_obst;
/**
* Dumper interface for dumping ia32 nodes in vcg.
* @param n the node to dump
......@@ -1114,5 +1116,12 @@ static void ia32_copy_attr(ir_graph *irg, const ir_node *old_node,
new_info->flags = old_info->flags;
}
static void ia32_init_op(ir_op *op, unsigned latency)
{
ia32_op_attr_t *attr = OALLOCZ(&opcodes_obst, ia32_op_attr_t);
attr->latency = latency;
set_op_attr(op, attr);
}
/* Include the generated constructor functions */
#include "gen_ia32_new_nodes.c.inl"
......@@ -48,6 +48,7 @@ enum {
pn_ia32_mem = 2
};
extern struct obstack opcodes_obst;
/**
* returns true if a node has x87 registers
......
......@@ -143,7 +143,7 @@ ENUM_BITSET(match_flags_t)
typedef struct ia32_op_attr_t ia32_op_attr_t;
struct ia32_op_attr_t {
match_flags_t flags;
//match_flags_t flags;
unsigned latency;
};
......
......@@ -2736,7 +2736,7 @@ foreach my $op (keys(%nodes)) {
die("Latency missing for op $op");
}
}
$op_attr_init .= "attr->latency = ".$node->{latency} . ";";
$op_attr_init .= "ia32_init_op(op, ".$node->{latency} . ");";
$node->{op_attr_init} = $op_attr_init;
}
......
......@@ -698,21 +698,18 @@ EOF
}
$n_opcodes++;
$temp = "\top_$op = new_ir_op(cur_opcode + iro_$op, \"$op\", op_pin_state_".$n{"state"}.", $op_flags";
$temp = "\top = new_ir_op(cur_opcode + iro_$op, \"$op\", op_pin_state_".$n{"state"}.", $op_flags";
$temp .= ", ".translate_arity($arity).", 0, ${attr_size}, &ops);\n";
push(@obst_new_irop, $temp);
if ($is_fragile) {
push(@obst_new_irop, "\tir_op_set_memory_index(op_${op}, n_${op}_mem);\n");
push(@obst_new_irop, "\tir_op_set_fragile_indices(op_${op}, pn_${op}_X_regular, pn_${op}_X_except);\n");
push(@obst_new_irop, "\tir_op_set_memory_index(op, n_${op}_mem);\n");
push(@obst_new_irop, "\tir_op_set_fragile_indices(op, pn_${op}_X_regular, pn_${op}_X_except);\n");
}
push(@obst_new_irop, "\tset_op_tag(op_$op, $arch\_op_tag);\n");
if(defined($default_op_attr_type)) {
push(@obst_new_irop, "\tattr = &attrs[iro_$op];\n");
if(defined($n{op_attr_init})) {
push(@obst_new_irop, "\t".$n{op_attr_init}."\n");
}
push(@obst_new_irop, "\tset_op_attr(op_$op, attr);\n");
push(@obst_new_irop, "\tset_op_tag(op, $arch\_op_tag);\n");
if(defined($n{op_attr_init})) {
push(@obst_new_irop, "\t".$n{op_attr_init}."\n");
}
push(@obst_new_irop, "\top_${op} = op;\n");
push(@obst_free_irop, "\tfree_ir_op(op_$op); op_$op = NULL;\n");
......@@ -824,24 +821,12 @@ $obst_constructor
void $arch\_create_opcodes(const arch_irn_ops_t *be_ops)
{
ir_op_ops ops;
int cur_opcode;
ENDOFMAIN
if (defined($default_op_attr_type)) {
print OUT "\t$default_op_attr_type *attr, *attrs;\n";
}
print OUT<<ENDOFMAIN;
cur_opcode = get_next_ir_opcodes(iro_$arch\_last);
ir_op *op;
int cur_opcode = get_next_ir_opcodes(iro_$arch\_last);
$arch\_opcode_start = cur_opcode;
ENDOFMAIN
if (defined($default_op_attr_type)) {
print OUT "\tattrs = XMALLOCNZ(${default_op_attr_type}, iro_${arch}_last);\n";
}
print OUT @obst_new_irop;
print OUT "\n";
print OUT "\t$arch\_register_additional_opcodes(cur_opcode);\n" if (defined($additional_opcodes));
......
Supports Markdown
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