How could I cast the return type of a function created by gimple_build_call?
Richard Guenther
richard.guenther@gmail.com
Thu Dec 8 12:35:00 GMT 2011
On Thu, Dec 8, 2011 at 1:26 PM, Martin Jambor <mjambor@suse.cz> wrote:
> Hi,
>
> On Thu, Dec 08, 2011 at 10:38:24AM +0100, Feng LI wrote:
>> Hi,
>>
>> I'm building a function with
>> fread = build_decl (LOCATION, FUNCTION_DECL, get_identifier (name), type);
>>
>> and then use it in gimple with
>> gimple gfread = gimple_build_call (fread, 1, offset);
>> gimple_call_set_lhs (fread, lhs);
>>
>> But I need a cast here, since the lhs has a different type than the return value
>> of the function fread. So I suppose that I need a cast here to cast from the
>> return type of fread -> type_of (lhs). But I've no idea how could I
>> achieve this?
>> Any suggestions?
>
> You need to store the result into a temporary and then add a
> VIEW_CONVERT_EXPR gimple assignment statement after the statement to
> convert to the necessary type. Grep *.c files for
> 'build.*VIEW_CONVERT_EXPR' and you should be able to find some example
> to follow in your own code.
A traditional cast is a NOP_EXPR. If you really need a
VIEW_CONVERT_EXPR then this is more like a *(T' *)&t
operation.
Richard.
> Martin
More information about the Gcc
mailing list