We are interested in extracting the type of a tree node that appears
within MEM_REF.
Given a C program:
struct node * * pvar;
struct node qvar;
pvar = (struct node * *) malloc (sizeof (struct node *));
*pvar = &qvar;
It is transformed into the following GIMPLE code:
void * * pvar.1;
void * pvar.0;
pvar.0_1 = malloc (4);
pvar = pvar.0_1;
MEM[(struct node * *)pvar.0_1] = &qvar;
We wish to discover the type of the argument of MEM[...] in the last
GIMPLE statement. We can see from the GIMPLE dump that the argument's
type is "struct node * *". How do we extract this from the tree
definition of MEM[...]?
We speculate the following solution: Given a variable var (whose tree is
tree_of_var) and a tree, say t,
if (TREE_CODE(t) is MEM_REF) and (TREE_OPERAND(t, 0) is tree_of_var)
then
the type of the expression inside MEM[...] of tree t is
POINTER_TYPE to TREE_TYPE(t).
Is is correct? It is general enough?
Thanks and regards,
Uday.
------------------------------------------------------------------------
Dr. Uday Khedker, Professor
Department of Computer Science & Engg.
IIT Bombay, Powai, Mumbai 400 076, India.
Email : u...@cse.iitb.ac.in
Homepage: http://www.cse.iitb.ac.in/~uday
Phone : 91 (22) 2572 2545 x 7717, 91 (22) 2576 7717 (Direct)