This is the mail archive of the
mailing list for the GCC project.
Re: Generating gimple code with gimple_build_assign
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Steve Ellcey <sellcey at imgtec dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Tue, 7 Apr 2015 10:31:09 +0200
- Subject: Re: Generating gimple code with gimple_build_assign
- Authentication-results: sourceware.org; auth=none
- References: <81903561-d468-4dbc-925a-b321bee3e7e2 at BAMAIL02 dot ba dot imgtec dot org>
On Mon, Apr 6, 2015 at 7:29 PM, Steve Ellcey <firstname.lastname@example.org> 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);
> 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));
> Steve Ellcey