diff mbox

[23/28] mn10300: Add delegitimize_address hook.

Message ID 1294691517-19580-24-git-send-email-rth@redhat.com
State New
Headers show

Commit Message

Richard Henderson Jan. 10, 2011, 8:31 p.m. UTC
From: Richard Henderson <rth@twiddle.net>

This suppresses warnings generated by the dwarf2 output
routines about uninterpretable addresses.
---
 gcc/config/mn10300/mn10300.c |   62 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

Comments

Jeff Law Jan. 12, 2011, 2:05 p.m. UTC | #1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/10/11 13:31, Richard Henderson wrote:
> From: Richard Henderson <rth@twiddle.net>
> 
> This suppresses warnings generated by the dwarf2 output
> routines about uninterpretable addresses.
> ---
>  gcc/config/mn10300/mn10300.c |   62 ++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 62 insertions(+), 0 deletions(-)
OK.
jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNLbUPAAoJEBRtltQi2kC7Of0H/R/R++i0z0YBK87OGMisflhH
VURiYW1+q+5SshgFRSu/n0cUcEGO1VSRWsgz9TtDuCt71Sm5VjsdWIVa/6Nrk9Pr
A1dExTlSUkD+NUCfhcuXqG9GB4+XHLQ+RWnzM74LLnHsM4oPOvDsPjNQrLmxJraP
LTomaSUilXfj/bopDHkWI7ZuwUN0enS3tGyi7kVMoBANL70bV4wFhSFOAMg6Xs6g
cxReZekNYETj16aowq3A8jMOspdLnJQMh7XXZaNARZAPCbtqe1z/TkBo8FQK/hVp
qCbFIr2H6D5eOtrg6s/LMUataY5DuYf3FJW+zUOY/xj5tflYlKiAQCvlKukDN24=
=8DAR
-----END PGP SIGNATURE-----
diff mbox

Patch

diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c
index c56b896..17e58fe 100644
--- a/gcc/config/mn10300/mn10300.c
+++ b/gcc/config/mn10300/mn10300.c
@@ -2080,6 +2080,66 @@  mn10300_legitimate_constant_p (rtx x)
   return true;
 }
 
+/* Undo pic address legitimization for the benefit of debug info.  */
+
+static rtx
+mn10300_delegitimize_address (rtx orig_x)
+{
+  rtx x = orig_x, ret, addend = NULL;
+  bool need_mem;
+
+  if (MEM_P (x))
+    x = XEXP (x, 0);
+  if (GET_CODE (x) != PLUS || GET_MODE (x) != Pmode)
+    return orig_x;
+
+  if (XEXP (x, 0) == pic_offset_table_rtx)
+    ;
+  /* With the REG+REG addressing of AM33, var-tracking can re-assemble
+     some odd-looking "addresses" that were never valid in the first place.
+     We need to look harder to avoid warnings being emitted.  */
+  else if (GET_CODE (XEXP (x, 0)) == PLUS)
+    {
+      rtx x0 = XEXP (x, 0);
+      rtx x00 = XEXP (x0, 0);
+      rtx x01 = XEXP (x0, 1);
+
+      if (x00 == pic_offset_table_rtx)
+	addend = x01;
+      else if (x01 == pic_offset_table_rtx)
+	addend = x00;
+      else
+	return orig_x;
+
+    }
+  else
+    return orig_x;
+  x = XEXP (x, 1);
+
+  if (GET_CODE (x) != CONST)
+    return orig_x;
+  x = XEXP (x, 0);
+  if (GET_CODE (x) != UNSPEC)
+    return orig_x;
+
+  ret = XVECEXP (x, 0, 0);
+  if (XINT (x, 1) == UNSPEC_GOTOFF)
+    need_mem = false;
+  else if (XINT (x, 1) == UNSPEC_GOT)
+    need_mem = true;
+  else
+    return orig_x;
+
+  gcc_assert (GET_CODE (ret) == SYMBOL_REF);
+  if (need_mem != MEM_P (orig_x))
+    return orig_x;
+  if (need_mem && addend)
+    return orig_x;
+  if (addend)
+    ret = gen_rtx_PLUS (Pmode, addend, ret);
+  return ret;
+}
+
 /* For addresses, costs are relative to "MOV (Rm),Rn".  For AM33 this is
    the 3-byte fully general instruction; for MN103 this is the 2-byte form
    with an address register.  */
@@ -2915,6 +2975,8 @@  mn10300_split_and_operand_count (rtx op)
 
 #undef  TARGET_LEGITIMATE_ADDRESS_P
 #define TARGET_LEGITIMATE_ADDRESS_P	mn10300_legitimate_address_p
+#undef  TARGET_DELEGITIMIZE_ADDRESS
+#define TARGET_DELEGITIMIZE_ADDRESS	mn10300_delegitimize_address
 
 #undef  TARGET_PREFERRED_RELOAD_CLASS
 #define TARGET_PREFERRED_RELOAD_CLASS mn10300_preferred_reload_class