From 70e7f57d3867e00cd67ea1f3dc49824a1d2da794 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Mon, 18 Aug 2014 20:25:45 +0000 Subject: [PATCH] New function: for_each_rtx_in_insn gcc/ 2014-08-18 David Malcolm * rtl.h (for_each_rtx_in_insn): New function. * rtlanal.c (for_each_rtx_in_insn): Likewise. From-SVN: r214119 --- gcc/ChangeLog | 5 +++++ gcc/rtl.h | 1 + gcc/rtlanal.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f6454db..931a95f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,10 @@ 2014-08-18 David Malcolm + * rtl.h (for_each_rtx_in_insn): New function. + * rtlanal.c (for_each_rtx_in_insn): Likewise. + +2014-08-18 David Malcolm + * coretypes.h (class rtx_insn): Add forward declaration. * rtl.h: Include is-a.h. diff --git a/gcc/rtl.h b/gcc/rtl.h index 28f598e..3c6e9a3 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -2399,6 +2399,7 @@ extern bool tls_referenced_p (rtx); typedef int (*rtx_function) (rtx *, void *); extern int for_each_rtx (rtx *, rtx_function, void *); +extern int for_each_rtx_in_insn (rtx_insn **, rtx_function, void *); /* Callback for for_each_inc_dec, to process the autoinc operation OP within MEM that sets DEST to SRC + SRCOFF, or SRC if SRCOFF is diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 3196e55..0e8cb44 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -3011,6 +3011,22 @@ for_each_rtx (rtx *x, rtx_function f, void *data) return for_each_rtx_1 (*x, i, f, data); } +/* Like "for_each_rtx", but for calling on an rtx_insn **. */ + +int +for_each_rtx_in_insn (rtx_insn **insn, rtx_function f, void *data) +{ + rtx insn_as_rtx = *insn; + int result; + + result = for_each_rtx (&insn_as_rtx, f, data); + + if (insn_as_rtx != *insn) + *insn = safe_as_a (insn_as_rtx); + + return result; +} + /* Data structure that holds the internal state communicated between -- 2.7.4