On Tue, 2014-08-12 at 15:20 -0600, Jeff Law wrote: > On 08/06/14 11:19, David Malcolm wrote: > > Yet more scaffolding: convert the NEXT_INSN/PREV_INSN macros > > and their SET_* variants into functions. > > > > Convert the rvalue-style functions into returning > > rtx_insn * rather than plain rtx. > > > > For now, this is done by adding a checked cast, but I hope this can > > eventually become a field lookup. The lvalue forms for now return an rtx& > > to allow in-place modification. > > > > gcc/ > > * rtl.h (PREV_INSN): Convert to an inline function. Strengthen > > the return type from rtx to rtx_insn *, which will enable various > > conversions in followup patches. For now this is is done by a > > checked cast. > > (NEXT_INSN): Likewise. > > (SET_PREV_INSN): Convert to an inilne function. This is intended > > for use as an lvalue, and so returns an rtx& to allow in-place > > modification. > > (SET_NEXT_INSN): Likewise. > OK.
Thanks Fixed up the as_a_nullable to safe_as_a, and committed to trunk as r214152, having verified bootstrap®rtest on x86_64-unknown-linux-gnu (Fedora 20) albeit in combination with patches 9-29 [1], and verified that it builds standalone. Am attaching what I committed. Should I add a blanket skip for rtl.h to gdbinit.in, or special-case the individual inline functions> > FWIW, I do think that after this series is done that we should look very > closely at moving those fields out of the rtunion array and just have > them first class fields in their classes. > > I can see a day where I say foo->uid or foo->next/prev and be > exceedingly happy. And if we keep "rtx_real_insn" as a concept, then > foo.pattern ;-) (nods) [1] as per https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01420.html
Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 214151) +++ gcc/ChangeLog (revision 214152) @@ -1,3 +1,15 @@ +2014-08-19 David Malcolm <dmalc...@redhat.com> + + * rtl.h (PREV_INSN): Convert to an inline function. Strengthen + the return type from rtx to rtx_insn *, which will enable various + conversions in followup patches. For now this is is done by a + checked cast. + (NEXT_INSN): Likewise. + (SET_PREV_INSN): Convert to an inline function. This is intended + for use as an lvalue, and so returns an rtx& to allow in-place + modification. + (SET_NEXT_INSN): Likewise. + 2014-07-08 Mark Wielaard <m...@redhat.com> PR debug/59051 Index: gcc/rtl.h =================================================================== --- gcc/rtl.h (revision 214151) +++ gcc/rtl.h (revision 214152) @@ -972,16 +972,34 @@ (RTL_INSN_CHAIN_FLAG_CHECK ("INSN_UID", (INSN))->u2.insn_uid) /* Chain insns together in sequence. */ + /* For now these are split in two: an rvalue form: PREV_INSN/NEXT_INSN and an lvalue form: SET_NEXT_INSN/SET_PREV_INSN. */ -#define PREV_INSN(INSN) XEXP ((const_rtx)(INSN), 0) -#define SET_PREV_INSN(INSN) XEXP (INSN, 0) -#define NEXT_INSN(INSN) XEXP ((const_rtx)(INSN), 1) -#define SET_NEXT_INSN(INSN) XEXP (INSN, 1) +inline rtx_insn *PREV_INSN (const_rtx insn) +{ + rtx prev = XEXP (insn, 0); + return safe_as_a <rtx_insn *> (prev); +} +inline rtx& SET_PREV_INSN (rtx insn) +{ + return XEXP (insn, 0); +} + +inline rtx_insn *NEXT_INSN (const_rtx insn) +{ + rtx next = XEXP (insn, 1); + return safe_as_a <rtx_insn *> (next); +} + +inline rtx& SET_NEXT_INSN (rtx insn) +{ + return XEXP (insn, 1); +} + #define BLOCK_FOR_INSN(INSN) XBBDEF (INSN, 2) /* The body of an insn. */