This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Creating parameters for functions calls
- From: Antoine Eiche <antoine dot eiche at ulp dot u-strasbg dot fr>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 27 Mar 2007 19:28:43 +0200
- Subject: Creating parameters for functions calls
Dear all,
I want to insert functions calls during a new pass. The problem is to
create parameters. At this time, I successfully create a function call
with two constante as parameter and insert it (I can see that in the
asm's code). But, I want to give the address of an array and a constante
to this function.
I think the problem is the creation of the node which contains the
address of the array.
For example:
I get from the code (in tree "rhs"):
a[i]
I want build a node like that:
&a[i]
and build a function call like that:
foo(constante,&a[i])
This is the error message when a try to compile a program with my pass :
tab.c: In function 'main':
tab.c:7: erreur interne du compilateur: dans lookup_subvars_for_var, à
tree-flow-inline.h:1629
This is an extract what I do in my pass:
tree new_rhs =
build4(TREE_CODE(rhs), TREE_TYPE(rhs),
TREE_OPERAND (rhs, 0)?copy_list (TREE_OPERAND (rhs,
0)):NULL_TREE,
TREE_OPERAND (rhs, 1)?copy_list (TREE_OPERAND (rhs,
1)):NULL_TREE,
TREE_OPERAND (rhs, 2)?copy_list (TREE_OPERAND (rhs,
2)):NULL_TREE,
TREE_OPERAND (rhs, 3)?copy_list (TREE_OPERAND (rhs,
3)):NULL_TREE);
tree param = build1 (ADDR_EXPR,
build_pointer_type (TREE_TYPE
(rhs)),
rhs);
tree compteur = build_int_cst (integer_type_node, 1 );
tree args = tree_cons(NULL_TREE,compteur,
tree_cons(NULL_TREE,
param,
NULL_TREE));
tree call_type = build_function_type_list (void_type_node,
integer_type_node,
ptr_type_node,
NULL_TREE);
tree call_fn = build_fn_decl ("foo",call_type);
tree call = build_function_call_expr (call_fn, args);
block_stmt_iterator bsi;
bsi = bsi_for_stmt (stmt);
bsi_insert_before (&bsi, call, BSI_SAME_STMT);
mark_symbols_for_renaming(call);
I put that debug_tree() says:
***Debug_KG: Nom de l'arbre: rhs
<array_ref 0xb7bd9d70
type <integer_type 0xb7be32d8 int sizes-gimplified public SI
size <integer_cst 0xb7bd2348 constant invariant 32>
unit size <integer_cst 0xb7bd2180 constant invariant 4>
align 32 symtab 0 alias set -1 canonical type 0xb7be32d8
precision 32 min <integer_cst 0xb7bd2300 -2147483648> max <integer_cst
0xb7bd2318 2147483647>
pointer_to_this <pointer_type 0xb7bea680>>
arg 0 <var_decl 0xb7ca72c0 AAAA
type <array_type 0xb7ca2680 type <integer_type 0xb7be32d8 int>
sizes-gimplified BLK
size <integer_cst 0xb7ca53c0 constant invariant 320000>
unit size <integer_cst 0xb7ca53d8 constant invariant 40000>
align 32 symtab 0 alias set -1 canonical type 0xb7ca2680
domain <integer_type 0xb7ca2618>
pointer_to_this <pointer_type 0xb7ca2c30>>
addressable used BLK file tab.c line 10 size <integer_cst
0xb7ca53c0 320000> unit size <integer_cst 0xb7ca53d8 40000>
align 32 context <function_decl 0xb7c9be00 main>
chain <var_decl 0xb7ca7318 BBBB type <array_type 0xb7ca2680>
used BLK file tab.c line 11 size <integer_cst 0xb7ca53c0
320000> unit size <integer_cst 0xb7ca53d8 40000>
align 32 context <function_decl 0xb7c9be00 main> chain
<var_decl 0xb7ca7370 CCCC>>>
arg 1 <ssa_name 0xb7caf450 type <integer_type 0xb7be32d8 int>
visited var <var_decl 0xb7ca7210 j> def_stmt <phi_node 0xb7cac8c0>
version 50>>
***Debug_KG: Nom de l'arbre: new_rhs
<array_ref 0xb7cab9b0
type <integer_type 0xb7be32d8 int sizes-gimplified public SI
size <integer_cst 0xb7bd2348 constant invariant 32>
unit size <integer_cst 0xb7bd2180 constant invariant 4>
align 32 symtab 0 alias set -1 canonical type 0xb7be32d8
precision 32 min <integer_cst 0xb7bd2300 -2147483648> max <integer_cst
0xb7bd2318 2147483647>
pointer_to_this <pointer_type 0xb7bea680>>
arg 0 <var_decl 0xb7cb6160 AAAA
type <array_type 0xb7ca2680 type <integer_type 0xb7be32d8 int>
sizes-gimplified BLK
size <integer_cst 0xb7ca53c0 constant invariant 320000>
unit size <integer_cst 0xb7ca53d8 constant invariant 40000>
align 32 symtab 0 alias set -1 canonical type 0xb7ca2680
domain <integer_type 0xb7ca2618>
pointer_to_this <pointer_type 0xb7ca2c30>>
addressable used BLK file tab.c line 10 size <integer_cst
0xb7ca53c0 320000> unit size <integer_cst 0xb7ca53d8 40000>
align 32 context <function_decl 0xb7c9be00 main>
chain <var_decl 0xb7cb61b8 BBBB type <array_type 0xb7ca2680>
used BLK file tab.c line 11 size <integer_cst 0xb7ca53c0
320000> unit size <integer_cst 0xb7ca53d8 40000>
align 32 context <function_decl 0xb7c9be00 main> chain
<var_decl 0xb7cb6210 CCCC>>>
arg 1 <ssa_name 0xb7cafb40 type <integer_type 0xb7be32d8 int>
var <var_decl 0xb7ca7210 j> def_stmt <phi_node 0xb7cacc40>
version 50>>
***Debug_KG: Nom de l'arbre: param
<addr_expr 0xb7cb4bb4
type <integer_type 0xb7be32d8 int sizes-gimplified public SI
size <integer_cst 0xb7bd2348 constant invariant 32>
unit size <integer_cst 0xb7bd2180 constant invariant 4>
align 32 symtab 0 alias set -1 canonical type 0xb7be32d8
precision 32 min <integer_cst 0xb7bd2300 -2147483648> max <integer_cst
0xb7bd2318 2147483647>
pointer_to_this <pointer_type 0xb7bea680>>
arg 0 <array_ref 0xb7cab9b0 type <integer_type 0xb7be32d8 int>
arg 0 <var_decl 0xb7cb6160 AAAA type <array_type 0xb7ca2680>
addressable used BLK file tab.c line 10
size <integer_cst 0xb7ca53c0 constant invariant 320000>
unit size <integer_cst 0xb7ca53d8 constant invariant 40000>
align 32 context <function_decl 0xb7c9be00 main> chain
<var_decl 0xb7cb61b8 BBBB>>
arg 1 <ssa_name 0xb7cafb40 type <integer_type 0xb7be32d8 int>
var <var_decl 0xb7ca7210 j> def_stmt <phi_node 0xb7cacc40>
version 50>>>
***Debug_KG: Nom de l'arbre: compteur
<integer_cst 0xb7bd2858 type <integer_type 0xb7be32d8 int> constant
invariant 0>
***Debug_KG: Nom de l'arbre: args
<tree_list 0xb7cb1fd8
value <addr_expr 0xb7cb4bd0
type <integer_type 0xb7be32d8 int sizes-gimplified public SI
size <integer_cst 0xb7bd2348 constant invariant 32>
unit size <integer_cst 0xb7bd2180 constant invariant 4>
align 32 symtab 0 alias set -1 canonical type 0xb7be32d8
precision 32 min <integer_cst 0xb7bd2300 -2147483648> max <integer_cst
0xb7bd2318 2147483647>
pointer_to_this <pointer_type 0xb7bea680>>
arg 0 <array_ref 0xb7cab9b0 type <integer_type 0xb7be32d8 int>
arg 0 <var_decl 0xb7cb6160 AAAA>
arg 1 <ssa_name 0xb7cafb40 type <integer_type 0xb7be32d8 int>
var <var_decl 0xb7ca7210 j> def_stmt <phi_node 0xb7cacc40>
version 50>>>
chain <tree_list 0xb7cb1fc0
value <integer_cst 0xb7bd2858 constant invariant 0>
chain <tree_list 0xb7cb1fa8
value <integer_cst 0xb7bd28d0 constant invariant 0>>>>
Does the parameter' s construction correct?
Thanks for any help in finishing this pass,
Antoine