From: Matthias Braun Date: Wed, 21 Dec 2011 12:15:50 +0000 (+0100) Subject: be: rework op_attr handling X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=68a3a77f08f0ccdadce9759d6eb19ecd875be7f0;p=libfirm be: rework op_attr handling --- diff --git a/ir/be/ia32/bearch_ia32.c b/ir/be/ia32/bearch_ia32.c index a293d7fa3..a3b499ce1 100644 --- a/ir/be/ia32/bearch_ia32.c +++ b/ir/be/ia32/bearch_ia32.c @@ -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); } /** diff --git a/ir/be/ia32/ia32_new_nodes.c b/ir/be/ia32/ia32_new_nodes.c index bdfc9c68a..62ed8d46e 100644 --- a/ir/be/ia32/ia32_new_nodes.c +++ b/ir/be/ia32/ia32_new_nodes.c @@ -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" diff --git a/ir/be/ia32/ia32_new_nodes.h b/ir/be/ia32/ia32_new_nodes.h index 6c296dfee..a6ca03e96 100644 --- a/ir/be/ia32/ia32_new_nodes.h +++ b/ir/be/ia32/ia32_new_nodes.h @@ -48,6 +48,7 @@ enum { pn_ia32_mem = 2 }; +extern struct obstack opcodes_obst; /** * returns true if a node has x87 registers diff --git a/ir/be/ia32/ia32_nodes_attr.h b/ir/be/ia32/ia32_nodes_attr.h index cfbc5a49b..71dd0e139 100644 --- a/ir/be/ia32/ia32_nodes_attr.h +++ b/ir/be/ia32/ia32_nodes_attr.h @@ -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; }; diff --git a/ir/be/ia32/ia32_spec.pl b/ir/be/ia32/ia32_spec.pl index e0ca3880f..3355198ee 100644 --- a/ir/be/ia32/ia32_spec.pl +++ b/ir/be/ia32/ia32_spec.pl @@ -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; } diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index 7ff3637f9..0c45138ff 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -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<