diff mbox

[05/50] calls.c:internal_arg_pointer_based_exp

Message ID 87d2chd6po.fsf@googlemail.com
State New
Headers show

Commit Message

Richard Sandiford Aug. 3, 2014, 1:48 p.m. UTC
gcc/
	* calls.c: Include rtl-iter.h.
	(internal_arg_pointer_based_exp_1): Delete.
	(internal_arg_pointer_based_exp): Take a const_rtx.
	Use FOR_EACH_SUBRTX to iterate over subrtxes.

Comments

Jeff Law Aug. 5, 2014, 8:56 p.m. UTC | #1
On 08/03/14 07:48, Richard Sandiford wrote:
> gcc/
> 	* calls.c: Include rtl-iter.h.
> 	(internal_arg_pointer_based_exp_1): Delete.
> 	(internal_arg_pointer_based_exp): Take a const_rtx.
> 	Use FOR_EACH_SUBRTX to iterate over subrtxes.
OK.
jeff
diff mbox

Patch

Index: gcc/calls.c
===================================================================
--- gcc/calls.c	2014-08-03 11:25:10.496959956 +0100
+++ gcc/calls.c	2014-08-03 11:25:21.433068077 +0100
@@ -49,6 +49,7 @@  Software Foundation; either version 3, o
 #include "cgraph.h"
 #include "except.h"
 #include "dbgcnt.h"
+#include "rtl-iter.h"
 
 /* Like PREFERRED_STACK_BOUNDARY but in units of bytes, not bits.  */
 #define STACK_BYTES (PREFERRED_STACK_BOUNDARY / BITS_PER_UNIT)
@@ -1693,7 +1694,7 @@  rtx_for_function_call (tree fndecl, tree
   vec<rtx> cache;
 } internal_arg_pointer_exp_state;
 
-static rtx internal_arg_pointer_based_exp (rtx, bool);
+static rtx internal_arg_pointer_based_exp (const_rtx, bool);
 
 /* Helper function for internal_arg_pointer_based_exp.  Scan insns in
    the tail call sequence, starting with first insn that hasn't been
@@ -1741,28 +1742,13 @@  internal_arg_pointer_based_exp_scan (voi
   internal_arg_pointer_exp_state.scan_start = scan_start;
 }
 
-/* Helper function for internal_arg_pointer_based_exp, called through
-   for_each_rtx.  Return 1 if *LOC is a register based on
-   crtl->args.internal_arg_pointer.  Return -1 if *LOC is not based on it
-   and the subexpressions need not be examined.  Otherwise return 0.  */
-
-static int
-internal_arg_pointer_based_exp_1 (rtx *loc, void *data ATTRIBUTE_UNUSED)
-{
-  if (REG_P (*loc) && internal_arg_pointer_based_exp (*loc, false) != NULL_RTX)
-    return 1;
-  if (MEM_P (*loc))
-    return -1;
-  return 0;
-}
-
 /* Compute whether RTL is based on crtl->args.internal_arg_pointer.  Return
    NULL_RTX if RTL isn't based on it, a CONST_INT offset if RTL is based on
    it with fixed offset, or PC if this is with variable or unknown offset.
    TOPLEVEL is true if the function is invoked at the topmost level.  */
 
 static rtx
-internal_arg_pointer_based_exp (rtx rtl, bool toplevel)
+internal_arg_pointer_based_exp (const_rtx rtl, bool toplevel)
 {
   if (CONSTANT_P (rtl))
     return NULL_RTX;
@@ -1796,8 +1782,15 @@  internal_arg_pointer_based_exp (rtx rtl,
       return NULL_RTX;
     }
 
-  if (for_each_rtx (&rtl, internal_arg_pointer_based_exp_1, NULL))
-    return pc_rtx;
+  subrtx_iterator::array_type array;
+  FOR_EACH_SUBRTX (iter, array, rtl, NONCONST)
+    {
+      const_rtx x = *iter;
+      if (REG_P (x) && internal_arg_pointer_based_exp (x, false) != NULL_RTX)
+	return pc_rtx;
+      if (MEM_P (x))
+	iter.skip_subrtxes ();
+    }
 
   return NULL_RTX;
 }