This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

call hooks for rs6000


This turns the call-related macros in the rs6000 port into hooks.

Bootstrapped & tested on powerpc-darwin.

-- 
- Geoffrey Keating <geoffk@apple.com>

===File ~/patches/rs6000-usehooks.patch=====================
2003-10-07  Geoffrey Keating  <geoffk@apple.com>

	* hooks.c (hook_bool_tree_true): New.
	(hook_rtx_tree_int_null): New.
	(hook_rtx_rtx_null): Use NULL, not 0.
	* hooks.h: Add 'extern' to everything.
	(hook_bool_tree_true): New.
	(hook_rtx_tree_int_null): New.
	* targhooks.c (hook_bool_CUMULATIVE_ARGS_true): New.
	* targhooks.h (hook_bool_CUMULATIVE_ARGS_true): New.
	* config/rs6000/rs6000-protos.h (setup_incoming_varargs): Remove
	prototype.
	* config/rs6000/rs6000.c (rs6000_return_in_memory): New.
	(setup_incoming_varargs): Prototype.
	(TARGET_PROMOTE_FUNCTION_ARGS): Define.
	(TARGET_PROMOTE_FUNCTION_RETURN): Define.
	(TARGET_STRUCT_VALUE_RTX): Define.
	(TARGET_RETURN_IN_MEMORY): Define.
	(TARGET_SETUP_INCOMING_VARARGS): Define.
	(TARGET_STRICT_ARGUMENT_NAMING): Define.
	(TARGET_PRETEND_OUTGOING_VARARGS_NAMED): Define.
	(init_cumulative_args): Use rs6000_return_in_memory.
	(setup_incoming_varargs): Make 'static'.
	* config/rs6000/rs6000.h (PROMOTE_FUNCTION_ARGS): Delete.
	(PROMOTE_FUNCTION_RETURN): Delete.
	(STRUCT_VALUE): Delete.
	(RETURN_IN_MEMORY): Delete.
	(SETUP_INCOMING_VARARGS): Delete.

Index: hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.c,v
retrieving revision 1.21
diff -u -p -u -p -r1.21 hooks.c
--- hooks.c	29 Jul 2003 23:36:46 -0000	1.21
+++ hooks.c	7 Oct 2003 19:02:41 -0000
@@ -159,6 +159,12 @@ hook_bool_tree_false (tree a ATTRIBUTE_U
 }
 
 bool
+hook_bool_tree_true (tree a ATTRIBUTE_UNUSED)
+{
+  return true;
+}
+
+bool
 hook_bool_tree_tree_false (tree a ATTRIBUTE_UNUSED, tree b ATTRIBUTE_UNUSED)
 {
   return false;
@@ -190,7 +196,14 @@ hook_rtx_rtx_identity (rtx x)
 rtx
 hook_rtx_rtx_null (rtx x ATTRIBUTE_UNUSED)
 {
-  return 0;
+  return NULL;
+}
+
+/* Generic hook that takes a tree and an int and returns NULL_RTX.  */
+rtx
+hook_rtx_tree_int_null (tree a ATTRIBUTE_UNUSED, int b ATTRIBUTE_UNUSED)
+{
+  return NULL;
 }
 
 /* Generic hook that takes a size_t and returns NULL.  */
Index: hooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/hooks.h,v
retrieving revision 1.22
diff -u -p -u -p -r1.22 hooks.h
--- hooks.h	29 Jul 2003 23:36:46 -0000	1.22
+++ hooks.h	7 Oct 2003 19:02:41 -0000
@@ -22,40 +22,42 @@ Foundation, 59 Temple Place - Suite 330,
 #ifndef GCC_HOOKS_H
 #define GCC_HOOKS_H
 
-bool hook_bool_void_false (void);
-bool hook_bool_bool_false (bool);
-bool hook_bool_tree_false (tree);
-bool hook_bool_tree_hwi_hwi_tree_false (tree, HOST_WIDE_INT, HOST_WIDE_INT,
+extern bool hook_bool_void_false (void);
+extern bool hook_bool_bool_false (bool);
+extern bool hook_bool_tree_false (tree);
+extern bool hook_bool_tree_true (tree);
+extern bool hook_bool_tree_hwi_hwi_tree_false (tree, HOST_WIDE_INT, HOST_WIDE_INT,
 					tree);
-bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
+extern bool hook_bool_tree_hwi_hwi_tree_true (tree, HOST_WIDE_INT, HOST_WIDE_INT,
 				       tree);
-bool hook_bool_rtx_false (rtx);
-bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
-bool hook_bool_constcharptr_size_t_false (const char *, size_t);
-
-void hook_void_tree_int (tree, int);
-void hook_void_void (void);
-void hook_void_FILEptr_constcharptr (FILE *, const char *);
-void hook_void_tree (tree);
-void hook_void_tree_treeptr (tree, tree *);
-void hook_void_constcharptr (const char *);
-
-int hook_int_tree_tree_1 (tree, tree);
-int hook_int_rtx_0 (rtx);
-int hook_int_void_0 (void);
-int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int);
-int hook_int_void_no_regs (void);
+extern bool hook_bool_rtx_false (rtx);
+extern bool hook_bool_rtx_int_int_intp_false (rtx, int, int, int *);
+extern bool hook_bool_constcharptr_size_t_false (const char *, size_t);
+
+extern void hook_void_tree_int (tree, int);
+extern void hook_void_void (void);
+extern void hook_void_FILEptr_constcharptr (FILE *, const char *);
+extern void hook_void_tree (tree);
+extern void hook_void_tree_treeptr (tree, tree *);
+extern void hook_void_constcharptr (const char *);
+
+extern int hook_int_tree_tree_1 (tree, tree);
+extern int hook_int_rtx_0 (rtx);
+extern int hook_int_void_0 (void);
+extern int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int);
+extern int hook_int_void_no_regs (void);
 
-unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **);
+extern unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **);
 
-bool default_can_output_mi_thunk_no_vcall (tree, HOST_WIDE_INT,
+extern bool default_can_output_mi_thunk_no_vcall (tree, HOST_WIDE_INT,
 					   HOST_WIDE_INT, tree);
 
-bool hook_bool_tree_tree_false (tree, tree);
+extern bool hook_bool_tree_tree_false (tree, tree);
 
-rtx hook_rtx_rtx_identity (rtx);
-rtx hook_rtx_rtx_null (rtx);
-void * hook_voidp_size_t_null (size_t);
-bool hook_bool_voidp_size_t_false (void *, size_t);
+extern rtx hook_rtx_rtx_identity (rtx);
+extern rtx hook_rtx_rtx_null (rtx);
+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);
 
 #endif
Index: targhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/targhooks.c,v
retrieving revision 2.7
diff -u -p -u -p -r2.7 targhooks.c
--- targhooks.c	23 Sep 2003 22:33:30 -0000	2.7
+++ targhooks.c	7 Oct 2003 19:02:41 -0000
@@ -195,3 +195,10 @@ default_pretend_outgoing_varargs_named(C
 #endif
 #endif
 }
+
+/* Generic hook that takes a CUMULATIVE_ARGS pointer and returns true.  */
+bool
+hook_bool_CUMULATIVE_ARGS_true (CUMULATIVE_ARGS * a ATTRIBUTE_UNUSED)
+{
+  return true;
+}
Index: targhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/targhooks.h,v
retrieving revision 2.2
diff -u -p -u -p -r2.2 targhooks.h
--- targhooks.h	23 Sep 2003 19:17:42 -0000	2.2
+++ targhooks.h	7 Oct 2003 19:02:41 -0000
@@ -31,3 +31,5 @@ extern rtx default_expand_builtin_savere
 extern void default_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int);
 extern bool default_strict_argument_naming (CUMULATIVE_ARGS *);
 extern bool default_pretend_outgoing_varargs_named (CUMULATIVE_ARGS *);
+
+extern bool hook_bool_CUMULATIVE_ARGS_true (CUMULATIVE_ARGS *);
Index: config/rs6000/rs6000-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000-protos.h,v
retrieving revision 1.63
diff -u -p -u -p -r1.63 rs6000-protos.h
--- config/rs6000/rs6000-protos.h	23 Sep 2003 02:03:55 -0000	1.63
+++ config/rs6000/rs6000-protos.h	7 Oct 2003 19:02:41 -0000
@@ -151,9 +151,6 @@ extern int function_arg_partial_nregs (C
 extern int function_arg_pass_by_reference (CUMULATIVE_ARGS *,
 						   enum machine_mode,
 						   tree, int);
-extern void setup_incoming_varargs (CUMULATIVE_ARGS *,
-					    enum machine_mode, tree,
-					    int *, int);
 extern rtx rs6000_function_value (tree, tree);
 extern rtx rs6000_libcall_value (enum machine_mode);
 extern struct rtx_def *rs6000_va_arg (tree, tree);
Index: config/rs6000/rs6000.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.c,v
retrieving revision 1.523
diff -u -p -u -p -r1.523 rs6000.c
--- config/rs6000/rs6000.c	4 Oct 2003 21:36:06 -0000	1.523
+++ config/rs6000/rs6000.c	7 Oct 2003 19:02:42 -0000
@@ -237,6 +237,7 @@ static void rs6000_output_function_epilo
 static void rs6000_output_mi_thunk (FILE *, tree, HOST_WIDE_INT,
 					    HOST_WIDE_INT, tree);
 static rtx rs6000_emit_set_long_const (rtx, HOST_WIDE_INT, HOST_WIDE_INT);
+static bool rs6000_return_in_memory (tree, tree);
 static void rs6000_file_start (void);
 #if TARGET_ELF
 static unsigned int rs6000_elf_section_type_flags (tree, const char *, int);
@@ -320,6 +321,9 @@ static int rs6000_get_some_local_dynamic
 static rtx rs6000_complex_function_value (enum machine_mode);
 static rtx rs6000_spe_function_arg (CUMULATIVE_ARGS *, 
 				    enum machine_mode, tree);
+static void setup_incoming_varargs (CUMULATIVE_ARGS *,
+				    enum machine_mode, tree,
+				    int *, int);
 
 /* Hash table stuff for keeping track of TOC entries.  */
 
@@ -497,6 +501,29 @@ static const char alt_reg_names[][8] =
 #undef TARGET_DWARF_REGISTER_SPAN
 #define TARGET_DWARF_REGISTER_SPAN rs6000_dwarf_register_span
 
+/* On rs6000, function arguments are promoted, as are function return
+   values.  */
+#undef TARGET_PROMOTE_FUNCTION_ARGS
+#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
+#undef TARGET_PROMOTE_FUNCTION_RETURN
+#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
+
+/* Structure return values are passed as an extra parameter.  */
+#undef TARGET_STRUCT_VALUE_RTX
+#define TARGET_STRUCT_VALUE_RTX hook_rtx_tree_int_null
+
+#undef TARGET_RETURN_IN_MEMORY
+#define TARGET_RETURN_IN_MEMORY rs6000_return_in_memory
+
+#undef TARGET_SETUP_INCOMING_VARARGS
+#define TARGET_SETUP_INCOMING_VARARGS setup_incoming_varargs
+
+/* Always strict argument naming on rs6000.  */
+#undef TARGET_STRICT_ARGUMENT_NAMING
+#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true
+#undef TARGET_PRETEND_OUTGOING_VARARGS_NAMED
+#define TARGET_PRETEND_OUTGOING_VARARGS_NAMED hook_bool_CUMULATIVE_ARGS_true
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Override command line options.  Mostly we process the processor
@@ -3509,6 +3551,39 @@ rs6000_emit_move (rtx dest, rtx source, 
   emit_insn (gen_rtx_SET (VOIDmode, operands[0], operands[1]));
 }
 
+/* Return a nonzero value to say to return the function value in
+   memory, just as large structures are always returned.  TYPE will be
+   the data type of the value, and FNTYPE will be the type of the
+   function doing the returning, or @code{NULL} for libcalls.
+
+   The AIX ABI for the RS/6000 specifies that all structures are
+   returned in memory.  The Darwin ABI does the same.  The SVR4 ABI
+   specifies that structures <= 8 bytes are returned in r3/r4, but a
+   draft put them in memory, and GCC used to implement the draft
+   instead of the final standard.  Therefore, TARGET_AIX_STRUCT_RET
+   controls this instead of DEFAULT_ABI; V.4 targets needing backward
+   compatibility can change DRAFT_V4_STRUCT_RET to override the
+   default, and -m switches get the final word.  See
+   rs6000_override_options for more details.
+
+   The PPC32 SVR4 ABI uses IEEE double extended for long double, if 128-bit
+   long double support is enabled.  These values are returned in memory.
+
+   int_size_in_bytes returns -1 for variable size objects, which go in
+   memory always.  The cast to unsigned makes -1 > 8.  */
+
+static bool
+rs6000_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
+{
+  if (AGGREGATE_TYPE_P (type)
+      && (TARGET_AIX_STRUCT_RET
+	  || (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 8))
+    return true;
+  if (DEFAULT_ABI == ABI_V4 && TYPE_MODE (type) == TFmode)
+    return true;
+  return false;
+}
+
 /* Initialize a variable CUM of type CUMULATIVE_ARGS
    for a call to a function whose data type is FNTYPE.
    For a library call, FNTYPE is 0.
@@ -3541,7 +3616,8 @@ init_cumulative_args (CUMULATIVE_ARGS *c
   else if (cum->prototype)
     cum->nargs_prototype = (list_length (TYPE_ARG_TYPES (fntype)) - 1
 			    + (TYPE_MODE (TREE_TYPE (fntype)) == BLKmode
-			       || RETURN_IN_MEMORY (TREE_TYPE (fntype))));
+			       || rs6000_return_in_memory (TREE_TYPE (fntype),
+							   fntype)));
 
   else
     cum->nargs_prototype = 0;
@@ -3999,7 +4119,7 @@ function_arg_pass_by_reference (CUMULATI
    Normally, this macro will push all remaining incoming registers on the
    stack and set PRETEND_SIZE to the length of the registers pushed.  */
 
-void
+static void
 setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode, 
 		tree type, int *pretend_size ATTRIBUTE_UNUSED, int no_rtl)
 {
Index: config/rs6000/rs6000.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/rs6000.h,v
retrieving revision 1.286
diff -u -p -u -p -r1.286 rs6000.h
--- config/rs6000/rs6000.h	21 Jul 2003 20:18:52 -0000	1.286
+++ config/rs6000/rs6000.h	7 Oct 2003 19:02:42 -0000
@@ -556,15 +556,6 @@ extern int rs6000_alignment_flags;
       && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \
     (MODE) = word_mode;
 
-/* Define this if function arguments should also be promoted using the above
-   procedure.  */
-
-#define PROMOTE_FUNCTION_ARGS
-
-/* Likewise, if the function return value is promoted.  */
-
-#define PROMOTE_FUNCTION_RETURN
-
 /* Define this if most significant bit is lowest numbered
    in instructions that operate on numbered bit-fields.  */
 /* That is true on RS/6000.  */
@@ -1144,11 +1135,6 @@ extern int rs6000_alignment_flags;
 
 /* Count register number.  */
 #define COUNT_REGISTER_REGNUM 66
-
-/* Place that structure value return address is placed.
-
-   On the RS/6000, it is passed as an extra parameter.  */
-#define STRUCT_VALUE 0
 
 /* Define the classes of registers for register constraints in the
    machine description.  Also define ranges of constants.
@@ -1609,28 +1595,6 @@ typedef struct rs6000_stack {
 
 #define LIBCALL_VALUE(MODE) rs6000_libcall_value ((MODE))
 
-/* The AIX ABI for the RS/6000 specifies that all structures are
-   returned in memory.  The Darwin ABI does the same.  The SVR4 ABI
-   specifies that structures <= 8 bytes are returned in r3/r4, but a
-   draft put them in memory, and GCC used to implement the draft
-   instead of the final standard.  Therefore, TARGET_AIX_STRUCT_RET
-   controls this instead of DEFAULT_ABI; V.4 targets needing backward
-   compatibility can change DRAFT_V4_STRUCT_RET to override the
-   default, and -m switches get the final word.  See
-   rs6000_override_options for more details.
-
-   The PPC32 SVR4 ABI uses IEEE double extended for long double, if 128-bit
-   long double support is enabled.  These values are returned in memory.
-
-   int_size_in_bytes returns -1 for variable size objects, which go in
-   memory always.  The cast to unsigned makes -1 > 8.  */
-
-#define RETURN_IN_MEMORY(TYPE) \
-  ((AGGREGATE_TYPE_P (TYPE)						\
-    && (TARGET_AIX_STRUCT_RET						\
-	|| (unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) > 8))	\
-   || (DEFAULT_ABI == ABI_V4 && TYPE_MODE (TYPE) == TFmode))
-
 /* DRAFT_V4_STRUCT_RET defaults off.  */
 #define DRAFT_V4_STRUCT_RET 0
 
@@ -1849,23 +1813,6 @@ typedef struct rs6000_args
    This should be set for Linux and Darwin as well, but we can't break
    the ABIs at the moment.  For now, only AIX gets fixed.  */
 #define SPLIT_COMPLEX_ARGS (DEFAULT_ABI == ABI_AIX)
-
-/* Perform any needed actions needed for a function that is receiving a
-   variable number of arguments.
-
-   CUM is as above.
-
-   MODE and TYPE are the mode and type of the current parameter.
-
-   PRETEND_SIZE is a variable that should be set to the amount of stack
-   that must be pushed by the prolog to pretend that our caller pushed
-   it.
-
-   Normally, this macro will push all remaining incoming registers on the
-   stack and set PRETEND_SIZE to the length of the registers pushed.  */
-
-#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL) \
-  setup_incoming_varargs (&CUM, MODE, TYPE, &PRETEND_SIZE, NO_RTL)
 
 /* Define the `__builtin_va_list' type for the ABI.  */
 #define BUILD_VA_LIST_TYPE(VALIST) \
============================================================


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]