* [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data
@ 2014-10-25 9:54 Richard Sandiford
2014-10-25 9:56 ` Richard Sandiford
2014-11-02 18:33 ` Joern Rennecke
0 siblings, 2 replies; 3+ messages in thread
From: Richard Sandiford @ 2014-10-25 9:54 UTC (permalink / raw)
To: gcc-patches; +Cc: joern.rennecke
This is part of a series to remove uses of for_each_rtx from the ports.
As with the first FR-V patch, we can find_all_hard_regs instead.
Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
and g++.dg for arc-elf. OK to install?
Thanks,
Richard
gcc/
* config/arc/arc.c: Include rtl-iter.h.
(arc_rewrite_small_data_1): Delete.
(arc_rewrite_small_data): Use FOR_EACH_SUBRTX_PTR.
Index: gcc/config/arc/arc.c
===================================================================
--- gcc/config/arc/arc.c 2014-10-25 09:40:38.176518180 +0100
+++ gcc/config/arc/arc.c 2014-10-25 09:51:25.501884042 +0100
@@ -72,6 +72,7 @@ the Free Software Foundation; either ver
#include "pass_manager.h"
#include "wide-int.h"
#include "builtins.h"
+#include "rtl-iter.h"
/* Which cpu we're compiling for (A5, ARC600, ARC601, ARC700). */
static const char *arc_cpu_string = "";
@@ -6351,38 +6352,6 @@ arc_rewrite_small_data_p (rtx x)
&& SYMBOL_REF_SMALL_P(x));
}
-/* A for_each_rtx callback, used by arc_rewrite_small_data. */
-
-static int
-arc_rewrite_small_data_1 (rtx *loc, void *data)
-{
- if (arc_rewrite_small_data_p (*loc))
- {
- rtx top;
-
- gcc_assert (SDATA_BASE_REGNUM == PIC_OFFSET_TABLE_REGNUM);
- *loc = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, *loc);
- if (loc == data)
- return -1;
- top = *(rtx*) data;
- if (GET_CODE (top) == MEM && &XEXP (top, 0) == loc)
- ; /* OK. */
- else if (GET_CODE (top) == MEM
- && GET_CODE (XEXP (top, 0)) == PLUS
- && GET_CODE (XEXP (XEXP (top, 0), 0)) == MULT)
- *loc = force_reg (Pmode, *loc);
- else
- gcc_unreachable ();
- return -1;
- }
-
- if (GET_CODE (*loc) == PLUS
- && rtx_equal_p (XEXP (*loc, 0), pic_offset_table_rtx))
- return -1;
-
- return 0;
-}
-
/* If possible, rewrite OP so that it refers to small data using
explicit relocations. */
@@ -6390,7 +6359,31 @@ arc_rewrite_small_data_1 (rtx *loc, void
arc_rewrite_small_data (rtx op)
{
op = copy_insn (op);
- for_each_rtx (&op, arc_rewrite_small_data_1, &op);
+ subrtx_ptr_iterator::array_type array;
+ FOR_EACH_SUBRTX_PTR (iter, array, &op, ALL)
+ {
+ rtx *loc = *iter;
+ if (arc_rewrite_small_data_p (*loc))
+ {
+ gcc_assert (SDATA_BASE_REGNUM == PIC_OFFSET_TABLE_REGNUM);
+ *loc = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, *loc);
+ if (loc != &op)
+ {
+ if (GET_CODE (op) == MEM && &XEXP (op, 0) == loc)
+ ; /* OK. */
+ else if (GET_CODE (op) == MEM
+ && GET_CODE (XEXP (op, 0)) == PLUS
+ && GET_CODE (XEXP (XEXP (op, 0), 0)) == MULT)
+ *loc = force_reg (Pmode, *loc);
+ else
+ gcc_unreachable ();
+ }
+ iter.skip_subrtxes ();
+ }
+ else if (GET_CODE (*loc) == PLUS
+ && rtx_equal_p (XEXP (*loc, 0), pic_offset_table_rtx))
+ iter.skip_subrtxes ();
+ }
return op;
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data
2014-10-25 9:54 [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data Richard Sandiford
@ 2014-10-25 9:56 ` Richard Sandiford
2014-11-02 18:33 ` Joern Rennecke
1 sibling, 0 replies; 3+ messages in thread
From: Richard Sandiford @ 2014-10-25 9:56 UTC (permalink / raw)
To: gcc-patches; +Cc: joern.rennecke
Richard Sandiford <rdsandiford@googlemail.com> writes:
> This is part of a series to remove uses of for_each_rtx from the ports.
> As with the first FR-V patch, we can find_all_hard_regs instead.
Oops, forgot that line :-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data
2014-10-25 9:54 [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data Richard Sandiford
2014-10-25 9:56 ` Richard Sandiford
@ 2014-11-02 18:33 ` Joern Rennecke
1 sibling, 0 replies; 3+ messages in thread
From: Joern Rennecke @ 2014-11-02 18:33 UTC (permalink / raw)
To: GCC Patches, Joern Rennecke, rdsandiford
On 25 October 2014 10:53, Richard Sandiford <rdsandiford@googlemail.com> wrote:
...
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for arc-elf. OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/arc/arc.c: Include rtl-iter.h.
> (arc_rewrite_small_data_1): Delete.
> (arc_rewrite_small_data): Use FOR_EACH_SUBRTX_PTR.
OK.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-02 18:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 9:54 [ARC] RFA: Use new rtl iterators in arc_rewrite_small_data Richard Sandiford
2014-10-25 9:56 ` Richard Sandiford
2014-11-02 18:33 ` Joern Rennecke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).