This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: extract register input, output and operator from rtl right before peepholes
- From: Ian Lance Taylor <ian at airs dot com>
- To: Liu Haibin <liu dot haibin at gmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 29 Dec 2005 11:14:14 -0800
- Subject: Re: extract register input, output and operator from rtl right before peepholes
- References: <e538aa3e0512290621ld460ac1g4b7ba7df2fa3a39b@mail.gmail.com>
Liu Haibin <liu.haibin@gmail.com> writes:
> I'd doing some coding right before peephole2 pass. I'd like to have a
> function that takes rtl as input and returns the values of register
> inputs, register output and operator. For example,
>
> input:
> (insn 496 34 29 1 (set (reg/f:SI 3 r3 [235])
> (plus:SI (reg/f:SI 3 r3 [235])
> (const_int 4 [0x4]))) 20 {addsi3} (insn_list:REG_DEP_ANTI 28 (nil))
> (nil))
> returns:
> inputs: r3, 4. ouput r3. operator: plus.
>
> I know sched_analyze() in sched-deps.c builds the dependencies in
> basic blocks and hope I can find some useful functions there. I
> roughly went through the code and didn't really understand.
>
> Because the rtl's are right before peephole2, they're much processed,
> which makes things easier. I hope I can find some existing function to
> use instead of using something like REGNO(XEXP(SET_SRC(PATTERN(x)),
> 0)). I believe sched-deps.c has something useful. Can someone help on
> this?
You can't pull out a single operator in the general case, since there
can be more than one. For an obvious example, consider a multiply/add
instruction.
You can iterate over all the subexpressions by using for_each_rtx on
the PATTERN of the insn.
Ian