allocate all op attributes on block instead of a lot of malloc calls
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 24 May 2008 16:35:45 +0000 (16:35 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sat, 24 May 2008 16:35:45 +0000 (16:35 +0000)
[r19749]

ir/be/scripts/generate_new_opcodes.pl

index b691e79..85e2627 100755 (executable)
@@ -586,8 +586,7 @@ foreach my $op (keys(%nodes)) {
        push(@obst_new_irop, $temp);
        push(@obst_new_irop, "\tset_op_tag(op_$op, $arch\_op_tag);\n");
        if(defined($default_op_attr_type)) {
-               push(@obst_new_irop, "\tattr = ($default_op_attr_type *) xmalloc(sizeof(attr[0]));\n");
-               push(@obst_new_irop, "\tmemset(attr, 0, sizeof(attr[0]));\n");
+               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");
                }
@@ -717,8 +716,8 @@ void $arch\_create_opcodes(const arch_irn_ops_t *be_ops) {
        int        i;
 ENDOFMAIN
 
-       if(defined($default_op_attr_type)) {
-               print OUT "\t$default_op_attr_type *attr;\n";
+       if (defined($default_op_attr_type)) {
+               print OUT "\t$default_op_attr_type *attr, *attrs;\n";
        }
 
 print OUT<<ENDOFMAIN;
@@ -739,6 +738,11 @@ print OUT<<ENDOFMAIN;
        $arch\_opcode_start = cur_opcode;
 ENDOFMAIN
 
+       if (defined($default_op_attr_type)) {
+               print OUT "\tattrs = xmalloc(sizeof(attr[0]) * iro_$arch\_last);\n";
+               print OUT "\tmemset(attrs, 0, sizeof(attr[0]) * 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));