[Generic] CALL_EXPR tree code with object ref

Ian Lance Taylor iant@google.com
Thu Nov 4 18:49:00 GMT 2010


charfi asma <charfiasma@yahoo.fr> writes:

> 1. I tried to follow the cp front end, but I get errors related to GTY.

What errors?

> I tried to include class.c, call.c or method.c to reuse the defined functions 
> like build_this_parm to add the param "this" to the call_exp, because when I 
> look at the gimple generated from the c++ call I find that I have to add "this" 
> to the 
>
> function decl and add it also to the call_expr (&c)

You for sure can't literally include class.c or any other C++ file.  You
need to read and understand what the code is doing, and write a version
of the code appropriate for your scenario.  For something like this,
think of GIMPLE as a simple programming language, and think about what
you want the code to look like.

> 2. I tried also to use the tree code defined in tree.def like COMPONENT_REF (but 
>
> it is only used for FIELD_DECL and not TYPE_METHOD of a RECORD_TYPE)

It does not make sense to use a COMPONENT_REF on a TYPE_METHOD.  A
COMPONENT_REF is referring to a field in a struct, like "s.f".

You are getting hung up on the fact that RECORD_TYPE has a TYPE_METHODS
field.  I'm trying to tell you that the TYPE_METHODS field means nothing
to the middle-end.  It's there for the use of the frontend.  You need to
ignore TYPE_METHODS, and focus on what the code you want to generate.

> 3. I tried to use OBJ_TYPE_REF tree code defined in tree.def to get the ref to 
> an object but I can not find a build_obj_type_ref in the tree.c  to use it (just 
>
> like build_call_exp ).

To build an OBJ_TYPE_REF just use build3.  See the C++ frontend for
examples.  But OBJ_TYPE_REF won't help you because the very first
parameter is the expression it is supposed to evaluate.  You need to
figure out how to write that expression for your language.

Ian



More information about the Gcc-help mailing list