Define FIND_BASE_TERM for rs6000

Richard Sandiford rdsandiford@googlemail.com
Mon Sep 22 18:49:00 GMT 2008


This patch, which follows on from the two previous (const (minus ...)) ones,
simply defines FIND_BASE_TERM for rs6000, so that alias.c knows the bases
of unspec addresses.

Tested in combination with the other patches but split out for ease
of review.  See the other messages for testing details.

Richard

PS. If this lot is accepted in some form, I'll post a documentation
    patch about the syntax of CONST expressions.


gcc/
	* config/rs6000/rs6000-protos.h (rs6000_find_base_term): Declare.
	* config/rs6000/rs6000.h (FIND_BASE_TERM): New macro.
	* config/rs6000/rs6000.c (rs6000_find_base_term): New function.

Index: gcc/config/rs6000/rs6000-protos.h
===================================================================
--- gcc/config/rs6000/rs6000-protos.h	2008-09-22 08:52:04.000000000 +0100
+++ gcc/config/rs6000/rs6000-protos.h	2008-09-22 19:12:42.000000000 +0100
@@ -112,6 +112,7 @@ extern rtx rs6000_legitimize_reload_addr
 extern int rs6000_legitimate_address (enum machine_mode, rtx, int);
 extern bool rs6000_legitimate_offset_address_p (enum machine_mode, rtx, int);
 extern bool rs6000_mode_dependent_address (rtx);
+extern rtx rs6000_find_base_term (rtx);
 extern bool rs6000_offsettable_memref_p (rtx);
 extern rtx rs6000_return_addr (int, rtx);
 extern void rs6000_output_symbol_ref (FILE*, rtx);
Index: gcc/config/rs6000/rs6000.h
===================================================================
--- gcc/config/rs6000/rs6000.h	2008-09-22 08:52:04.000000000 +0100
+++ gcc/config/rs6000/rs6000.h	2008-09-22 19:12:42.000000000 +0100
@@ -1848,6 +1848,8 @@ #define GO_IF_MODE_DEPENDENT_ADDRESS(ADD
   if (rs6000_mode_dependent_address (ADDR))			\
     goto LABEL;							\
 } while (0)
+
+#define FIND_BASE_TERM rs6000_find_base_term
 
 /* The register number of the register used to address a table of
    static data addresses in memory.  In some cases this register is
Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	2008-09-22 19:12:40.000000000 +0100
+++ gcc/config/rs6000/rs6000.c	2008-09-22 19:12:42.000000000 +0100
@@ -4406,6 +4406,27 @@ rs6000_mode_dependent_address (rtx addr)
   return false;
 }
 
+/* Implement FIND_BASE_TERM.  */
+
+rtx
+rs6000_find_base_term (rtx op)
+{
+  rtx base, offset;
+
+  split_const (op, &base, &offset);
+  if (GET_CODE (base) == UNSPEC)
+    switch (XINT (base, 1))
+      {
+      case UNSPEC_TOCREL:
+      case UNSPEC_MACHOPIC_OFFSET:
+	/* OP represents SYM [+ OFFSET] - ANCHOR.  SYM is the base term
+	   for aliasing purposes.  */
+	return XVECEXP (base, 0, 0);
+      }
+
+  return op;
+}
+
 /* More elaborate version of recog's offsettable_memref_p predicate
    that works around the ??? note of rs6000_mode_dependent_address.
    In particular it accepts



More information about the Gcc-patches mailing list