be: rework op_attr handling
authorMatthias Braun <matze@braunis.de>
Wed, 21 Dec 2011 12:15:50 +0000 (13:15 +0100)
committerMatthias Braun <matze@braunis.de>
Wed, 21 Dec 2011 17:21:21 +0000 (18:21 +0100)
ir/be/ia32/bearch_ia32.c
ir/be/ia32/ia32_new_nodes.c
ir/be/ia32/ia32_new_nodes.h
ir/be/ia32/ia32_nodes_attr.h
ir/be/ia32/ia32_spec.pl
ir/be/scripts/generate_new_opcodes.pl

index a293d7f..a3b499c 100644 (file)
@@ -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);
 }
 
 /**
index bdfc9c6..62ed8d4 100644 (file)
@@ -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"
index 6c296df..a6ca03e 100644 (file)
@@ -48,6 +48,7 @@ enum {
        pn_ia32_mem   = 2
 };
 
+extern struct obstack opcodes_obst;
 
 /**
  * returns true if a node has x87 registers
index cfbc5a4..71dd0e1 100644 (file)
@@ -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;
 };
 
index e0ca388..3355198 100644 (file)
@@ -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;
 }
index 7ff3637..0c45138 100755 (executable)
@@ -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));