rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Redefine.
authorJakub Jelinek <jakub@redhat.com>
Wed, 27 Jan 2010 15:14:09 +0000 (16:14 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 27 Jan 2010 15:14:09 +0000 (16:14 +0100)
* config/rs6000/rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Redefine.
(rs6000_delegitimize_address): New function.

From-SVN: r156289

gcc/ChangeLog
gcc/config/rs6000/rs6000.c

index 36ee6905d0abaea05c6dff2727caf3d349d03878..290b3544085f586594453c0f14970305cd214ad9 100644 (file)
@@ -1,5 +1,8 @@
 2010-01-27  Jakub Jelinek  <jakub@redhat.com>
 
+       * config/rs6000/rs6000.c (TARGET_DELEGITIMIZE_ADDRESS): Redefine.
+       (rs6000_delegitimize_address): New function.
+
        * config/s390/s390.c (s390_delegitimize_address): Call
        delegitimize_mem_from_attrs.
 
index 639e71fdc1f0dd5724c108a1a603b85e200ddb6f..ee4eff6bb34039f000c040cb4cbbe559ddc49632 100644 (file)
@@ -1059,6 +1059,7 @@ static rtx rs6000_legitimize_address (rtx, rtx, enum machine_mode);
 static rtx rs6000_debug_legitimize_address (rtx, rtx, enum machine_mode);
 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
+static rtx rs6000_delegitimize_address (rtx);
 static rtx rs6000_tls_get_addr (void);
 static rtx rs6000_got_sym (void);
 static int rs6000_tls_symbol_ref_1 (rtx *, void *);
@@ -1326,6 +1327,9 @@ static const struct attribute_spec rs6000_attribute_table[] =
 #undef TARGET_CANNOT_FORCE_CONST_MEM
 #define TARGET_CANNOT_FORCE_CONST_MEM rs6000_tls_referenced_p
 
+#undef TARGET_DELEGITIMIZE_ADDRESS
+#define TARGET_DELEGITIMIZE_ADDRESS rs6000_delegitimize_address
+
 #undef TARGET_ASM_FUNCTION_PROLOGUE
 #define TARGET_ASM_FUNCTION_PROLOGUE rs6000_output_function_prologue
 #undef TARGET_ASM_FUNCTION_EPILOGUE
@@ -5262,6 +5266,41 @@ rs6000_output_dwarf_dtprel (FILE *file, int size, rtx x)
   fputs ("@dtprel+0x8000", file);
 }
 
+/* In the name of slightly smaller debug output, and to cater to
+   general assembler lossage, recognize various UNSPEC sequences
+   and turn them back into a direct symbol reference.  */
+
+static rtx
+rs6000_delegitimize_address (rtx orig_x)
+{
+  rtx x, y;
+
+  orig_x = delegitimize_mem_from_attrs (orig_x);
+  x = orig_x;
+  if (MEM_P (x))
+    x = XEXP (x, 0);
+
+  if (GET_CODE (x) == PLUS
+      && GET_CODE (XEXP (x, 1)) == CONST
+      && GET_CODE (XEXP (x, 0)) == REG
+      && REGNO (XEXP (x, 0)) == TOC_REGISTER)
+    {
+      y = XEXP (XEXP (x, 1), 0);
+      if (GET_CODE (y) == UNSPEC
+          && XINT (y, 1) == UNSPEC_TOCREL)
+       {
+         y = XVECEXP (y, 0, 0);
+         if (!MEM_P (orig_x))
+           return y;
+         else
+           return replace_equiv_address_nv (orig_x, y);
+       }
+      return orig_x;
+    }
+
+  return orig_x;
+}
+
 /* Construct the SYMBOL_REF for the tls_get_addr function.  */
 
 static GTY(()) rtx rs6000_tls_symbol;