Generating gimple code with gimple_build_assign
Richard Biener
richard.guenther@gmail.com
Tue Apr 7 14:45:00 GMT 2015
On Mon, Apr 6, 2015 at 7:29 PM, Steve Ellcey <sellcey@imgtec.com> wrote:
> I have a simple gimple question. I am trying to introduce an array
> into a gimple stream and create a pointer to that array.
>
> I can create the array with:
>
> array_type = build_array_type_nelts (char_type_node, 256);
> array_var = create_tmp_var (array_type, "spill");
>
> I can create a pointer to an array with:
>
> ptr_type = build_pointer_type (array_type);
> ptr_var = create_tmp_var (ptr_type, "spill");
>
> But if I try to create an assignment to get the pointer to point to
> the array I get a verify_gimple error.
>
> I have tried:
>
> stmt = gimple_build_assign (ptr_var, array_var);
> and
> stmt = gimple_build_assign (ptr_var, ADDR_EXPR, array_var);
>
> but neither of those work. I also tried making the pointer be a
> pointer to char instead of a pointer to array of char but that didn't
> seem to work either. Can someone help me with the magic formula to
> generate gimple code that causes ptr_var to point to array_var?
> Is ADDR_EXPR the right way to get the address of the array instead of
> the value in a gimple_build_assign call?
ADDR_EXPR is one of the "single-rhs" tree codes so you need to build
a GENERIC expression here:
stmt = gimple_build_assing (ptr_var, build_fold_addr_expr (array_var));
Richard.
>
> Steve Ellcey
> sellcey@imgtec.com
More information about the Gcc
mailing list