This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Expression with 2 operations


Dear all,

I must calculate the address of an element's array.
If the size of an element is one integer it's good.
I do like that:
new_rhs=fold_build2(PLUS_EXPR,TREE_TYPE(TREE_OPERAND(rhs,1)),
build1(ADDR_EXPR, build_pointer_type (TREE_TYPE (array)),array),
index);


But, if the type of an element is not one integer, I must multiply the index by the size of an element.
I try to do like that :
tree decalage=fold_build2(MULT_EXPR,TREE_TYPE(index),
index,
compteur);
new_rhs=fold_build2(PLUS_EXPR,TREE_TYPE(TREE_OPERAND(rhs,1)),
build1(ADDR_EXPR, build_pointer_type (TREE_TYPE (array)),array),
decalage);


new_rhs is a futur parameter of a function call.

When a try to compile a program gcc answer:
"
tab.c:22: erreur: invalid operand to binary operator
i_28 * 4;

tab.c:22: erreur interne du compilateur: verify_stmts failed
"

i_28 is index
4 is compteur

How can I do that ?

Thanks in advance.
Antoine



This is the debug_tree() of new_rhs :
<plus_expr 0x403f6520
type <integer_type 0x403532d8 int sizes-gimplified public SI
size <integer_cst 0x40342348 constant invariant 32>
unit size <integer_cst 0x40342180 constant invariant 4>
align 32 symtab 0 alias set 3 canonical type 0x403532d8 precision 32 min <integer_cst 0x40342300 -2147483648> max <integer_cst 0x40342318 2147483647>
pointer_to_this <pointer_type 0x4035a680>>
arg 0 <mult_expr 0x403f6500 type <integer_type 0x403532d8 int>
arg 0 <ssa_name 0x403ead20 type <integer_type 0x403532d8 int>
visited var <var_decl 0x4034e318 i> def_stmt <phi_node 0x403e79a0>
version 28>
arg 1 <integer_cst 0x40362df8 constant invariant 4>>
arg 1 <addr_expr 0x403f1a2c
type <pointer_type 0x403e38f0 type <array_type 0x403d8f70>
unsigned SI size <integer_cst 0x40342348 32> unit size <integer_cst 0x40342180 4>
align 32 symtab 0 alias set -1 canonical type 0x403e38f0>
constant invariant
arg 0 <var_decl 0x4034e0b0 AAAA type <array_type 0x403d8f70>
addressable used public static common BLK file tab.c line 7
size <integer_cst 0x40342b58 constant invariant 320>
unit size <integer_cst 0x403e1198 constant invariant 40>
align 256
(mem/s/c:BLK (symbol_ref:SI ("AAAA") <var_decl 0x4034e0b0 AAAA>) [2 AAAA+0 S40 A256]) chain <var_decl 0x4034e108 BBBB>>>>





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]