X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fscripts%2Fgenerate_new_opcodes.pl;h=a97cacdb88573742ec83f0513c82c749dde9bc7b;hb=c23b55879df97f49fc6f1e95651f9f28a980b620;hp=0e153368a1bf44da81e5077e09b32d6ec7d51cee;hpb=e830cecd3c6a78682fec44ffa180b184639a4944;p=libfirm diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index 0e153368a..a97cacdb8 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # -# Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. +# Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. # # This file is part of libFirm. # @@ -39,10 +39,14 @@ our $additional_opcodes; our %nodes; our %operands; our %cpu; +our $default_op_attr_type; our $default_attr_type; our $default_cmp_attr; +our $default_copy_attr; our %init_attr; +our $custom_init_attr_func; our %compare_attr; +our %copy_attr; our %reg_classes; # include spec file @@ -65,7 +69,7 @@ if(!defined($default_attr_type)) { } if(!defined(%init_attr)) { %init_attr = ( - "$default_attr_type" => "\tinit_${arch}_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res, latency);", + "$default_attr_type" => "\tinit_${arch}_attributes(res, flags, in_reqs, out_reqs, exec_units, n_res);", ); } if(!defined($default_cmp_attr)) { @@ -154,7 +158,7 @@ foreach my $class_name (keys(%reg_classes)) { # for registering additional opcodes $n_opcodes += $additional_opcodes if (defined($additional_opcodes)); -push(@obst_header, "void ".$arch."_create_opcodes(void);\n"); +push(@obst_header, "void ".$arch."_create_opcodes(const arch_irn_ops_t *be_ops);\n"); push(@obst_enum_op, "typedef enum _$arch\_opcodes {\n"); foreach my $op (keys(%nodes)) { @@ -373,12 +377,6 @@ foreach my $op (keys(%nodes)) { $temp .= "\tint n_res = ${out_arity};\n"; } - my $latency = $n{"latency"}; - if (!defined($latency)) { - $latency = 1; - } - $temp .= "\tunsigned latency = ${latency};\n"; - if (defined($known_mode)) { $temp .= "\tir_mode *mode = ${known_mode};\n"; } @@ -504,32 +502,38 @@ foreach my $op (keys(%nodes)) { die "Fatal error: Couldn't find attribute initialisation code for type '${attr_type}'"; } $temp .= "${attr_init_code}\n"; + if(defined($custom_init_attr_func)) { + $temp .= &$custom_init_attr_func(\%n, $op); + } $temp .= "\n"; # set flags for outs - if ($#out_flags >= 0) { - $temp .= "\t/* set flags for outs */\n"; - for (my $idx = 0; $idx <= $#out_flags; $idx++) { - my $flags = ""; - my $prefix = ""; - - foreach my $flag (split(/\|/, $out_flags[$idx])) { - if ($flag eq "I") { - $flags .= $prefix."arch_irn_flags_ignore"; - $prefix = " | "; + if (exists($n{"outs"})) { + undef my @outs; + @outs = @{ $n{"outs"} }; + + for (my $idx = 0; $idx <= $#outs; $idx++) { + # check, if we have additional flags annotated to out + if ($outs[$idx] =~ /:((S|I)(\|(S|I))*)/) { + my $flag_string = $1; + my $prefix = ""; + my $flags = ""; + + foreach my $flag (split(/\|/, $flag_string)) { + if ($flag eq "I") { + $flags .= $prefix."arch_irn_flags_ignore"; + $prefix = " | "; + } elsif ($flag eq "S") { + $flags .= $prefix."arch_irn_flags_modify_sp"; + $prefix = " | "; + } } - elsif ($flag eq "S") { - $flags .= $prefix."arch_irn_flags_modify_sp"; - $prefix = " | "; - } - } - $temp .= "\tset_$arch\_out_flags(res, $flags, $idx);\n"; + $temp .= "\tset_$arch\_out_flags(res, $flags, $idx);\n"; + } } - $temp .= "\n"; } - if (exists($n{"init_attr"})) { $temp .= "\tattr = get_irn_generic_attr(res);\n"; $temp .= "\t".$n{"init_attr"}."\n"; @@ -558,11 +562,19 @@ foreach my $op (keys(%nodes)) { push(@obst_new_irop, "\n\tmemset(&ops, 0, sizeof(ops));\n"); + push(@obst_new_irop, "\tops.be_ops = be_ops;\n"); push(@obst_new_irop, "\tops.dump_node = $arch\_dump_node;\n"); if (defined($cmp_attr_func)) { push(@obst_new_irop, "\tops.node_cmp_attr = ${cmp_attr_func};\n"); } + my $copy_attr_func = $copy_attr{$attr_type}; + if (!defined($copy_attr_func)) { + $copy_attr_func = $default_copy_attr; + } + if (defined($copy_attr_func)) { + push(@obst_new_irop, "\tops.copy_attr = ${copy_attr_func};\n"); + } $n_opcodes++; my $n_res = $out_arity; @@ -573,6 +585,15 @@ foreach my $op (keys(%nodes)) { $temp .= "|M, ".translate_arity($arity).", 0, sizeof(${attr_type}), &ops);\n"; 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"); + 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_enum_op, "\tiro_$op,\n"); push(@obst_header, "\n"); @@ -675,7 +696,7 @@ print OUT<ops.be_ops = be_ops; + } +ENDOFMAIN + + if(defined($default_op_attr_type)) { + print OUT "\t$default_op_attr_type *attr;\n"; + } + +print OUT<