* [x86] RFA: Use new rtl iterators in find_constant
@ 2014-10-25 9:11 Richard Sandiford
2014-10-27 9:42 ` Uros Bizjak
0 siblings, 1 reply; 2+ messages in thread
From: Richard Sandiford @ 2014-10-25 9:11 UTC (permalink / raw)
To: gcc-patches; +Cc: rth, hubicka, ubizjak
[-- Attachment #1: Type: text/plain, Size: 2574 bytes --]
This is part of a series to remove uses of for_each_rtx from the ports.
It's a bit hard to read, so I've attached a -b version too.
Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
and g++.dg for x86_64-linux-gnu, and also by a boostrap. OK to install?
Thanks,
Richard
gcc/
* config/i386/i386.c (find_constant_1): Delete.
(find_constant): Use FOR_EACH_SUBRTX.
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c 2014-10-25 09:51:15.606795843 +0100
+++ gcc/config/i386/i386.c 2014-10-25 09:51:15.992799283 +0100
@@ -46526,53 +46526,44 @@ allocate_next_window (int window_num)
return dispatch_window_list1;
}
-/* Increment the number of immediate operands of an instruction. */
+/* Compute number of immediate operands of an instruction. */
-static int
-find_constant_1 (rtx *in_rtx, imm_info *imm_values)
+static void
+find_constant (rtx in_rtx, imm_info *imm_values)
{
- if (*in_rtx == 0)
- return 0;
-
- switch ( GET_CODE (*in_rtx))
- {
- case CONST:
- case SYMBOL_REF:
- case CONST_INT:
- (imm_values->imm)++;
- if (x86_64_immediate_operand (*in_rtx, SImode))
- (imm_values->imm32)++;
- else
- (imm_values->imm64)++;
- break;
-
- case CONST_DOUBLE:
- (imm_values->imm)++;
- (imm_values->imm64)++;
- break;
-
- case CODE_LABEL:
- if (LABEL_KIND (*in_rtx) == LABEL_NORMAL)
+ if (INSN_P (in_rtx))
+ in_rtx = PATTERN (in_rtx);
+ subrtx_iterator::array_type array;
+ FOR_EACH_SUBRTX (iter, array, in_rtx, ALL)
+ if (const_rtx x = *iter)
+ switch (GET_CODE (x))
{
+ case CONST:
+ case SYMBOL_REF:
+ case CONST_INT:
(imm_values->imm)++;
- (imm_values->imm32)++;
- }
- break;
-
- default:
- break;
- }
+ if (x86_64_immediate_operand (CONST_CAST_RTX (x), SImode))
+ (imm_values->imm32)++;
+ else
+ (imm_values->imm64)++;
+ break;
- return 0;
-}
+ case CONST_DOUBLE:
+ (imm_values->imm)++;
+ (imm_values->imm64)++;
+ break;
-/* Compute number of immediate operands of an instruction. */
+ case CODE_LABEL:
+ if (LABEL_KIND (x) == LABEL_NORMAL)
+ {
+ (imm_values->imm)++;
+ (imm_values->imm32)++;
+ }
+ break;
-static void
-find_constant (rtx in_rtx, imm_info *imm_values)
-{
- for_each_rtx (INSN_P (in_rtx) ? &PATTERN (in_rtx) : &in_rtx,
- (rtx_function) find_constant_1, (void *) imm_values);
+ default:
+ break;
+ }
}
/* Return total size of immediate operands of an instruction along with number
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: b-version.diff --]
[-- Type: text/x-patch, Size: 1846 bytes --]
Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c 2014-10-25 10:05:55.546618859 +0100
+++ gcc/config/i386/i386.c 2014-10-25 10:05:58.575647258 +0100
@@ -46526,21 +46526,23 @@ allocate_next_window (int window_num)
return dispatch_window_list1;
}
-/* Increment the number of immediate operands of an instruction. */
+/* Compute number of immediate operands of an instruction. */
-static int
-find_constant_1 (rtx *in_rtx, imm_info *imm_values)
+static void
+find_constant (rtx in_rtx, imm_info *imm_values)
{
- if (*in_rtx == 0)
- return 0;
-
- switch ( GET_CODE (*in_rtx))
+ if (INSN_P (in_rtx))
+ in_rtx = PATTERN (in_rtx);
+ subrtx_iterator::array_type array;
+ FOR_EACH_SUBRTX (iter, array, in_rtx, ALL)
+ if (const_rtx x = *iter)
+ switch (GET_CODE (x))
{
case CONST:
case SYMBOL_REF:
case CONST_INT:
(imm_values->imm)++;
- if (x86_64_immediate_operand (*in_rtx, SImode))
+ if (x86_64_immediate_operand (CONST_CAST_RTX (x), SImode))
(imm_values->imm32)++;
else
(imm_values->imm64)++;
@@ -46552,7 +46554,7 @@ find_constant_1 (rtx *in_rtx, imm_info *
break;
case CODE_LABEL:
- if (LABEL_KIND (*in_rtx) == LABEL_NORMAL)
+ if (LABEL_KIND (x) == LABEL_NORMAL)
{
(imm_values->imm)++;
(imm_values->imm32)++;
@@ -46562,17 +46564,6 @@ find_constant_1 (rtx *in_rtx, imm_info *
default:
break;
}
-
- return 0;
-}
-
-/* Compute number of immediate operands of an instruction. */
-
-static void
-find_constant (rtx in_rtx, imm_info *imm_values)
-{
- for_each_rtx (INSN_P (in_rtx) ? &PATTERN (in_rtx) : &in_rtx,
- (rtx_function) find_constant_1, (void *) imm_values);
}
/* Return total size of immediate operands of an instruction along with number
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [x86] RFA: Use new rtl iterators in find_constant
2014-10-25 9:11 [x86] RFA: Use new rtl iterators in find_constant Richard Sandiford
@ 2014-10-27 9:42 ` Uros Bizjak
0 siblings, 0 replies; 2+ messages in thread
From: Uros Bizjak @ 2014-10-27 9:42 UTC (permalink / raw)
To: gcc-patches, Richard Henderson, Jan Hubicka, Uros Bizjak,
Richard Sandiford
On Sat, Oct 25, 2014 at 11:07 AM, Richard Sandiford
<rdsandiford@googlemail.com> wrote:
> This is part of a series to remove uses of for_each_rtx from the ports.
> It's a bit hard to read, so I've attached a -b version too.
>
> Tested by making sure there were no code changes for gcc.dg, gcc.c-torture
> and g++.dg for x86_64-linux-gnu, and also by a boostrap. OK to install?
>
> Thanks,
> Richard
>
>
> gcc/
> * config/i386/i386.c (find_constant_1): Delete.
> (find_constant): Use FOR_EACH_SUBRTX.
OK.
Thanks,
Uros.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-10-27 9:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-25 9:11 [x86] RFA: Use new rtl iterators in find_constant Richard Sandiford
2014-10-27 9:42 ` Uros Bizjak
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).