From 750b270a1dd7a1c617f9dfa48a24b68216abf1c2 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Thu, 28 Aug 2014 06:25:14 +0000 Subject: [PATCH] varasm.c (mark_constant): Replace this for_each_rtx callback with... gcc/ * varasm.c (mark_constant): Replace this for_each_rtx callback with... (mark_constants_in_pattern): ...this new function to iterate over all the subrtxes. (mark_constants): Update accordingly. From-SVN: r214666 --- gcc/ChangeLog | 7 +++++++ gcc/varasm.c | 56 +++++++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 30093936ead..50f5ece8421 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2014-08-28 Richard Sandiford + + * varasm.c (mark_constant): Replace this for_each_rtx callback with... + (mark_constants_in_pattern): ...this new function to iterate over + all the subrtxes. + (mark_constants): Update accordingly. + 2014-08-28 Richard Sandiford * varasm.c: Include rtl-iter.h. diff --git a/gcc/varasm.c b/gcc/varasm.c index ce3442a50dc..8cc0633252f 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -3871,38 +3871,38 @@ output_constant_pool_1 (struct constant_descriptor_rtx *desc, return; } -/* Given a SYMBOL_REF CURRENT_RTX, mark it and all constants it refers - to as used. Emit referenced deferred strings. This function can - be used with for_each_rtx to mark all SYMBOL_REFs in an rtx. */ +/* Mark all constants that are referenced by SYMBOL_REFs in X. + Emit referenced deferred strings. */ -static int -mark_constant (rtx *current_rtx, void *data ATTRIBUTE_UNUSED) +static void +mark_constants_in_pattern (rtx insn) { - rtx x = *current_rtx; - - if (x == NULL_RTX || GET_CODE (x) != SYMBOL_REF) - return 0; - - if (CONSTANT_POOL_ADDRESS_P (x)) - { - struct constant_descriptor_rtx *desc = SYMBOL_REF_CONSTANT (x); - if (desc->mark == 0) - { - desc->mark = 1; - for_each_rtx (&desc->constant, mark_constant, NULL); - } - } - else if (TREE_CONSTANT_POOL_ADDRESS_P (x)) + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, PATTERN (insn), ALL) { - tree decl = SYMBOL_REF_DECL (x); - if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl))) + const_rtx x = *iter; + if (GET_CODE (x) == SYMBOL_REF) { - n_deferred_constants--; - output_constant_def_contents (x); + if (CONSTANT_POOL_ADDRESS_P (x)) + { + struct constant_descriptor_rtx *desc = SYMBOL_REF_CONSTANT (x); + if (desc->mark == 0) + { + desc->mark = 1; + iter.substitute (desc->constant); + } + } + else if (TREE_CONSTANT_POOL_ADDRESS_P (x)) + { + tree decl = SYMBOL_REF_DECL (x); + if (!TREE_ASM_WRITTEN (DECL_INITIAL (decl))) + { + n_deferred_constants--; + output_constant_def_contents (CONST_CAST_RTX (x)); + } + } } } - - return -1; } /* Look through appropriate parts of INSN, marking all entries in the @@ -3926,11 +3926,11 @@ mark_constants (rtx_insn *insn) { rtx subinsn = seq->element (i); if (INSN_P (subinsn)) - for_each_rtx (&PATTERN (subinsn), mark_constant, NULL); + mark_constants_in_pattern (subinsn); } } else - for_each_rtx (&PATTERN (insn), mark_constant, NULL); + mark_constants_in_pattern (insn); } /* Look through the instructions for this function, and mark all the -- 2.30.2