How could I cast the return type of a function created by gimple_build_call?

Martin Jambor mjambor@suse.cz
Thu Dec 8 12:27:00 GMT 2011


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.

Martin 



More information about the Gcc mailing list