This is the mail archive of the gcc@gcc.gnu.org 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]

RE: [RTL]Access rtx oprands


> -----Original Message-----
> From: gcc-owner On Behalf Of ? ?
> Sent: 25 June 2004 21:45

> Suppose an rtx variable insn points to a call_insn rtx, and 
> this rtx dumped with "gcc -dr ..." looks like
> (call_insn 12 11 8 (call (mem:QI (symbol_ref:SI ("my_fun")) [0 S1 A8])
>         (const_int 16 [0x10])) -1 (nil)
>     (expr_list:REG_EH_REGION (const_int 0 [0x0])
>         (nil))
>     (nil))
> How could I get the symbol_ref "my_fun" as an string?
> 
> I read some gcc source codes and patched gcc with the 
> following statements:
>     if(GET_CODE(insn) == CALL_INSN)
>       if(GET_CODE(XEXP(insn, 5)) == CALL)
>         if(GET_CODE(XEXP(XEXP(insn, 5), 0)) == MEM)
>           if(GET_CODE(XEXP(XEXP(XEXP(insn, 5), 0), 0)) == SYMBOL_REF)
>            //      const char *name = "ok";
>             const char *name = XSTR(XEXP(XEXP(XEXP(insn, 5), 
> 0), 0), 0);    
> 
> I got an segment fault error when compiling GCC, but if I 
> replace the evaluate statement with the commented one, then GCC
> is successfully built and the patched GCC works well.
> 
> There are some similar usages of XEXP and XSTR in GCC source, 
> I wonder why this one doesn't work?
> If my method of getting the routine name in an call_insn is 
> wrong, please tell me how to get that.

  Those three numbers are the UIDs in the insn chain, not operands, and I'm
still not quite sure how you counted 5.  You want to access XEXP (insn, 0)
to get at the call rtx; trying to access XEXP (insn, 5) will get you an
undefined pointer.


    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


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