summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog13
-rw-r--r--gcc/doc/tm.texi19
-rw-r--r--gcc/recog.c10
-rw-r--r--gcc/recog.h4
-rw-r--r--gcc/target-def.h5
-rw-r--r--gcc/target.h4
-rw-r--r--gcc/targhooks.c20
-rw-r--r--gcc/targhooks.h1
8 files changed, 67 insertions, 9 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8fb04d5e0de..43d9e9ed2ec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2010-05-12 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.
+
2010-05-12 Kazu Hirata <kazu@codesourcery.com>
Nathan Froyd <froydnj@codesourcery.com>
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index 96fc62c2c51..6a998ed71a4 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -5609,6 +5609,22 @@ It is not necessary for this macro to come up with a legitimate
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
@@ -5622,6 +5638,9 @@ 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.
+
+These are obsolete macros, replaced by the
+@code{TARGET_MODE_DEPENDENT_ADDRESS_P} target hook.
@end defmac
@defmac LEGITIMATE_CONSTANT_P (@var{x})
diff --git a/gcc/recog.c b/gcc/recog.c
index 0dea35fb3d7..e8f918c7102 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -1978,7 +1978,7 @@ offsettable_address_addr_space_p (int strictp, enum machine_mode mode, rtx y,
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
@@ -1988,13 +1988,9 @@ mode_dependent_address_p (rtx addr)
|| 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
diff --git a/gcc/recog.h b/gcc/recog.h
index 3daac6225c2..5e820cc0103 100644
--- a/gcc/recog.h
+++ b/gcc/recog.h
@@ -1,6 +1,6 @@
/* Declarations for interface to insn recognizer and insn-output.c.
Copyright (C) 1987, 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004,
- 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GCC.
@@ -111,7 +111,7 @@ extern int offsettable_address_addr_space_p (int, enum machine_mode, rtx,
#define offsettable_address_p(strict,mode,addr) \
offsettable_address_addr_space_p ((strict), (mode), (addr), \
ADDR_SPACE_GENERIC)
-extern int mode_dependent_address_p (rtx);
+extern bool mode_dependent_address_p (rtx);
extern int recog (rtx, rtx, int *);
#ifndef GENERATOR_FILE
diff --git a/gcc/target-def.h b/gcc/target-def.h
index 72cf9307679..3ead3702047 100644
--- a/gcc/target-def.h
+++ b/gcc/target-def.h
@@ -599,6 +599,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
@@ -970,6 +974,7 @@
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
+ TARGET_MODE_DEPENDENT_ADDRESS_P, \
TARGET_LEGITIMIZE_ADDRESS, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_LEGITIMATE_ADDRESS_P, \
diff --git a/gcc/target.h b/gcc/target.h
index 2c9ab8598fa..29ec84f1a48 100644
--- a/gcc/target.h
+++ b/gcc/target.h
@@ -663,6 +663,10 @@ struct gcc_target
/* 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 invalid address X for a given machine mode, try machine-specific
ways to make it legitimate. Return X or an invalid address on failure. */
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 2c0a65dc926..5e1831cd825 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -958,6 +958,26 @@ default_hard_regno_scratch_ok (unsigned int regno ATTRIBUTE_UNUSED)
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
+}
+
bool
default_target_option_valid_attribute_p (tree ARG_UNUSED (fndecl),
tree ARG_UNUSED (name),
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index e70eef4d555..be167e5e0db 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -117,6 +117,7 @@ extern tree default_mangle_decl_assembler_name (tree, tree);
extern tree default_emutls_var_fields (tree, tree *);
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);
extern bool default_target_option_valid_attribute_p (tree, tree, tree, int);
extern bool default_target_option_pragma_parse (tree, tree);
extern bool default_target_can_inline_p (tree, tree);