This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[RTL]Access rtx oprands
- From: 王 逸 <cnnjuwy at hotmail dot com>
- To: <gcc at gcc dot gnu dot org>
- Date: Sat, 26 Jun 2004 04:12:04 +0800
- Subject: [RTL]Access rtx oprands
Hi, all!
I've a question about accessing the GCC rtx oprands.
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.
Thanks for your concerning!
Wang Yi