Patchwork Fix gcc.dg/tls/pr45870.c on SPARC 32-bit

login
register
mail settings
Submitter Eric Botcazou
Date Nov. 10, 2010, 10:07 p.m.
Message ID <201011102307.34541.ebotcazou@adacore.com>
Download mbox | patch
Permalink /patch/70694/
State New
Headers show

Comments

Eric Botcazou - Nov. 10, 2010, 10:07 p.m.
... by providing the minimal sparc_delegitimize_address hook.

Tested on SPARC/Solaris, applied on the mainline.


2010-11-10  Eric Botcazou  <ebotcazou@adacore.com>

	* config/sparc/sparc.c (sparc_delegitimize_address): New function.
	(TARGET_DELEGITIMIZE_ADDRESS): Define to above.

Patch

Index: config/sparc/sparc.c
===================================================================
--- config/sparc/sparc.c	(revision 166490)
+++ config/sparc/sparc.c	(working copy)
@@ -420,6 +420,7 @@  static bool sparc_tls_referenced_p (rtx)
 static rtx sparc_legitimize_tls_address (rtx);
 static rtx sparc_legitimize_pic_address (rtx, rtx);
 static rtx sparc_legitimize_address (rtx, rtx, enum machine_mode);
+static rtx sparc_delegitimize_address (rtx);
 static bool sparc_mode_dependent_address_p (const_rtx);
 static bool sparc_pass_by_reference (CUMULATIVE_ARGS *,
 				     enum machine_mode, const_tree, bool);
@@ -524,6 +525,8 @@  static const struct default_options spar
 
 #undef TARGET_LEGITIMIZE_ADDRESS
 #define TARGET_LEGITIMIZE_ADDRESS sparc_legitimize_address
+#undef TARGET_DELEGITIMIZE_ADDRESS
+#define TARGET_DELEGITIMIZE_ADDRESS sparc_delegitimize_address
 #undef TARGET_MODE_DEPENDENT_ADDRESS_P
 #define TARGET_MODE_DEPENDENT_ADDRESS_P sparc_mode_dependent_address_p
 
@@ -3567,6 +3570,24 @@  sparc_legitimize_address (rtx x, rtx old
 
   return x;
 }
+
+/* Delegitimize an address that was legitimized by the above function.  */
+
+static rtx
+sparc_delegitimize_address (rtx x)
+{
+  x = delegitimize_mem_from_attrs (x);
+
+  if (GET_CODE (x) == LO_SUM
+      && GET_CODE (XEXP (x, 1)) == UNSPEC
+      && XINT (XEXP (x, 1), 1) == UNSPEC_TLSLE)
+    {
+      x = XVECEXP (XEXP (x, 1), 0, 0);
+      gcc_assert (GET_CODE (x) == SYMBOL_REF);
+    }
+
+  return x;
+}
 
 /* SPARC implementation of LEGITIMIZE_RELOAD_ADDRESS.  Returns a value to
    replace the input X, or the original X if no replacement is called for.