[patch] mips: Hookize some target macros.

Kazu Hirata kazu@cs.umass.edu
Sun Jan 25 08:08:00 GMT 2004


Hi,

Attached is a patch to hookize some target macros.

Built cc1 of mips-elf.  OK to apply?

Kazu Hirata

2004-01-25  Kazu Hirata  <kazu@cs.umass.edu>

	* config/mips/mips-protos.h: Update the prototype for
	mips_setup_incoming_varargs.
	Remove the prototype for mips_return_in_memory.
	* config/mips/mips.c (TARGET_PROMOTE_FUNCTION_ARGS): New.
	(TARGET_PROMOTE_FUNCTION_RETURN): Likewise.
	(TARGET_PROMOTE_PROTOTYPES): Likewise.
	(TARGET_STRUCT_VALUE_RTX): Likewise.
	(TARGET_RETURN_IN_MEMORY): Likewise.
	(TARGET_SETUP_INCOMING_VARARGS): Likewise.
	(TARGET_STRICT_ARGUMENT_NAMING): Likewise.
	(mips_setup_incoming_varargs): Match the prototype for
	TARGET_SETUP_INCOMING_VARARGS.
	(mips_return_in_memory): Make it static.  Add argument fntype.
	(mips_strict_argument_naming): New.
	* config/mips/mips.h (PROMOTE_PROTOTYPES): Remove.
	(PROMOTE_FUNCTION_ARGS): Likewise.
	(PROMOTE_FUNCTION_RETURN): Likewise.
	(STRUCT_VALUE): Likewise.
	(RETURN_IN_MEMORY): Likewise.
	(SETUP_INCOMING_VARARGS): Likewise.
	(STRICT_ARGUMENT_NAMING): Likewise.

Index: mips-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips-protos.h,v
retrieving revision 1.59
diff -u -r1.59 mips-protos.h
--- mips-protos.h	5 Jan 2004 09:59:41 -0000	1.59
+++ mips-protos.h	25 Jan 2004 07:54:17 -0000
@@ -83,8 +83,6 @@
 				       enum machine_mode, tree, int);
 extern bool mips_pad_arg_upward (enum machine_mode, tree);
 extern bool mips_pad_reg_upward (enum machine_mode, tree);
-extern int mips_setup_incoming_varargs (const CUMULATIVE_ARGS *,
-					enum machine_mode, tree, int);
 extern void mips_va_start (tree, rtx);
 extern struct rtx_def *mips_va_arg (tree, tree);
 
@@ -141,7 +139,6 @@
 						   int, int);
 extern const char *mips_output_division (const char *, rtx *);
 extern unsigned int mips_hard_regno_nregs (int, enum machine_mode);
-extern int mips_return_in_memory (tree);
 extern const char *mips_emit_prefetch (rtx *);
 
 extern void irix_asm_output_align (FILE *, unsigned);
Index: mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.366
diff -u -r1.366 mips.c
--- mips.c	20 Jan 2004 19:58:59 -0000	1.366
+++ mips.c	25 Jan 2004 07:54:22 -0000
@@ -279,9 +279,13 @@
 static const struct mips_cpu_info *mips_parse_cpu (const char *, const char *);
 static const struct mips_cpu_info *mips_cpu_info_from_isa (int);
 static int mips_adjust_cost (rtx, rtx, rtx, int);
+static bool mips_return_in_memory (tree, tree);
+static bool mips_strict_argument_naming (CUMULATIVE_ARGS *);
 static int mips_issue_rate (void);
 static int mips_use_dfa_pipeline_interface (void);
 static void mips_init_libfuncs (void);
+static void mips_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
+					 tree, int *, int);
 static tree mips_build_builtin_va_list (void);
 
 #if TARGET_IRIX
@@ -795,6 +799,18 @@
 
 #undef TARGET_BUILD_BUILTIN_VA_LIST
 #define TARGET_BUILD_BUILTIN_VA_LIST mips_build_builtin_va_list
+
+#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
+#undef TARGET_PROMOTE_PROTOTYPES
+#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_true
+
+#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 mips_return_in_memory
 #undef TARGET_RETURN_IN_MSB
 #define TARGET_RETURN_IN_MSB mips_return_in_msb
 
@@ -803,6 +819,11 @@
 #undef TARGET_ASM_CAN_OUTPUT_MI_THUNK
 #define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_tree_hwi_hwi_tree_true
 
+#undef TARGET_SETUP_INCOMING_VARARGS
+#define TARGET_SETUP_INCOMING_VARARGS mips_setup_incoming_varargs
+#undef TARGET_STRICT_ARGUMENT_NAMING
+#define TARGET_STRICT_ARGUMENT_NAMING mips_strict_argument_naming
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Classify symbol X, which must be a SYMBOL_REF or a LABEL_REF.  */
@@ -3856,9 +3877,9 @@
   return mips_pad_arg_upward (mode, type);
 }
 
-int
-mips_setup_incoming_varargs (const CUMULATIVE_ARGS *cum,
-			     enum machine_mode mode, tree type, int no_rtl)
+static void
+mips_setup_incoming_varargs (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			     tree type, int *pretend_size, int no_rtl)
 {
   CUMULATIVE_ARGS local_cum;
   int gp_saved, fp_saved;
@@ -3929,10 +3950,13 @@
 	}
     }
   if (mips_abi == ABI_32 || mips_abi == ABI_O64)
-    /* No need for pretend arguments: the register parameter area was
-       allocated by the caller.  */
-    return 0;
-  return (gp_saved * UNITS_PER_WORD) + (fp_saved * UNITS_PER_FPREG);
+    {
+      /* No need for pretend arguments: the register parameter area was
+	 allocated by the caller.  */
+      *pretend_size = 0;
+      return;
+    }
+  *pretend_size = (gp_saved * UNITS_PER_WORD) + (fp_saved * UNITS_PER_FPREG);
 }
 
 /* Create the va_list data type.
@@ -7437,8 +7461,8 @@
       mode = TYPE_MODE (valtype);
       unsignedp = TREE_UNSIGNED (valtype);
 
-      /* Since we define PROMOTE_FUNCTION_RETURN, we must promote
-	 the mode just as PROMOTE_MODE does.  */
+      /* Since we define TARGET_PROMOTE_FUNCTION_RETURN that returns
+	 true, we must promote the mode just as PROMOTE_MODE does.  */
       mode = promote_mode (valtype, mode, &unsignedp, 1);
 
       /* Handle structures whose fields are returned in $f0/$f2.  */
@@ -9488,20 +9512,26 @@
     return ((GET_MODE_SIZE (mode) + UNITS_PER_FPREG - 1) / UNITS_PER_FPREG);
 }
 
-/* Implement RETURN_IN_MEMORY.  Under the old (i.e., 32 and O64 ABIs)
+/* Implement TARGET_RETURN_IN_MEMORY.  Under the old (i.e., 32 and O64 ABIs)
    all BLKmode objects are returned in memory.  Under the new (N32 and
    64-bit MIPS ABIs) small structures are returned in a register.
    Objects with varying size must still be returned in memory, of
    course.  */
 
-int
-mips_return_in_memory (tree type)
+static bool
+mips_return_in_memory (tree type, tree fndecl ATTRIBUTE_UNUSED)
 {
   if (mips_abi == ABI_32 || mips_abi == ABI_O64)
     return (TYPE_MODE (type) == BLKmode);
   else
     return ((int_size_in_bytes (type) > (2 * UNITS_PER_WORD))
 	    || (int_size_in_bytes (type) == -1));
+}
+
+static bool
+mips_strict_argument_naming (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
+{
+  return (mips_abi != ABI_32 && mips_abi != ABI_O64);
 }
 
 static int
Index: mips.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.h,v
retrieving revision 1.310
diff -u -r1.310 mips.h
--- mips.h	7 Jan 2004 00:52:31 -0000	1.310
+++ mips.h	25 Jan 2004 07:54:24 -0000
@@ -1424,10 +1424,6 @@
 #define PAD_VARARGS_DOWN \
   (FUNCTION_ARG_PADDING (TYPE_MODE (type), type) == downward)
 
-/* Arguments declared as 'char' or 'short' in a prototype should be
-   passed as 'int's.  */
-#define PROMOTE_PROTOTYPES 1
-
 /* Define if operations between registers always perform the operation
    on the full register even if a narrower mode is specified.  */
 #define WORD_REGISTER_OPERATIONS
@@ -1455,15 +1451,6 @@
 
 /* Define if loading short immediate values into registers sign extends.  */
 #define SHORT_IMMEDIATES_SIGN_EXTEND
-
-
-/* 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
-
 
 /* Standard register usage.  */
 
@@ -1684,9 +1671,6 @@
 /* Register in which static-chain is passed to a function.  */
 #define STATIC_CHAIN_REGNUM (GP_REG_FIRST + 2)
 
-/* Pass structure addresses as an "invisible" first argument.  */
-#define STRUCT_VALUE 0
-
 /* Registers used as temporaries in prologue/epilogue code.  If we're
    generating mips16 code, these registers must come from the core set
    of 8.  The prologue register mustn't conflict with any incoming
@@ -2226,15 +2210,7 @@
     || (IN_RANGE((N), FP_ARG_FIRST, FP_ARG_LAST)		\
 	&& ((N) % FP_INC == 0) && mips_abi != ABI_O64))		\
    && !fixed_regs[N])
-
-#define RETURN_IN_MEMORY(TYPE) mips_return_in_memory (TYPE)
-
-#define SETUP_INCOMING_VARARGS(CUM,MODE,TYPE,PRETEND_SIZE,NO_RTL)	\
-	(PRETEND_SIZE) = mips_setup_incoming_varargs (&(CUM), (MODE),	\
-						      (TYPE), (NO_RTL))
 
-#define STRICT_ARGUMENT_NAMING (mips_abi != ABI_32 && mips_abi != ABI_O64)
-
 /* This structure has to cope with two different argument allocation
    schemes.  Most MIPS ABIs view the arguments as a struct, of which the
    first N words go in registers and the rest go on the stack.  If I < N,



More information about the Gcc-patches mailing list