* Add new memory_address_p target hook
@ 2008-06-26 22:38 Anatoly Sokolov
2008-06-27 12:50 ` Weddington, Eric
2008-06-30 16:49 ` Ian Lance Taylor
0 siblings, 2 replies; 7+ messages in thread
From: Anatoly Sokolov @ 2008-06-26 22:38 UTC (permalink / raw)
To: gcc-patches; +Cc: aesok, iant
Hello.
As the Zack Weinberg offered in the post:
http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00511.html, this patch introduce
new TARGET_MEMORY_ADDRESS_P target hook instead GO_IF_LEGITIMATE_ADDRESS macro.
Outline:
* Remove uses in machine-independent code memory_address_p and
strict_memory_address_p functions and use memory_address_p target hook
instead. This allow delete memory_address_p and strict_memory_address_p
functions.
* For all target add TARGET_MEMORY_ADDRESS_P target hook and delete
GO_IF_LEGITIMATE_ADDRESS macro. This allow delete memory_address_1_p and
strict_memory_address_1_p functions and simplify default_memory_address_p.
2008-06-27 Anatoly Sokolov <aesok@post.ru>
* target.h (struct gcc_target): Add memory_address_p field.
* target-def.h (TARGET_MEMORY_ADDRESS_P): New.
(TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
* targhooks.c (default_memory_address_p): New function.
* targhooks.h (default_memory_address_p): Declare function.
* recog.c (memory_address_1_p): (Ditto.).
(memory_address_1_p): (Ditto.).
* reload.c (strict_memory_address_1_p): New function.
(strict_memory_address_p): Use memory_address_p target hook.
* recog.c: Include "target.h".
(memory_address_1_p): New function.
(memory_address_p): Use memory_address_p target hook.
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c (revision 137147)
+++ gcc/targhooks.c (working copy)
@@ -703,4 +703,14 @@
return true;
}
+bool
+default_memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr,
+ bool strict)
+{
+ if (strict)
+ return strict_memory_address_1_p (mode, addr);
+ else
+ return memory_address_1_p (mode, addr);
+}
+
#include "gt-targhooks.h"
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h (revision 137147)
+++ gcc/targhooks.h (working copy)
@@ -97,3 +97,5 @@
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_memory_address_p (enum machine_mode, rtx, bool);
Index: gcc/reload.c
===================================================================
--- gcc/reload.c (revision 137147)
+++ gcc/reload.c (working copy)
@@ -2111,11 +2111,17 @@
int
strict_memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, true) ? 1 : 0;
+}
+
+bool
+strict_memory_address_1_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+{
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
}
\f
/* Like rtx_equal_p except that it allows a REG and a SUBREG to match
Index: gcc/target.h
===================================================================
--- gcc/target.h (revision 137147)
+++ gcc/target.h (working copy)
@@ -564,6 +564,11 @@
/* True if X is considered to be commutative. */
bool (* commutative_p) (const_rtx, int);
+ /* Return trie if ADDR is a valid memory address for mode MODE,
+ and if strict is true check that each pseudo reg has the proper kind of
+ hard reg. */
+ bool (* memory_address_p) (enum machine_mode mode, rtx addr, bool strict);
+
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx);
Index: gcc/recog.c
===================================================================
--- gcc/recog.c (revision 137147)
+++ gcc/recog.c (working copy)
@@ -42,6 +42,7 @@
#include "reload.h"
#include "timevar.h"
#include "tree-pass.h"
+#include "target.h"
#include "df.h"
#ifndef STACK_PUSH_CODE
@@ -1206,11 +1207,17 @@
int
memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, false) ? 1 : 0;
+}
+
+bool
+memory_address_1_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+{
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
}
/* Return 1 if OP is a valid memory reference with mode MODE,
Index: gcc/recog.h
===================================================================
--- gcc/recog.h (revision 137147)
+++ gcc/recog.h (working copy)
@@ -85,7 +85,9 @@
extern int constrain_operands (int);
extern int constrain_operands_cached (int);
extern int memory_address_p (enum machine_mode, rtx);
+extern bool memory_address_1_p (enum machine_mode, rtx);
extern int strict_memory_address_p (enum machine_mode, rtx);
+extern bool strict_memory_address_1_p (enum machine_mode, rtx);
extern int validate_replace_rtx (rtx, rtx, rtx);
extern void validate_replace_rtx_group (rtx, rtx, rtx);
extern void validate_replace_src_group (rtx, rtx, rtx);
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h (revision 137147)
+++ gcc/target-def.h (working copy)
@@ -457,6 +457,10 @@
#define TARGET_VECTOR_OPAQUE_P hook_bool_const_tree_false
#endif
+#ifndef TARGET_MEMORY_ADDRESS_P
+#define TARGET_MEMORY_ADDRESS_P default_memory_address_p
+#endif
+
/* In hooks.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_BRANCH_TARGET_REGISTER_CLASS hook_int_void_no_regs
@@ -791,6 +795,7 @@
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
+ TARGET_MEMORY_ADDRESS_P, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_USE_BLOCKS_FOR_CONSTANT_P, \
TARGET_MIN_ANCHOR_OFFSET, \
Anatoly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: Add new memory_address_p target hook
2008-06-26 22:38 Add new memory_address_p target hook Anatoly Sokolov
@ 2008-06-27 12:50 ` Weddington, Eric
2008-06-30 16:49 ` Ian Lance Taylor
1 sibling, 0 replies; 7+ messages in thread
From: Weddington, Eric @ 2008-06-27 12:50 UTC (permalink / raw)
To: Anatoly Sokolov, gcc-patches
> -----Original Message-----
> From: Anatoly Sokolov [mailto:aesok@post.ru]
> Sent: Thursday, June 26, 2008 4:15 PM
> To: gcc-patches@gcc.gnu.org
> Cc: aesok@post.ru; iant@google.com
> Subject: Add new memory_address_p target hook
>
> Hello.
>
>
> 2008-06-27 Anatoly Sokolov <aesok@post.ru>
>
> * target.h (struct gcc_target): Add memory_address_p field.
> * target-def.h (TARGET_MEMORY_ADDRESS_P): New.
> (TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
> * targhooks.c (default_memory_address_p): New function.
> * targhooks.h (default_memory_address_p): Declare function.
> * recog.c (memory_address_1_p): (Ditto.).
> (memory_address_1_p): (Ditto.).
> * reload.c (strict_memory_address_1_p): New function.
> (strict_memory_address_p): Use memory_address_p target hook.
> * recog.c: Include "target.h".
> (memory_address_1_p): New function.
> (memory_address_p): Use memory_address_p target hook.
<snip>
>
> Index: gcc/target.h
> ===================================================================
> --- gcc/target.h (revision 137147)
> +++ gcc/target.h (working copy)
> @@ -564,6 +564,11 @@
> /* True if X is considered to be commutative. */
> bool (* commutative_p) (const_rtx, int);
>
> + /* Return trie if ADDR is a valid memory address for mode MODE,
Spelling error: /* Return true if ADDR ...
Eric
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add new memory_address_p target hook
2008-06-26 22:38 Add new memory_address_p target hook Anatoly Sokolov
2008-06-27 12:50 ` Weddington, Eric
@ 2008-06-30 16:49 ` Ian Lance Taylor
2008-07-03 11:54 ` Anatoly Sokolov
1 sibling, 1 reply; 7+ messages in thread
From: Ian Lance Taylor @ 2008-06-30 16:49 UTC (permalink / raw)
To: Anatoly Sokolov; +Cc: gcc-patches
Anatoly Sokolov <aesok@post.ru> writes:
> As the Zack Weinberg offered in the post:
> http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00511.html, this patch introduce
> new TARGET_MEMORY_ADDRESS_P target hook instead GO_IF_LEGITIMATE_ADDRESS macro.
>
> Outline:
>
> * Remove uses in machine-independent code memory_address_p and
> strict_memory_address_p functions and use memory_address_p target hook
> instead. This allow delete memory_address_p and strict_memory_address_p
> functions.
>
> * For all target add TARGET_MEMORY_ADDRESS_P target hook and delete
> GO_IF_LEGITIMATE_ADDRESS macro. This allow delete memory_address_1_p and
> strict_memory_address_1_p functions and simplify default_memory_address_p.
How did you test this?
> 2008-06-27 Anatoly Sokolov <aesok@post.ru>
>
> * target.h (struct gcc_target): Add memory_address_p field.
> * target-def.h (TARGET_MEMORY_ADDRESS_P): New.
> (TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
> * targhooks.c (default_memory_address_p): New function.
> * targhooks.h (default_memory_address_p): Declare function.
> * recog.c (memory_address_1_p): (Ditto.).
> (memory_address_1_p): (Ditto.).
> * reload.c (strict_memory_address_1_p): New function.
> (strict_memory_address_p): Use memory_address_p target hook.
> * recog.c: Include "target.h".
> (memory_address_1_p): New function.
> (memory_address_p): Use memory_address_p target hook.
I don't like the names memory_address_1_p or
strict_memory_address_1_p. Those names don't seem to indicate what
the functions do. The functions seem to provide default
implementations of memory_address_p for targets which still define
GO_IF_LEGITIMATE_ADDRESS. How about default_legitimate_address_p and
default_strict_legitimate_address_p? Also the new functions need
comments. Also for future-proofing I think the functions should use
#ifdef GO_IF_LEGITIMATE_ADDRESS and call gcc_unreachable() if it is
not defined.
Please submit an updated patch, with information on how it was tested.
Thanks for tackling this.
Ian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add new memory_address_p target hook
2008-06-30 16:49 ` Ian Lance Taylor
@ 2008-07-03 11:54 ` Anatoly Sokolov
2008-07-03 17:54 ` Ralf Wildenhues
0 siblings, 1 reply; 7+ messages in thread
From: Anatoly Sokolov @ 2008-07-03 11:54 UTC (permalink / raw)
To: Ian Lance Taylor; +Cc: gcc-patches, aesok
Hello.
>> As the Zack Weinberg offered in the post:
>> http://gcc.gnu.org/ml/gcc-patches/2004-08/msg00511.html, this patch introduce
>> new TARGET_MEMORY_ADDRESS_P target hook instead GO_IF_LEGITIMATE_ADDRESS macro.
>> 2008-06-27 Anatoly Sokolov <aesok@post.ru>
>> * reload.c (strict_memory_address_1_p): New function.
>> (strict_memory_address_p): Use memory_address_p target hook.
>> * recog.c: Include "target.h".
>> (memory_address_1_p): New function.
>> (memory_address_p): Use memory_address_p target hook.
> I don't like the names memory_address_1_p or
> strict_memory_address_1_p. ....
> How about default_legitimate_address_p and
> default_strict_legitimate_address_p? Also the new functions need
> comments. Also for future-proofing I think the functions should use
> #ifdef GO_IF_LEGITIMATE_ADDRESS and call gcc_unreachable() if it is
> not defined.
> Please submit an updated patch, with information on how it was tested.
I have change the function names, added new comments and also add guards
for uses of GO_IF_LEGITIMATE_ADDRESS with appropriate #ifdef in
default_strict_legitimate_address_p and default_legitimate_address_p
functions. Please, send further comments.
Patch was bootstrapped and regression tested on x86_64-unknown-linux-gnu.
2008-07-03 Anatoly Sokolov <aesok@post.ru>
* target.h (struct gcc_target): Add memory_address_p field.
* target-def.h (TARGET_MEMORY_ADDRESS_P): New.
(TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
* targhooks.c (default_memory_address_p): New function.
* targhooks.h (default_memory_address_p): Declare function.
* recog.h (default_legitimate_address_p): (Ditto.).
(default_strict_legitimate_address_p): (Ditto.).
* reload.c (default_strict_legitimate_address_p): New function.
(strict_memory_address_p): Use memory_address_p target hook.
* recog.c: Include "target.h".
(default_legitimate_address_p): New function.
(memory_address_p): Use memory_address_p target hook.
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c (revision 137392)
+++ gcc/targhooks.c (working copy)
@@ -703,4 +703,17 @@
return true;
}
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and if STRICT is true check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_memory_address_p (enum machine_mode mode, rtx addr, bool strict)
+{
+ if (strict)
+ return default_strict_legitimate_address_p (mode, addr);
+ else
+ return default_legitimate_address_p (mode, addr);
+}
+
#include "gt-targhooks.h"
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h (revision 137392)
+++ gcc/targhooks.h (working copy)
@@ -97,3 +97,5 @@
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_memory_address_p (enum machine_mode, rtx, bool);
Index: gcc/reload.c
===================================================================
--- gcc/reload.c (revision 137392)
+++ gcc/reload.c (working copy)
@@ -2109,13 +2109,32 @@
hard reg. */
int
-strict_memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+strict_memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, true) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_strict_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
\f
/* Like rtx_equal_p except that it allows a REG and a SUBREG to match
Index: gcc/target.h
===================================================================
--- gcc/target.h (revision 137392)
+++ gcc/target.h (working copy)
@@ -564,6 +564,11 @@
/* True if X is considered to be commutative. */
bool (* commutative_p) (const_rtx, int);
+ /* Return true if ADDR is a valid memory address for mode MODE,
+ and if strict is true check that each pseudo reg has the proper kind of
+ hard reg. */
+ bool (* memory_address_p) (enum machine_mode mode, rtx addr, bool strict);
+
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx);
Index: gcc/recog.c
===================================================================
--- gcc/recog.c (revision 137392)
+++ gcc/recog.c (working copy)
@@ -42,6 +42,7 @@
#include "reload.h"
#include "timevar.h"
#include "tree-pass.h"
+#include "target.h"
#include "df.h"
#ifndef STACK_PUSH_CODE
@@ -1204,13 +1205,30 @@
/* Return 1 if ADDR is a valid memory address for mode MODE. */
int
-memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, false) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE. */
+
+bool
+default_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
/* Return 1 if OP is a valid memory reference with mode MODE,
Index: gcc/recog.h
===================================================================
--- gcc/recog.h (revision 137392)
+++ gcc/recog.h (working copy)
@@ -85,7 +85,9 @@
extern int constrain_operands (int);
extern int constrain_operands_cached (int);
extern int memory_address_p (enum machine_mode, rtx);
+extern bool default_legitimate_address_p (enum machine_mode, rtx);
extern int strict_memory_address_p (enum machine_mode, rtx);
+extern bool default_strict_legitimate_address_p (enum machine_mode, rtx);
extern int validate_replace_rtx (rtx, rtx, rtx);
extern void validate_replace_rtx_group (rtx, rtx, rtx);
extern void validate_replace_src_group (rtx, rtx, rtx);
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h (revision 137392)
+++ gcc/target-def.h (working copy)
@@ -457,6 +457,10 @@
#define TARGET_VECTOR_OPAQUE_P hook_bool_const_tree_false
#endif
+#ifndef TARGET_MEMORY_ADDRESS_P
+#define TARGET_MEMORY_ADDRESS_P default_memory_address_p
+#endif
+
/* In hooks.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_BRANCH_TARGET_REGISTER_CLASS hook_int_void_no_regs
@@ -791,6 +795,7 @@
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
+ TARGET_MEMORY_ADDRESS_P, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_USE_BLOCKS_FOR_CONSTANT_P, \
TARGET_MIN_ANCHOR_OFFSET, \
Anatoly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Add new memory_address_p target hook
2008-07-03 11:54 ` Anatoly Sokolov
@ 2008-07-03 17:54 ` Ralf Wildenhues
2008-07-03 18:36 ` Re[2]: " Anatoly Sokolov
2008-07-12 14:35 ` Re[2]:[PING] " Anatoly Sokolov
0 siblings, 2 replies; 7+ messages in thread
From: Ralf Wildenhues @ 2008-07-03 17:54 UTC (permalink / raw)
To: Anatoly Sokolov; +Cc: Ian Lance Taylor, gcc-patches
Hello Anatoly,
* Anatoly Sokolov wrote on Thu, Jul 03, 2008 at 01:52:27PM CEST:
> * recog.c: Include "target.h".
> --- gcc/recog.c (revision 137392)
> +++ gcc/recog.c (working copy)
> @@ -42,6 +42,7 @@
> #include "reload.h"
> #include "timevar.h"
> #include "tree-pass.h"
> +#include "target.h"
> #include "df.h"
This needs adjustment of the recog.o rule in gcc/Makefile.in.
Cheers,
Ralf
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re[2]: Add new memory_address_p target hook
2008-07-03 17:54 ` Ralf Wildenhues
@ 2008-07-03 18:36 ` Anatoly Sokolov
2008-07-12 14:35 ` Re[2]:[PING] " Anatoly Sokolov
1 sibling, 0 replies; 7+ messages in thread
From: Anatoly Sokolov @ 2008-07-03 18:36 UTC (permalink / raw)
To: Ralf Wildenhues; +Cc: Ian Lance Taylor, gcc-patches, aesok
Helo, Ralf.
Ralf Wildenhues wrote:
> This needs adjustment of the recog.o rule in gcc/Makefile.in.
New patch.
2008-07-03 Anatoly Sokolov <aesok@post.ru>
* target.h (struct gcc_target): Add memory_address_p field.
* target-def.h (TARGET_MEMORY_ADDRESS_P): New.
(TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
* targhooks.c (default_memory_address_p): New function.
* targhooks.h (default_memory_address_p): Declare function.
* recog.h (default_legitimate_address_p): (Ditto.).
(default_strict_legitimate_address_p): (Ditto.).
* reload.c (default_strict_legitimate_address_p): New function.
(strict_memory_address_p): Use memory_address_p target hook.
* recog.c: Include "target.h".
(default_legitimate_address_p): New function.
(memory_address_p): Use memory_address_p target hook.
* Makefile.in (recog.o): Depend on target.h.
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c (revision 137426)
+++ gcc/targhooks.c (working copy)
@@ -703,4 +703,17 @@
return true;
}
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and if STRICT is true check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_memory_address_p (enum machine_mode mode, rtx addr, bool strict)
+{
+ if (strict)
+ return default_strict_legitimate_address_p (mode, addr);
+ else
+ return default_legitimate_address_p (mode, addr);
+}
+
#include "gt-targhooks.h"
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h (revision 137426)
+++ gcc/targhooks.h (working copy)
@@ -97,3 +97,5 @@
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_memory_address_p (enum machine_mode, rtx, bool);
Index: gcc/reload.c
===================================================================
--- gcc/reload.c (revision 137426)
+++ gcc/reload.c (working copy)
@@ -2109,13 +2109,32 @@
hard reg. */
int
-strict_memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+strict_memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, true) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_strict_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
\f
/* Like rtx_equal_p except that it allows a REG and a SUBREG to match
Index: gcc/target.h
===================================================================
--- gcc/target.h (revision 137426)
+++ gcc/target.h (working copy)
@@ -564,6 +564,11 @@
/* True if X is considered to be commutative. */
bool (* commutative_p) (const_rtx, int);
+ /* Return true if ADDR is a valid memory address for mode MODE,
+ and if strict is true check that each pseudo reg has the proper kind of
+ hard reg. */
+ bool (* memory_address_p) (enum machine_mode mode, rtx addr, bool strict);
+
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx);
Index: gcc/recog.c
===================================================================
--- gcc/recog.c (revision 137426)
+++ gcc/recog.c (working copy)
@@ -42,6 +42,7 @@
#include "reload.h"
#include "timevar.h"
#include "tree-pass.h"
+#include "target.h"
#include "df.h"
#ifndef STACK_PUSH_CODE
@@ -1204,13 +1205,30 @@
/* Return 1 if ADDR is a valid memory address for mode MODE. */
int
-memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, false) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE. */
+
+bool
+default_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
/* Return 1 if OP is a valid memory reference with mode MODE,
Index: gcc/recog.h
===================================================================
--- gcc/recog.h (revision 137426)
+++ gcc/recog.h (working copy)
@@ -85,7 +85,9 @@
extern int constrain_operands (int);
extern int constrain_operands_cached (int);
extern int memory_address_p (enum machine_mode, rtx);
+extern bool default_legitimate_address_p (enum machine_mode, rtx);
extern int strict_memory_address_p (enum machine_mode, rtx);
+extern bool default_strict_legitimate_address_p (enum machine_mode, rtx);
extern int validate_replace_rtx (rtx, rtx, rtx);
extern void validate_replace_rtx_group (rtx, rtx, rtx);
extern void validate_replace_src_group (rtx, rtx, rtx);
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h (revision 137426)
+++ gcc/target-def.h (working copy)
@@ -457,6 +457,10 @@
#define TARGET_VECTOR_OPAQUE_P hook_bool_const_tree_false
#endif
+#ifndef TARGET_MEMORY_ADDRESS_P
+#define TARGET_MEMORY_ADDRESS_P default_memory_address_p
+#endif
+
/* In hooks.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_BRANCH_TARGET_REGISTER_CLASS hook_int_void_no_regs
@@ -791,6 +795,7 @@
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
+ TARGET_MEMORY_ADDRESS_P, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_USE_BLOCKS_FOR_CONSTANT_P, \
TARGET_MIN_ANCHOR_OFFSET, \
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in (revision 137426)
+++ gcc/Makefile.in (working copy)
@@ -2868,7 +2868,7 @@
$(FUNCTION_H) $(BASIC_BLOCK_H) $(REGS_H) $(RECOG_H) $(EXPR_H) \
$(FLAGS_H) insn-config.h $(INSN_ATTR_H) toplev.h output.h reload.h \
addresses.h $(TM_P_H) $(TIMEVAR_H) tree-pass.h hard-reg-set.h $(REAL_H) \
- $(DF_H) $(DBGCNT_H)
+ $(DF_H) $(DBGCNT_H) $(TARGET_H)
reg-stack.o : reg-stack.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(RTL_H) $(TREE_H) $(RECOG_H) $(REGS_H) hard-reg-set.h $(FLAGS_H) \
insn-config.h toplev.h reload.h $(FUNCTION_H) $(TM_P_H) $(GGC_H) \
Anatoly.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re[2]:[PING] Add new memory_address_p target hook
2008-07-03 17:54 ` Ralf Wildenhues
2008-07-03 18:36 ` Re[2]: " Anatoly Sokolov
@ 2008-07-12 14:35 ` Anatoly Sokolov
1 sibling, 0 replies; 7+ messages in thread
From: Anatoly Sokolov @ 2008-07-12 14:35 UTC (permalink / raw)
To: Ralf Wildenhues; +Cc: Ian Lance Taylor, gcc-patches, aesok
Hello.
I updated the patch to the trunk revision 137735.
Patch was bootstrapped and regression tested on x86_64-unknown-linux-gnu.
OK for trunk?
2008-07-03 Anatoly Sokolov <aesok@post.ru>
* target.h (struct gcc_target): Add memory_address_p field.
* target-def.h (TARGET_MEMORY_ADDRESS_P): New.
(TARGET_INITIALIZER): Use TARGET_MEMORY_ADDRESS_P.
* targhooks.c (default_memory_address_p): New function.
* targhooks.h (default_memory_address_p): Declare function.
* recog.h (default_legitimate_address_p): (Ditto.).
(default_strict_legitimate_address_p): (Ditto.).
* reload.c (default_strict_legitimate_address_p): New function.
(strict_memory_address_p): Use memory_address_p target hook.
* recog.c (default_legitimate_address_p): New function.
(memory_address_p): Use memory_address_p target hook.
Index: gcc/targhooks.c
===================================================================
--- gcc/targhooks.c (revision 137724)
+++ gcc/targhooks.c (working copy)
@@ -709,4 +709,17 @@
return true;
}
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and if STRICT is true check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_memory_address_p (enum machine_mode mode, rtx addr, bool strict)
+{
+ if (strict)
+ return default_strict_legitimate_address_p (mode, addr);
+ else
+ return default_legitimate_address_p (mode, addr);
+}
+
#include "gt-targhooks.h"
Index: gcc/targhooks.h
===================================================================
--- gcc/targhooks.h (revision 137724)
+++ 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_memory_address_p (enum machine_mode, rtx, bool);
Index: gcc/reload.c
===================================================================
--- gcc/reload.c (revision 137724)
+++ gcc/reload.c (working copy)
@@ -2109,13 +2109,32 @@
hard reg. */
int
-strict_memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+strict_memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, true) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE,
+ and check that each pseudo reg has the proper kind of
+ hard reg. */
+
+bool
+default_strict_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
\f
/* Like rtx_equal_p except that it allows a REG and a SUBREG to match
Index: gcc/target.h
===================================================================
--- gcc/target.h (revision 137724)
+++ gcc/target.h (working copy)
@@ -564,6 +564,11 @@
/* True if X is considered to be commutative. */
bool (* commutative_p) (const_rtx, int);
+ /* Return true if ADDR is a valid memory address for mode MODE,
+ and if strict is true check that each pseudo reg has the proper kind of
+ hard reg. */
+ bool (* memory_address_p) (enum machine_mode mode, rtx addr, bool strict);
+
/* Given an address RTX, undo the effects of LEGITIMIZE_ADDRESS. */
rtx (* delegitimize_address) (rtx);
Index: gcc/recog.c
===================================================================
--- gcc/recog.c (revision 137724)
+++ gcc/recog.c (working copy)
@@ -1205,13 +1205,30 @@
/* Return 1 if ADDR is a valid memory address for mode MODE. */
int
-memory_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx addr)
+memory_address_p (enum machine_mode mode, rtx addr)
{
+ return targetm.memory_address_p (mode, addr, false) ? 1 : 0;
+}
+
+/* Return true if ADDR is a valid memory address for mode MODE. */
+
+bool
+default_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED,
+ rtx addr ATTRIBUTE_UNUSED)
+{
+#ifdef GO_IF_LEGITIMATE_ADDRESS
+
GO_IF_LEGITIMATE_ADDRESS (mode, addr, win);
- return 0;
+ return false;
win:
- return 1;
+ return true;
+
+#else
+
+ gcc_unreachable ();
+
+#endif
}
/* Return 1 if OP is a valid memory reference with mode MODE,
Index: gcc/recog.h
===================================================================
--- gcc/recog.h (revision 137724)
+++ gcc/recog.h (working copy)
@@ -85,7 +85,9 @@
extern int constrain_operands (int);
extern int constrain_operands_cached (int);
extern int memory_address_p (enum machine_mode, rtx);
+extern bool default_legitimate_address_p (enum machine_mode, rtx);
extern int strict_memory_address_p (enum machine_mode, rtx);
+extern bool default_strict_legitimate_address_p (enum machine_mode, rtx);
extern int validate_replace_rtx (rtx, rtx, rtx);
extern void validate_replace_rtx_group (rtx, rtx, rtx);
extern void validate_replace_src_group (rtx, rtx, rtx);
Index: gcc/target-def.h
===================================================================
--- gcc/target-def.h (revision 137724)
+++ gcc/target-def.h (working copy)
@@ -457,6 +457,10 @@
#define TARGET_VECTOR_OPAQUE_P hook_bool_const_tree_false
#endif
+#ifndef TARGET_MEMORY_ADDRESS_P
+#define TARGET_MEMORY_ADDRESS_P default_memory_address_p
+#endif
+
/* In hooks.c. */
#define TARGET_CANNOT_MODIFY_JUMPS_P hook_bool_void_false
#define TARGET_BRANCH_TARGET_REGISTER_CLASS hook_int_void_no_regs
@@ -797,6 +801,7 @@
TARGET_CANNOT_FORCE_CONST_MEM, \
TARGET_CANNOT_COPY_INSN_P, \
TARGET_COMMUTATIVE_P, \
+ TARGET_MEMORY_ADDRESS_P, \
TARGET_DELEGITIMIZE_ADDRESS, \
TARGET_USE_BLOCKS_FOR_CONSTANT_P, \
TARGET_MIN_ANCHOR_OFFSET, \
Anatoly.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-07-12 12:01 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-26 22:38 Add new memory_address_p target hook Anatoly Sokolov
2008-06-27 12:50 ` Weddington, Eric
2008-06-30 16:49 ` Ian Lance Taylor
2008-07-03 11:54 ` Anatoly Sokolov
2008-07-03 17:54 ` Ralf Wildenhues
2008-07-03 18:36 ` Re[2]: " Anatoly Sokolov
2008-07-12 14:35 ` Re[2]:[PING] " Anatoly Sokolov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).