This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [RTL]Access rtx oprands
- From: 王 逸 <cnnjuwy at hotmail dot com>
- To: "Dave Korn" <dk at artimi dot com>,<gcc at gcc dot gnu dot org>
- Date: Sun, 27 Jun 2004 04:24:36 +0800
- Subject: Re: [RTL]Access rtx oprands
- References: <NUTMEGlwRhD54wG8nls000004e9@NUTMEG.CAM.ARTIMI.COM>
In gcc/rtl.h:
/* Holds a unique number for each insn.
These are not necessarily sequentially increasing. */
#define INSN_UID(INSN) XINT (INSN, 0)
/* Chain insns together in sequence. */
#define PREV_INSN(INSN) XEXP (INSN, 1)
#define NEXT_INSN(INSN) XEXP (INSN, 2)
#define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 3)
#define INSN_LOCATOR(INSN) XINT (INSN, 4)
/* The body of an insn. */
#define PATTERN(INSN) XEXP (INSN, 5)
So I think XEXP(insn, 0) gets the insn_uid while XEXP(insn, 5) gets the call rtx in a call_insn, this right?
The if conditions listed in my original message were all true, just the last evaluate statement got a segment fault, while compiling GCC.
I'm confused why
(GET_CODE(insn) == SYMBOL_REF)
is true, but
const char *name = XSTR(insn, 0)
araised a segment fault?
thanks
WangYi
----- Original Message -----
From: "Dave Korn" <dk@artimi.com>
To: "'王 逸'" <cnnjuwy@hotmail.com>; <gcc@gcc.gnu.org>
Sent: Wednesday, June 23, 2004 5:49 PM
Subject: 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....
>
>