This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Typecasting information in MEM[...] GIMPLE

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)
        the type of the expression inside MEM[...] of tree t is

Is is correct? It is general enough?

Thanks and regards,


Dr. Uday Khedker, Professor
Department of Computer Science & Engg.
IIT Bombay, Powai, Mumbai 400 076, India. 	
Email :
Phone : 	  91 (22) 2572 2545 x 7717, 91 (22) 2576 7717 (Direct)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]