hooks.c (hook_rtx_rtx_identity): Generic hook function that takes a single rtx and...
authorRoger Sayle <roger@eyesopen.com>
Mon, 3 Feb 2003 19:40:58 +0000 (19:40 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Mon, 3 Feb 2003 19:40:58 +0000 (19:40 +0000)
* hooks.c (hook_rtx_rtx_identity): Generic hook function that
takes a single rtx and returns it unmodified.
* hooks.h (hook_rtx_rtx_identity): Prototype here.
* target.h (struct gcc_target): Add "delegitimize_address"
field to target structure.
* target-def.h (TARGET_DELEGITIMIZE_ADDRESS):  Provide default
for delegitimize_address target using hook_rtx_rtx_identity.
(TARGET_INITIALIZER): Initialize delegitimize_address field
using TARGET_DELEGITIMIZE_ADDRESS macro.
* simplify-rtx.c (avoid_constant_pool_reference): Handle float
extensions of constant pool references.  Use delegitimize_address
to undo the obfuscation of "-fpic".
* Makefile.in (simplify-rtx.o): Add dependency on target.h.

* config/i386/i386.c (TARGET_DELEGITIMIZE_ADDRESS): Define as
i386_simplify_dwarf_addr.
(ix86_find_base_term): Simplify using i386_simplify_dwarf_addr.
   (maybe_get_pool_constant): Likewise.

From-SVN: r62336

gcc/ChangeLog
gcc/Makefile.in
gcc/config/i386/i386.c
gcc/hooks.c
gcc/hooks.h
gcc/simplify-rtx.c
gcc/target-def.h
gcc/target.h

index e26e1c09bda3aa5c8504336164cde47333e04bb5..d89b2153e9c82ff51d30cbf3408ede2ed37a851d 100644 (file)
@@ -1,3 +1,24 @@
+2002-02-03  Roger Sayle  <roger@eyesopen.com>
+
+       * hooks.c (hook_rtx_rtx_identity): Generic hook function that
+       takes a single rtx and returns it unmodified.
+       * hooks.h (hook_rtx_rtx_identity): Prototype here.
+       * target.h (struct gcc_target): Add "delegitimize_address" 
+       field to target structure.
+       * target-def.h (TARGET_DELEGITIMIZE_ADDRESS):  Provide default
+       for delegitimize_address target using hook_rtx_rtx_identity.
+       (TARGET_INITIALIZER): Initialize delegitimize_address field
+       using TARGET_DELEGITIMIZE_ADDRESS macro.
+       * simplify-rtx.c (avoid_constant_pool_reference): Handle float
+       extensions of constant pool references.  Use delegitimize_address
+       to undo the obfuscation of "-fpic".
+       * Makefile.in (simplify-rtx.o): Add dependency on target.h.
+
+       * config/i386/i386.c (TARGET_DELEGITIMIZE_ADDRESS): Define as
+       i386_simplify_dwarf_addr.
+       (ix86_find_base_term): Simplify using i386_simplify_dwarf_addr.
+       (maybe_get_pool_constant): Likewise.
+
 Mon Feb  3 16:01:17 CET 2003  Jan Hubicka  <jh@suse.cz>
 
        * i386.c (ix86_expand_int_movcc):  Fix setcc sign bit case.
index cc444045e1902e7b61228ea435a605e8d4d5bf44..a40d15adb2b13798cba32a0ed6933b6e3a128dca 100644 (file)
@@ -1523,7 +1523,7 @@ jump.o : jump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
 
 simplify-rtx.o : simplify-rtx.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    $(REGS_H) hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
-   output.h function.h $(GGC_H) $(OBSTACK_H) $(TM_P_H) $(TREE_H)
+   output.h function.h $(GGC_H) $(OBSTACK_H) $(TM_P_H) $(TREE_H) $(TARGET_H)
 cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
    hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
    output.h function.h cselib.h $(GGC_H) $(TM_P_H) gt-cselib.h
index 48b60ad499c4e9673a2c0230a31d0a79c0b3f7ba..2f7a300f8ecd26b03cdbc6e53b61abc37cf7d428 100644 (file)
@@ -990,6 +990,9 @@ static enum x86_64_reg_class merge_classes PARAMS ((enum x86_64_reg_class,
 #undef TARGET_CANNOT_FORCE_CONST_MEM
 #define TARGET_CANNOT_FORCE_CONST_MEM ix86_cannot_force_const_mem
 
+#undef TARGET_DELEGITIMIZE_ADDRESS
+#define TARGET_DELEGITIMIZE_ADDRESS i386_simplify_dwarf_addr
+
 #undef TARGET_MS_BITFIELD_LAYOUT_P
 #define TARGET_MS_BITFIELD_LAYOUT_P ix86_ms_bitfield_layout_p
 
@@ -5368,21 +5371,7 @@ ix86_find_base_term (x)
       return term;
     }
 
-  if (GET_CODE (x) != PLUS
-      || XEXP (x, 0) != pic_offset_table_rtx
-      || GET_CODE (XEXP (x, 1)) != CONST)
-    return x;
-
-  term = XEXP (XEXP (x, 1), 0);
-
-  if (GET_CODE (term) == PLUS && GET_CODE (XEXP (term, 1)) == CONST_INT)
-    term = XEXP (term, 0);
-
-  if (GET_CODE (term) != UNSPEC
-      || XINT (term, 1) != UNSPEC_GOTOFF)
-    return x;
-
-  term = XVECEXP (term, 0, 0);
+  term = i386_simplify_dwarf_addr (x);
 
   if (GET_CODE (term) != SYMBOL_REF
       && GET_CODE (term) != LABEL_REF)
@@ -8047,24 +8036,7 @@ static rtx
 maybe_get_pool_constant (x)
      rtx x;
 {
-  x = XEXP (x, 0);
-
-  if (flag_pic && ! TARGET_64BIT)
-    {
-      if (GET_CODE (x) != PLUS)
-       return NULL_RTX;
-      if (XEXP (x, 0) != pic_offset_table_rtx)
-       return NULL_RTX;
-      x = XEXP (x, 1);
-      if (GET_CODE (x) != CONST)
-       return NULL_RTX;
-      x = XEXP (x, 0);
-      if (GET_CODE (x) != UNSPEC)
-       return NULL_RTX;
-      if (XINT (x, 1) != UNSPEC_GOTOFF)
-       return NULL_RTX;
-      x = XVECEXP (x, 0, 0);
-    }
+  x = i386_simplify_dwarf_addr (XEXP (x, 0));
 
   if (GET_CODE (x) == SYMBOL_REF && CONSTANT_POOL_ADDRESS_P (x))
     return get_pool_constant (x);
index 0954bde936bad8ef2f8d55d8db4af56abba79cfc..8926638347ce8a6cbdafc8891bd646c12e822a85 100644 (file)
@@ -1,5 +1,5 @@
 /* General-purpose hooks.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -149,3 +149,11 @@ hook_bool_rtx_int_int_intp_false (a, b, c, d)
   return false;
 }
 
+/* Generic hook that takes an rtx and returns it.  */
+rtx
+hook_rtx_rtx_identity (x)
+     rtx x;
+{
+  return x;
+}
+
index d36e3fcbc6433cf01830995dda9147048cf29d00..f7a4d6d302073ac31006a6bb0bc216c422094a2d 100644 (file)
@@ -1,5 +1,5 @@
 /* General-purpose hooks.
-   Copyright (C) 2002 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -45,4 +45,6 @@ bool default_can_output_mi_thunk_no_vcall
 
 bool hook_bool_tree_tree_false PARAMS ((tree, tree));
 
+rtx hook_rtx_rtx_identity PARAMS ((rtx));
+
 #endif
index 47dd7a0703814cb44359689f53846d208862bb11..19d664b14fb1ce41600d842dc819931e5e422f4f 100644 (file)
@@ -38,6 +38,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "toplev.h"
 #include "output.h"
 #include "ggc.h"
+#include "target.h"
 
 /* Simplification and canonicalization of RTL.  */
 
@@ -106,13 +107,36 @@ rtx
 avoid_constant_pool_reference (x)
      rtx x;
 {
-  rtx c, addr;
+  rtx c, tmp, addr;
   enum machine_mode cmode;
 
-  if (GET_CODE (x) != MEM)
-    return x;
+  switch (GET_CODE (x))
+    {
+    case MEM:
+      break;
+
+    case FLOAT_EXTEND:
+      /* Handle float extensions of constant pool references.  */
+      tmp = XEXP (x, 0);
+      c = avoid_constant_pool_reference (tmp);
+      if (c != tmp && GET_CODE (c) == CONST_DOUBLE)
+       {
+         REAL_VALUE_TYPE d;
+
+         REAL_VALUE_FROM_CONST_DOUBLE (d, c);
+         return CONST_DOUBLE_FROM_REAL_VALUE (d, GET_MODE (x));
+       }
+      return x;
+
+    default:
+      return x;
+    }
+
   addr = XEXP (x, 0);
 
+  /* Call target hook to avoid the effects of -fpic etc...  */
+  addr = (*targetm.delegitimize_address) (addr);
+
   if (GET_CODE (addr) == LO_SUM)
     addr = XEXP (addr, 1);
 
index 18929d101cb9da49da8b328b1340826fe662546f..dfc590009b38e8dbfc61013c4eba5a191c0e52ce 100644 (file)
@@ -1,5 +1,5 @@
 /* Default initializers for a generic GCC target.
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -259,6 +259,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 /* In hook.c.  */
 #define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
 #define TARGET_CANNOT_FORCE_CONST_MEM hook_bool_rtx_false
+#define TARGET_DELEGITIMIZE_ADDRESS hook_rtx_rtx_identity
 #define TARGET_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_false
 #define TARGET_COMP_TYPE_ATTRIBUTES hook_int_tree_tree_1
 #define TARGET_SET_DEFAULT_TYPE_ATTRIBUTES hook_void_tree
@@ -293,6 +294,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   TARGET_SECTION_TYPE_FLAGS,                   \
   TARGET_CANNOT_MODIFY_JUMPS_P,                        \
   TARGET_CANNOT_FORCE_CONST_MEM,               \
+  TARGET_DELEGITIMIZE_ADDRESS,                 \
   TARGET_FUNCTION_OK_FOR_SIBCALL,              \
   TARGET_IN_SMALL_DATA_P,                      \
   TARGET_BINDS_LOCAL_P,                                \
index b6d7f8dd4ce4c496acbcd1eadfeb6b88ee2b1502..8c286f70ad1b8fd0e0f5ab793196cfb0983b10fd 100644 (file)
@@ -1,5 +1,5 @@
 /* Data structure definitions for a generic GCC target.
-   Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -292,6 +292,9 @@ struct gcc_target
   /* True if the constant X cannot be placed in the constant pool.  */
   bool (* cannot_force_const_mem) PARAMS ((rtx));
 
+  /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS.  */
+  rtx (* delegitimize_address) PARAMS ((rtx));
+
   /* True if it is OK to do sibling call optimization for the specified
      call expression EXP.  DECL will be the called function, or NULL if
      this is an indirect call.  */