This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] Hookize MD_ASM_CLOBBERS.
- From: Kazu Hirata <kazu at cs dot umass dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 03 Mar 2004 02:56:38 -0500 (EST)
- Subject: [patch] Hookize MD_ASM_CLOBBERS.
Hi,
Attached is a patch to hookize MD_ASM_CLOBBERS.
I'm planning to use this hook on H8. I'd like to hookize it before we
start seeing these macro definitions all over the place.
Bootstrapped on i686-pc-linux-gnu. OK to apply?
Kazu Hirata
2004-03-03 Kazu Hirata <kazu@cs.umass.edu>
* hooks.c (hook_tree_tree_identity): New.
* hooks.h: Add a prototype for hook_tree_tree_identity.
* stmt.c (expand_asm_operands): Use targetm.md_asm_clobbers
instead of MD_ASM_CLOBBERS.
* system.h (MD_ASM_CLOBBERS): Poison.
* target-def.h (TARGET_MD_ASM_CLOBBERS): New.
(TARGET_INITIALIZER): Add TARGET_MD_ASM_CLOBBERS.
* target.h (gcc_target): Add md_asm_clobbers.
* config/i386/i386.c (TARGET_MD_ASM_CLOBBERS): New.
(ix86_md_asm_clobbers): New.
* config/i386/i386.h (MD_ASM_CLOBBERS): Remove.
* doc/tm.texi (MD_ASM_CLOBBERS): Change to
TARGET_MD_ASM_CLOBBERS.
Index: hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.c,v
retrieving revision 1.24
diff -u -r1.24 hooks.c
--- hooks.c 19 Feb 2004 11:06:26 -0000 1.24
+++ hooks.c 3 Mar 2004 06:50:51 -0000
@@ -209,3 +209,10 @@
{
return false;
}
+
+/* Generic hook that takes a tree and returns it as is. */
+tree
+hook_tree_tree_identity (tree a)
+{
+ return a;
+}
Index: hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.h,v
retrieving revision 1.25
diff -u -r1.25 hooks.h
--- hooks.h 19 Feb 2004 11:06:26 -0000 1.25
+++ hooks.h 3 Mar 2004 06:50:51 -0000
@@ -57,5 +57,6 @@
extern rtx hook_rtx_tree_int_null (tree, int);
extern void * hook_voidp_size_t_null (size_t);
extern bool hook_bool_voidp_size_t_false (void *, size_t);
+extern tree hook_tree_tree_identity (tree a);
#endif
Index: stmt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stmt.c,v
retrieving revision 1.348
diff -u -r1.348 stmt.c
--- stmt.c 3 Mar 2004 00:18:09 -0000 1.348
+++ stmt.c 3 Mar 2004 06:50:54 -0000
@@ -1486,13 +1486,11 @@
for (t = inputs; t ; t = TREE_CHAIN (t), i++)
constraints[i] = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
-#ifdef MD_ASM_CLOBBERS
/* Sometimes we wish to automatically clobber registers across an asm.
Case in point is when the i386 backend moved from cc0 to a hard reg --
maintaining source-level compatibility means automatically clobbering
the flags register. */
- MD_ASM_CLOBBERS (clobbers);
-#endif
+ clobbers = targetm.md_asm_clobbers (clobbers);
/* Count the number of meaningful clobbered registers, ignoring what
we would ignore later. */
Index: system.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/system.h,v
retrieving revision 1.204
diff -u -r1.204 system.h
--- system.h 2 Mar 2004 22:32:26 -0000 1.204
+++ system.h 3 Mar 2004 06:50:55 -0000
@@ -640,7 +640,8 @@
MAX_WCHAR_TYPE_SIZE GCOV_TYPE_SIZE SHARED_SECTION_ASM_OP \
FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE \
TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE \
- DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE
+ DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE \
+ MD_ASM_CLOBBERS
/* Hooks that are no longer used. */
#pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE \
Index: target-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target-def.h,v
retrieving revision 1.71
diff -u -r1.71 target-def.h
--- target-def.h 2 Mar 2004 22:32:26 -0000 1.71
+++ target-def.h 3 Mar 2004 06:50:55 -0000
@@ -333,6 +333,8 @@
#define TARGET_BUILTIN_SETJMP_FRAME_VALUE default_builtin_setjmp_frame_value
+#define TARGET_MD_ASM_CLOBBERS hook_tree_tree_identity
+
#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_false
#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_false
#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_false
@@ -400,6 +402,7 @@
TARGET_PCH_VALID_P, \
TARGET_DEFAULT_SHORT_ENUMS, \
TARGET_BUILTIN_SETJMP_FRAME_VALUE, \
+ TARGET_MD_ASM_CLOBBERS, \
TARGET_HAVE_NAMED_SECTIONS, \
TARGET_HAVE_CTORS_DTORS, \
TARGET_HAVE_TLS, \
Index: target.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/target.h,v
retrieving revision 1.81
diff -u -r1.81 target.h
--- target.h 3 Mar 2004 06:31:00 -0000 1.81
+++ target.h 3 Mar 2004 06:50:55 -0000
@@ -425,6 +425,10 @@
of the current frame into the built-in setjmp buffer. */
rtx (* builtin_setjmp_frame_value) (void);
+ /* This target hook should add STRING_CST trees for any hard regs
+ the port wishes to automatically clobber for all asms. */
+ tree (* md_asm_clobbers) (tree);
+
/* Leave the boolean fields at the end. */
/* True if arbitrary sections are supported. */
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.654
diff -u -r1.654 i386.c
--- config/i386/i386.c 26 Feb 2004 21:43:34 -0000 1.654
+++ config/i386/i386.c 3 Mar 2004 06:51:02 -0000
@@ -886,6 +886,7 @@
static int extended_reg_mentioned_1 (rtx *, void *);
static bool ix86_rtx_costs (rtx, int, int, int *);
static int min_insn_size (rtx);
+static tree ix86_md_asm_clobbers (tree clobbers);
#if defined (DO_GLOBAL_CTORS_BODY) && defined (HAS_INIT_SECTION)
static void ix86_svr3_asm_out_constructor (rtx, int);
@@ -1027,6 +1028,9 @@
#undef TARGET_BUILD_BUILTIN_VA_LIST
#define TARGET_BUILD_BUILTIN_VA_LIST ix86_build_builtin_va_list
+#undef TARGET_MD_ASM_CLOBBERS
+#define TARGET_MD_ASM_CLOBBERS ix86_md_asm_clobbers
+
#undef TARGET_PROMOTE_PROTOTYPES
#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
@@ -16023,6 +16027,23 @@
default:
abort ();
}
+}
+
+/* Worker function for TARGET_MD_ASM_CLOBBERS.
+
+ We do this in the new i386 backend to maintain source compatibility
+ with the old cc0-based compiler. */
+
+static tree
+ix86_md_asm_clobbers (tree clobbers)
+{
+ clobbers = tree_cons (NULL_TREE, build_string (5, "flags"),
+ clobbers);
+ clobbers = tree_cons (NULL_TREE, build_string (4, "fpsr"),
+ clobbers);
+ clobbers = tree_cons (NULL_TREE, build_string (7, "dirflag"),
+ clobbers);
+ return clobbers;
}
#include "gt-i386.h"
Index: config/i386/i386.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.h,v
retrieving revision 1.379
diff -u -r1.379 i386.h
--- config/i386/i386.h 26 Feb 2004 21:43:36 -0000 1.379
+++ config/i386/i386.h 3 Mar 2004 06:51:04 -0000
@@ -1591,22 +1591,6 @@
|| MAYBE_MMX_CLASS_P (CLASS) \
: GET_MODE_SIZE (FROM) != GET_MODE_SIZE (TO) \
? reg_classes_intersect_p (FLOAT_REGS, (CLASS)) : 0)
-
-/* A C statement that adds to CLOBBERS any hard regs the port wishes
- to automatically clobber for all asms.
-
- We do this in the new i386 backend to maintain source compatibility
- with the old cc0-based compiler. */
-
-#define MD_ASM_CLOBBERS(CLOBBERS) \
- do { \
- (CLOBBERS) = tree_cons (NULL_TREE, build_string (5, "flags"), \
- (CLOBBERS)); \
- (CLOBBERS) = tree_cons (NULL_TREE, build_string (4, "fpsr"), \
- (CLOBBERS)); \
- (CLOBBERS) = tree_cons (NULL_TREE, build_string (7, "dirflag"), \
- (CLOBBERS)); \
- } while (0)
/* Stack layout; function entry, exit and calling. */
Index: doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.307
diff -u -r1.307 tm.texi
--- doc/tm.texi 2 Mar 2004 22:32:27 -0000 1.307
+++ doc/tm.texi 3 Mar 2004 06:51:11 -0000
@@ -8864,10 +8864,12 @@
symbols must be explicitly imported from shared libraries (DLLs).
@end defmac
-@defmac MD_ASM_CLOBBERS (@var{clobbers})
-A C statement that adds to @var{clobbers} @code{STRING_CST} trees for
+@deftypefn {Target Hook} tree TARGET_MD_ASM_CLOBBERS (tree @var{clobbers})
+This target hook should add to @var{clobbers} @code{STRING_CST} trees for
any hard regs the port wishes to automatically clobber for all asms.
-@end defmac
+It should return the result of the last @code{tree_cons} used to add a
+clobber.
+@end deftypefn
@defmac MATH_LIBRARY
Define this macro as a C string constant for the linker argument to link