From: Christian Würdig Date: Wed, 2 Nov 2005 14:33:59 +0000 (+0000) Subject: added generation of missing function prototypes X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=64e61397cbe0fb0c91ba999a321fe90629243d04;p=libfirm added generation of missing function prototypes made several key in node spec optional (args, rd_constructor, op_flags, state) create only new_rd_ functions (no _r and _d wrapper anymore) added several set and get attribute functions --- diff --git a/ir/be/scripts/generate_new_opcodes.pl b/ir/be/scripts/generate_new_opcodes.pl index d0125306d..9eeea8538 100755 --- a/ir/be/scripts/generate_new_opcodes.pl +++ b/ir/be/scripts/generate_new_opcodes.pl @@ -59,6 +59,8 @@ foreach my $op (keys(%nodes)) { push(@obst_get_opvar, "ir_op *get_op_$op(void) { return op_$op; }\n"); push(@obst_get_opvar, "int is_$op(ir_node *n) { return get_irn_op(n) == op_$op ? 1 : 0; }\n\n"); + push(@obst_header, "int is_$op(ir_node *n);\n"); + $n{"comment"} =~ s/^"|"$//g; $n{"comment"} = "/* ".$n{"comment"}." */\n"; push(@obst_constructor, $n{"comment"}); @@ -67,7 +69,7 @@ foreach my $op (keys(%nodes)) { my $complete_args = ""; my $arg_names = ""; $temp = "ir_node *new_rd_$op(dbg_info *db, ir_graph *irg, ir_node *block"; - if ($n{"args"} eq "DEFAULT") { # default args + if (!exists($n{"args"}) || $n{"args"} eq "DEFAULT") { # default args if ($n{"arity"} !~ /^[0-3]$/) { print "DEFAULT args require arity 0,1,2 or 3! Ignoring op $orig_op!\n"; next; @@ -91,7 +93,7 @@ foreach my $op (keys(%nodes)) { push(@obst_header, $temp.";\n"); # emit constructor code - if ($n{"rd_constructor"} eq "DEFAULT") { # default constructor + if (!exists($n{"rd_constructor"}) || $n{"rd_constructor"} eq "DEFAULT") { # default constructor if ($n{"arity"} !~ /^[0-3]$/) { print "DEFAULT rd_constructor requires arity 0,1,2 or 3! Ignoring op $orig_op!\n"; next; @@ -120,29 +122,34 @@ foreach my $op (keys(%nodes)) { # close constructor function push(@obst_constructor, "}\n\n"); - # create the _r and _d wrapper - $temp = "ir_node *new_r_$op(ir_graph *irg, ir_node *block, $complete_args)"; - push(@obst_header, $temp.";\n"); - $temp .= " {\n"; - $temp .= " return new_rd_$op(NULL, irg, block".$arg_names.");\n"; - $temp .= "}\n\n"; - push(@obst_constructor, $temp); +# # create the _r and _d wrapper +# $temp = "ir_node *new_r_$op(ir_graph *irg, ir_node *block, $complete_args)"; +# push(@obst_header, $temp.";\n"); +# $temp .= " {\n"; +# $temp .= " return new_rd_$op(NULL, irg, block".$arg_names.");\n"; +# $temp .= "}\n\n"; +# push(@obst_constructor, $temp); +# +# $temp = "ir_node *new_d_$op(dbg_info *db, $complete_args)"; +# push(@obst_header, $temp.";\n"); +# $temp .= " {\n"; +# $temp .= " return new_rd_$op(db, current_ir_graph, current_ir_graph->current_block".$arg_names.");\n"; +# $temp .= "}\n\n"; +# push(@obst_constructor, $temp); +# +# $temp = "ir_node *new_$op($complete_args)"; +# push(@obst_header, $temp.";\n"); +# $temp .= " {\n"; +# $temp .= " return new_d_$op(NULL".$arg_names.");\n"; +# $temp .= "}\n\n"; +# push(@obst_constructor, $temp); - $temp = "ir_node *new_d_$op(dbg_info *db, $complete_args)"; - push(@obst_header, $temp.";\n"); - $temp .= " {\n"; - $temp .= " return new_rd_$op(db, current_ir_graph, current_ir_graph->current_block".$arg_names.");\n"; - $temp .= "}\n\n"; - push(@obst_constructor, $temp); + # construct the new_ir_op calls - $temp = "ir_node *new_$op($complete_args)"; - push(@obst_header, $temp.";\n"); - $temp .= " {\n"; - $temp .= " return new_d_$op(NULL".$arg_names.");\n"; - $temp .= "}\n\n"; - push(@obst_constructor, $temp); + # set default values for state and flags if not given + $n{"state"} = "pinned" if (! exists($n{"state"})); + $n{"op_flags"} = "N" if (! exists($n{"op_flags"})); - # construct the new_ir_op calls my $arity_str = $arity == 0 ? "zero" : ($arity == 1 ? "unary" : ($arity == 2 ? "binary" : ($arity == 3 ? "trinary" : $arity))); $temp = " op_$op = new_ir_op(get_next_ir_opcode(), \"$op\", op_pin_state_".$n{"state"}.", ".$n{"op_flags"}; $temp .= ", oparity_".$arity_str.", 0, sizeof(asmop_attr), &ops);\n"; @@ -180,13 +187,68 @@ print OUT<tv; + if (attr->tp == asmop_Const) + return attr->data.tv; + else + return NULL; +} + +/** + * Copy the attributes from an Imm to an Immop (Add_i, Sub_i, ...) node + */ +void set_Immop_attr(ir_node *node, ir_node *imm) { + asmop_attr *attr = (asmop_attr *)get_irn_generic_attr(node); + assert(is_Imm(imm) && "Need Imm to set Immop attr"); + + imm_attr_t *ia = (imm_attr_t *)get_irn_generic_attr(imm); + if (ia->tp == imm_Const) { + attr->tp = asmop_Const; + attr->data.tv = ia->data.tv; + } + else { + attr->tp = asmop_SymConst; + attr->data.symconst = ia->data.symconst; + } +} + +/** + * Sets the attributes of an immediate operation to the specified tarval + */ +void set_Immop_attr_tv(ir_node *node, tarval *tv) { + asmop_attr *attr = (asmop_attr *)get_irn_generic_attr(node); + + attr->tp = asmop_Const; + attr->data.tv = tv; +} + +/** + * Sets the offset for a Lea. + */ +void set_ia32_Lea_offs(ir_node *node, tarval *offs) { + assert(is_ia32_Lea(node) && "Cannot set offset in non-Lea node."); + + asmop_attr *attr = (asmop_attr *)get_irn_generic_attr(node); + attr->data.offset = offs; +} + +/** + * Gets the offset for a Lea. + */ +tarval *get_ia32_Lea_offs(ir_node *node) { + assert(is_ia32_Lea(node) && "Cannot get offset for a non-Lea node."); + + asmop_attr *attr = (asmop_attr *)get_irn_generic_attr(node); + return attr->data.offset; } ENDOFHEADER @@ -243,6 +305,10 @@ print OUT<