[PATCH] Add TARGET_MODE_DEPENDENT_ADDRESS_P target hook.

Bernhard Fischer rep.dot.nop@gmail.com
Sun Jul 20 05:20:00 GMT 2008


Hi.

>>        * targhooks.c (defeult_mode_dependent_address_p): New function.
>
> s/defeult/default/g

Sorry. I fix a typo and a speling errors.

2008-07-19  Anatoly Sokolov  <aesok@post.ru>

        * target.h (struct gcc_target): Add mode_dependent_address_p field.
        * target-def.h (TARGET_MODE_DEPENDENT_ADDRESS_P): New.
        (TARGET_INITIALIZER): Use TARGET_MODE_DEPENDENT_ADDRESS_P.
        * targhooks.c (default_mode_dependent_address_p): New function.
        * targhooks.h (default_mode_dependent_address_p): Declare function.
        * doc/tm.texi (TARGET_MODE_DEPENDENT_ADDRESS_P): New.
        (GO_IF_MODE_DEPENDENT_ADDRESS): Update.
        * recog.c: (mode_dependent_address_p): Call mode_dependent_address_p
        target hook. Change return type to bool.
        * recog.h: (mode_dependent_address_p): Change return type to bool.


Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi     (revision 137928)
+++ gcc/doc/tm.texi     (working copy)
@@ -5458,6 +5458,22 @@
 address;  but often a machine-dependent strategy can generate better code.
 @end defmac
 
+@deftypefn {Target Hook} bool TARGET_MODE_DEPENDENT_ADDRESS_P (const_rtx @var{addr})
+This hook returns @code{true} if memory address @var{addr} can have
+different meanings depending on the machine mode of the memory
+reference it is used for or if the address is valid for some modes
+but not others.
+
+Autoincrement and autodecrement addresses typically have mode-dependent
+effects because the amount of the increment or decrement is the size
+of the operand being addressed.  Some machines have other mode-dependent
+addresses.  Many RISC machines have no mode-dependent addresses.
+
+You may assume that @var{addr} is a valid address for the machine.
+
+The default version of this hook returns @code{false}.
+@end deftypefn
+
 @defmac GO_IF_MODE_DEPENDENT_ADDRESS (@var{addr}, @var{label})
 A C statement or compound statement with a conditional @code{goto
 @var{label};} executed if memory address @var{x} (an RTX) can have
@@ -5471,6 +5487,9 @@
 addresses.  Many RISC machines have no mode-dependent addresses.
 
 You may assume that @var{addr} is a valid address for the machine.
+
+These are obsolete macros, replaced by the
+@code{TARGET_MODE_DEPENDENT_ADDRESS_P} target hook.
 @end defmac
 
 @defmac LEGITIMATE_CONSTANT_P (@var{x})
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c     (revision 137928)
+++ gcc/targhooks.c     (working copy)
@@ -709,4 +709,24 @@
   return true;
 }
 
+/* The default implementation of TARGET_MODE_DEPENDENT_ADDRESS_P.  */
+
+bool
+default_mode_dependent_address_p (const_rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_MODE_DEPENDENT_ADDRESS
+
+  GO_IF_MODE_DEPENDENT_ADDRESS (addr, win);
+  return false;
+  /* Label `win' might (not) be used via GO_IF_MODE_DEPENDENT_ADDRESS.  */
+ win: ATTRIBUTE_UNUSED_LABEL
+  return true;
+
+#else
+
+  return false;
+
+#endif
+}
+
 #include "gt-targhooks.h"
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h     (revision 137928)
+++ gcc/targhooks.h     (working copy)
@@ -99,3 +99,4 @@
 extern tree default_emutls_var_init (tree, tree, tree);
 
 extern bool default_hard_regno_scratch_ok (unsigned int);
+extern bool default_mode_dependent_address_p (const_rtx addr);
Index: gcc/target.h
===================================================================
--- gcc/target.h        (revision 137928)
+++ gcc/target.h        (working copy)
@@ -563,6 +563,10 @@
 
   /* True if X is considered to be commutative.  */
   bool (* commutative_p) (const_rtx, int);
+  
+  /* True if ADDR is an address-expression whose effect depends 
+     on the mode of the memory reference it is used in.  */
+  bool (* mode_dependent_address_p) (const_rtx addr);
 
   /* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS.  */
   rtx (* delegitimize_address) (rtx);
Index: gcc/recog.c
===================================================================
--- gcc/recog.c	(revision 137928)
+++ gcc/recog.c	(working copy)
@@ -1866,7 +1866,7 @@
    Autoincrement addressing is a typical example of mode-dependence
    because the amount of the increment depends on the mode.  */
 
-int
+bool
 mode_dependent_address_p (rtx addr)
 {
   /* Auto-increment addressing with anything other than post_modify
@@ -1876,13 +1876,9 @@
       || GET_CODE (addr) == POST_INC
       || GET_CODE (addr) == PRE_DEC
       || GET_CODE (addr) == POST_DEC)
-    return 1;
+    return true;
 
-  GO_IF_MODE_DEPENDENT_ADDRESS (addr, win);
-  return 0;
-  /* Label `win' might (not) be used via GO_IF_MODE_DEPENDENT_ADDRESS.  */
- win: ATTRIBUTE_UNUSED_LABEL
-  return 1;
+  return targetm.mode_dependent_address_p (addr);
 }
 

 /* Like extract_insn, but save insn extracted and don't extract again, when
Index: gcc/recog.h
===================================================================
--- gcc/recog.h	(revision 137928)
+++ gcc/recog.h	(working copy)
@@ -99,7 +99,7 @@
 extern int offsettable_memref_p (rtx);
 extern int offsettable_nonstrict_memref_p (rtx);
 extern int offsettable_address_p (int, enum machine_mode, rtx);
-extern int mode_dependent_address_p (rtx);
+extern bool mode_dependent_address_p (rtx);
 
 extern int recog (rtx, rtx, int *);
 #ifndef GENERATOR_FILE
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h    (revision 137928)
+++ gcc/target-def.h    (working copy)
@@ -497,6 +497,10 @@
 #define TARGET_IN_SMALL_DATA_P hook_bool_const_tree_false
 #endif
 
+#ifndef TARGET_MODE_DEPENDENT_ADDRESS_P
+#define TARGET_MODE_DEPENDENT_ADDRESS_P default_mode_dependent_address_p
+#endif
+
 #ifndef TARGET_MANGLE_DECL_ASSEMBLER_NAME
 #define TARGET_MANGLE_DECL_ASSEMBLER_NAME default_mangle_decl_assembler_name
 #endif
@@ -797,6 +801,7 @@
   TARGET_CANNOT_FORCE_CONST_MEM,               \
   TARGET_CANNOT_COPY_INSN_P,                   \
   TARGET_COMMUTATIVE_P,                                \
+  TARGET_MODE_DEPENDENT_ADDRESS_P,             \
   TARGET_DELEGITIMIZE_ADDRESS,                 \
   TARGET_USE_BLOCKS_FOR_CONSTANT_P,            \
   TARGET_MIN_ANCHOR_OFFSET,                    \


Anatoly.



More information about the Gcc-patches mailing list