Patchwork [sparc] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Aug. 26, 2010, 8:53 p.m.
Message ID <20100826205318.GL16898@codesourcery.com>
Download mbox | patch
Permalink /patch/62806/
State New
Headers show

Comments

Nathan Froyd - Aug. 26, 2010, 8:53 p.m.
This patch hookies FUNCTION_ARG and related macros for the sparc
backend.  Just like the rs6000 and mips patches, there's a fair bit of
futzing around with const-ify arguments.

Tested on sparc-elf, eyeballed by hand to make sure I wasn't introducing
new warnings.  I plan on doing a cfarm bootstrap on sparc64-linux prior
to committing just for sanity's sake; I plan to commit this in a week
under the obvious rule.

-Nathan

	* config/sparc/sparc-protos.h (function_arg_advance, function-arg):
	Delete.
	* config/sparc/sparc.h (FUNCTION_ARG_ADVANCE, FUNCTION_ARG): Delete.
	(FUNCTION_INCOMING_ARG): Delete.
	* config/sparc/sparc.c (scan_record_type): Const-ify tree argument.
	(function_arg_slotno): Likewise.  Take bool arguments.
	(sparc_arg_partial_bytes): Update call to it.
	(function_arg): Rename to...
	(sparc_function_arg_1): ...this.  Take bool arguments.
	(sparc_function_arg, sparc_function_incoming_arg): New functions.
	(function_arg_advance): Rename to...
	(sparc_function_arg_advance): ...this.  Take bool argument.
	(TARGET_FUNCTION_ARG_ADVANCE, TARGET_FUNCTION_ARG): Define.
	(TARGET_FUNCTION_INCOMING_ARG): Define.

Patch

diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h
index f5efcb9..d37823f 100644
--- a/gcc/config/sparc/sparc-protos.h
+++ b/gcc/config/sparc/sparc-protos.h
@@ -25,10 +25,6 @@  along with GCC; see the file COPYING3.  If not see
 #define __SPARC_PROTOS_H__
 
 #ifdef TREE_CODE
-extern void function_arg_advance (CUMULATIVE_ARGS *,
-				  enum machine_mode, tree, int);
-extern struct rtx_def *function_arg (const CUMULATIVE_ARGS *,
-				     enum machine_mode, tree, int, int);
 #ifdef RTX_CODE
 extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree);
 #endif
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 50b981e..b9c4390 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -350,9 +350,9 @@  int sparc_indent_opcode = 0;
 
 static bool sparc_handle_option (size_t, const char *, int);
 static void sparc_init_modes (void);
-static void scan_record_type (tree, int *, int *, int *);
+static void scan_record_type (const_tree, int *, int *, int *);
 static int function_arg_slotno (const CUMULATIVE_ARGS *, enum machine_mode,
-				tree, int, int, int *, int *);
+				const_tree, bool, bool, int *, int *);
 
 static int supersparc_adjust_cost (rtx, rtx, rtx, int);
 static int hypersparc_adjust_cost (rtx, rtx, rtx, int);
@@ -423,6 +423,14 @@  static rtx sparc_legitimize_address (rtx, rtx, enum machine_mode);
 static bool sparc_mode_dependent_address_p (const_rtx);
 static bool sparc_pass_by_reference (CUMULATIVE_ARGS *,
 				     enum machine_mode, const_tree, bool);
+static void sparc_function_arg_advance (CUMULATIVE_ARGS *,
+					enum machine_mode, const_tree, bool);
+static rtx sparc_function_arg_1 (const CUMULATIVE_ARGS *,
+				 enum machine_mode, const_tree, bool, bool);
+static rtx sparc_function_arg (CUMULATIVE_ARGS *,
+			       enum machine_mode, const_tree, bool);
+static rtx sparc_function_incoming_arg (CUMULATIVE_ARGS *,
+					enum machine_mode, const_tree, bool);
 static int sparc_arg_partial_bytes (CUMULATIVE_ARGS *,
 				    enum machine_mode, tree, bool);
 static void sparc_dwarf_handle_frame_unspec (const char *, rtx, int);
@@ -557,6 +565,12 @@  static bool fpu_option_set = false;
 #define TARGET_PASS_BY_REFERENCE sparc_pass_by_reference
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES sparc_arg_partial_bytes
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE sparc_function_arg_advance
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG sparc_function_arg
+#undef TARGET_FUNCTION_INCOMING_ARG
+#define TARGET_FUNCTION_INCOMING_ARG sparc_function_incoming_arg
 
 #undef TARGET_EXPAND_BUILTIN_SAVEREGS
 #define TARGET_EXPAND_BUILTIN_SAVEREGS sparc_builtin_saveregs
@@ -4924,7 +4938,8 @@  sparc_strict_argument_naming (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
    Sub-fields are not taken into account for the PACKED_P predicate.  */
 
 static void
-scan_record_type (tree type, int *intregs_p, int *fpregs_p, int *packed_p)
+scan_record_type (const_tree type, int *intregs_p, int *fpregs_p,
+		  int *packed_p)
 {
   tree field;
 
@@ -4964,7 +4979,7 @@  scan_record_type (tree type, int *intregs_p, int *fpregs_p, int *packed_p)
 
 static int
 function_arg_slotno (const struct sparc_args *cum, enum machine_mode mode,
-		     tree type, int named, int incoming_p,
+		     const_tree type, bool named, bool incoming_p,
 		     int *pregno, int *ppadding)
 {
   int regbase = (incoming_p
@@ -5538,8 +5553,7 @@  function_arg_vector_value (int size, int regno)
   return regs;
 }
 
-/* Handle the FUNCTION_ARG macro.
-   Determine where to put an argument to a function.
+/* Determine where to put an argument to a function.
    Value is zero to push the argument on the stack,
    or a hard register in which to store the argument.
 
@@ -5549,13 +5563,14 @@  function_arg_vector_value (int size, int regno)
    TYPE is the data type of the argument (as a tree).
     This is null for libcalls where that information may
     not be available.
-   NAMED is nonzero if this argument is a named parameter
+   NAMED is true if this argument is a named parameter
     (otherwise it is an extra parameter matching an ellipsis).
-   INCOMING_P is zero for FUNCTION_ARG, nonzero for FUNCTION_INCOMING_ARG.  */
+   INCOMING_P is false for TARGET_FUNCTION_ARG, true for
+    TARGET_FUNCTION_INCOMING_ARG.  */
 
-rtx
-function_arg (const struct sparc_args *cum, enum machine_mode mode,
-	      tree type, int named, int incoming_p)
+static rtx
+sparc_function_arg_1 (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		      const_tree type, bool named, bool incoming_p)
 {
   int regbase = (incoming_p
 		 ? SPARC_INCOMING_INT_ARG_FIRST
@@ -5687,6 +5702,24 @@  function_arg (const struct sparc_args *cum, enum machine_mode mode,
   return gen_rtx_REG (mode, regno);
 }
 
+/* Handle the TARGET_FUNCTION_ARG target hook.  */
+
+static rtx
+sparc_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		    const_tree type, bool named)
+{
+  return sparc_function_arg_1 (cum, mode, type, named, false);
+}
+
+/* Handle the TARGET_FUNCTION_INCOMING_ARG target hook.  */
+
+static rtx
+sparc_function_incoming_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			     const_tree type, bool named)
+{
+  return sparc_function_arg_1 (cum, mode, type, named, true);
+}
+
 /* For an arg passed partly in registers and partly in memory,
    this is the number of bytes of registers used.
    For args passed entirely in registers or entirely in memory, zero.
@@ -5703,8 +5736,9 @@  sparc_arg_partial_bytes (CUMULATIVE_ARGS *cum, enum machine_mode mode,
 {
   int slotno, regno, padding;
 
-  /* We pass 0 for incoming_p here, it doesn't matter.  */
-  slotno = function_arg_slotno (cum, mode, type, named, 0, &regno, &padding);
+  /* We pass false for incoming_p here, it doesn't matter.  */
+  slotno = function_arg_slotno (cum, mode, type, named, false,
+				&regno, &padding);
 
   if (slotno == -1)
     return 0;
@@ -5802,19 +5836,19 @@  sparc_pass_by_reference (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
 	    || GET_MODE_SIZE (mode) > 16);
 }
 
-/* Handle the FUNCTION_ARG_ADVANCE macro.
+/* Handle the TARGET_FUNCTION_ARG_ADVANCE hook.
    Update the data in CUM to advance over an argument
    of mode MODE and data type TYPE.
    TYPE is null for libcalls where that information may not be available.  */
 
-void
-function_arg_advance (struct sparc_args *cum, enum machine_mode mode,
-		      tree type, int named)
+static void
+sparc_function_arg_advance (struct sparc_args *cum, enum machine_mode mode,
+			    const_tree type, bool named)
 {
   int regno, padding;
 
-  /* We pass 0 for incoming_p here, it doesn't matter.  */
-  function_arg_slotno (cum, mode, type, named, 0, &regno, &padding);
+  /* We pass false for incoming_p here, it doesn't matter.  */
+  function_arg_slotno (cum, mode, type, named, false, &regno, &padding);
 
   /* If argument requires leading padding, add it.  */
   cum->words += padding;
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index eae3959..12e53ab 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.h
@@ -1450,35 +1450,6 @@  struct sparc_args {
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
 init_cumulative_args (& (CUM), (FNTYPE), (LIBNAME), (FNDECL));
 
-/* Update the data in CUM to advance over an argument
-   of mode MODE and data type TYPE.
-   TYPE is null for libcalls where that information may not be available.  */
-
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED) \
-function_arg_advance (& (CUM), (MODE), (TYPE), (NAMED))
-
-/* Determine where to put an argument to a function.
-   Value is zero to push the argument on the stack,
-   or a hard register in which to store the argument.
-
-   MODE is the argument's machine mode.
-   TYPE is the data type of the argument (as a tree).
-    This is null for libcalls where that information may
-    not be available.
-   CUM is a variable of type CUMULATIVE_ARGS which gives info about
-    the preceding args and about the function being called.
-   NAMED is nonzero if this argument is a named parameter
-    (otherwise it is an extra parameter matching an ellipsis).  */
-
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-function_arg (& (CUM), (MODE), (TYPE), (NAMED), 0)
-
-/* Define where a function finds its arguments.
-   This is different from FUNCTION_ARG because of register windows.  */
-
-#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
-function_arg (& (CUM), (MODE), (TYPE), (NAMED), 1)
-
 /* If defined, a C expression which determines whether, and in which direction,
    to pad out an argument with extra space.  The value should be of type
    `enum direction': either `upward' to pad above the argument,