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]

[patch] frv: Hookize some target macros.


Hi,

Attached is a patch to hookize some target macros.

Since I am planning to poison STRUCT_VALUE_REGNUM once I complete the
migration, I renamed STRUCT_VALUE_REGNUM to FRV_STRUCT_VALUE_REGNUM.

Built cc1 of frv-elf.  OK to apply?

Kazu Hirata

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

	* config/frv/frv-protos.h: Remove the prototype for
	frv_expand_builtin_saveregs.
	* config/frv/frv.c (TARGET_STRUCT_VALUE_RTX): Likewise.
	(TARGET_EXPAND_BUILTIN_SAVEREGS): Likewise.
	(frv_stack_info): Use FRV_STRUCT_VALUE_REGNUM instead of
	STRUCT_VALUE_REGNUM.
	(frv_expand_builtin_saveregs): Make it static.
	(frv_struct_value_rtx): New.
	* config/frv/frv.h (EXPAND_BUILTIN_SAVEREGS): Remove.

Index: frv-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv-protos.h,v
retrieving revision 1.10
diff -u -r1.10 frv-protos.h
--- frv-protos.h	16 Jan 2004 18:04:21 -0000	1.10
+++ frv-protos.h	24 Jan 2004 22:49:22 -0000
@@ -1,5 +1,5 @@
 /* Frv prototypes.
-   Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Red Hat, Inc.
 
 This file is part of GCC.
@@ -96,7 +96,6 @@
 						 enum machine_mode,
 						 tree, int);
 
-extern rtx frv_expand_builtin_saveregs		(void);
 extern void frv_setup_incoming_varargs		(CUMULATIVE_ARGS *,
 						 enum machine_mode,
 						 tree, int *, int);
Index: frv.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.c,v
retrieving revision 1.43
diff -u -r1.43 frv.c
--- frv.c	16 Jan 2004 18:04:21 -0000	1.43
+++ frv.c	24 Jan 2004 22:49:25 -0000
@@ -262,9 +262,11 @@
 static bool frv_in_small_data_p			(tree);
 static void frv_asm_output_mi_thunk
   (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree);
+static rtx frv_expand_builtin_saveregs		(void);
 static bool frv_rtx_costs			(rtx, int, int, int*);
 static void frv_asm_out_constructor		(rtx, int);
 static void frv_asm_out_destructor		(rtx, int);
+static rtx frv_struct_value_rtx			(tree, int);
 
 /* Initialize the GCC target structure.  */
 #undef  TARGET_ASM_FUNCTION_PROLOGUE
@@ -298,6 +300,12 @@
 #undef  TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE
 #define TARGET_SCHED_USE_DFA_PIPELINE_INTERFACE frv_use_dfa_pipeline_interface
 
+#undef TARGET_STRUCT_VALUE_RTX
+#define TARGET_STRUCT_VALUE_RTX frv_struct_value_rtx
+
+#undef TARGET_EXPAND_BUILTIN_SAVEREGS
+#define TARGET_EXPAND_BUILTIN_SAVEREGS frv_expand_builtin_saveregs
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Given a CONST, return true if the symbol_ref points to small data.  */
@@ -902,8 +910,8 @@
   info_ptr->regs[STACK_REGS_STDARG].special_p = 1;
 
   info_ptr->regs[STACK_REGS_STRUCT].name      = "struct";
-  info_ptr->regs[STACK_REGS_STRUCT].first     = STRUCT_VALUE_REGNUM;
-  info_ptr->regs[STACK_REGS_STRUCT].last      = STRUCT_VALUE_REGNUM;
+  info_ptr->regs[STACK_REGS_STRUCT].first     = FRV_STRUCT_VALUE_REGNUM;
+  info_ptr->regs[STACK_REGS_STRUCT].last      = FRV_STRUCT_VALUE_REGNUM;
   info_ptr->regs[STACK_REGS_STRUCT].special_p = 1;
 
   info_ptr->regs[STACK_REGS_FP].name          = "fp";
@@ -998,7 +1006,7 @@
 	case STACK_REGS_STRUCT:
 	  if (cfun->returns_struct)
 	    {
-	      info_ptr->save_p[STRUCT_VALUE_REGNUM] = REG_SAVE_1WORD;
+	      info_ptr->save_p[FRV_STRUCT_VALUE_REGNUM] = REG_SAVE_1WORD;
 	      size_1word += UNITS_PER_WORD;
 	    }
 	  break;
@@ -1136,8 +1144,8 @@
 
       if (cfun->returns_struct)
 	{
-	  info_ptr->save_p[STRUCT_VALUE_REGNUM] = REG_SAVE_1WORD;
-	  info_ptr->reg_offset[STRUCT_VALUE_REGNUM] = offset + UNITS_PER_WORD;
+	  info_ptr->save_p[FRV_STRUCT_VALUE_REGNUM] = REG_SAVE_1WORD;
+	  info_ptr->reg_offset[FRV_STRUCT_VALUE_REGNUM] = offset + UNITS_PER_WORD;
 	  info_ptr->regs[STACK_REGS_STRUCT].size_1word = UNITS_PER_WORD;
 	}
 
@@ -1975,7 +1983,7 @@
    If this macro is not defined, the compiler will output an ordinary call to
    the library function `__builtin_saveregs'.  */
 
-rtx
+static rtx
 frv_expand_builtin_saveregs (void)
 {
   int offset = UNITS_PER_WORD * FRV_NUM_ARG_REGS;
@@ -9562,4 +9570,11 @@
   dtors_section ();
   assemble_align (POINTER_SIZE);
   assemble_integer_with_op ("\t.picptr\t", symbol);
+}
+
+static rtx
+frv_struct_value_rtx (tree fntype ATTRIBUTE_UNUSED,
+		      int incoming ATTRIBUTE_UNUSED)
+{
+  return gen_rtx_REG (Pmode, FRV_STRUCT_VALUE_REGNUM);
 }
Index: frv.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/frv/frv.h,v
retrieving revision 1.33
diff -u -r1.33 frv.h
--- frv.h	16 Jan 2004 18:04:22 -0000	1.33
+++ frv.h	24 Jan 2004 22:49:28 -0000
@@ -1,5 +1,6 @@
 /* Target macros for the FRV port of GCC.
-   Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
    Contributed by Red Hat Inc.
 
    This file is part of GCC.
@@ -1999,8 +2000,9 @@
    (Actually, on most machines, scalar values are returned in the same place
    regardless of mode).
 
-   If `PROMOTE_FUNCTION_RETURN' is defined, you must apply the same promotion
-   rules specified in `PROMOTE_MODE' if VALTYPE is a scalar type.
+   If `TARGET_PROMOTE_FUNCTION_RETURN' is defined to return true, you
+   must apply the same promotion rules specified in `PROMOTE_MODE' if
+   VALTYPE is a scalar type.
 
    If the precise function being called is known, FUNC is a tree node
    (`FUNCTION_DECL') for it; otherwise, FUNC is a null pointer.  This makes it
@@ -2008,8 +2010,8 @@
    functions when all their calls are known.
 
    `FUNCTION_VALUE' is not used for return vales with aggregate data types,
-   because these are returned in another way.  See `STRUCT_VALUE_REGNUM' and
-   related macros, below.  */
+   because these are returned in another way.  See
+   `TARGET_STRUCT_VALUE_RTX' and related macros, below.  */
 #define FUNCTION_VALUE(VALTYPE, FUNC) \
   gen_rtx (REG, TYPE_MODE (VALTYPE), RETURN_VALUE_REGNUM)
 
@@ -2041,9 +2043,9 @@
 
 /* How Large Values are Returned.  */
 
-/* If the structure value address is passed in a register, then
-   `STRUCT_VALUE_REGNUM' should be the number of that register.  */
-#define STRUCT_VALUE_REGNUM (GPR_FIRST + 3)
+/* The number of the register that is used to to pass the structure
+   value address.  */
+#define FRV_STRUCT_VALUE_REGNUM (GPR_FIRST + 3)
 
 
 /* Function Entry and Exit.  */
@@ -2081,23 +2083,13 @@
 
 /* Implementing the Varargs Macros.  */
 
-/* If defined, is a C expression that produces the machine-specific code for a
-   call to `__builtin_saveregs'.  This code will be moved to the very beginning
-   of the function, before any parameter access are made.  The return value of
-   this function should be an RTX that contains the value to use as the return
-   of `__builtin_saveregs'.
-
-   If this macro is not defined, the compiler will output an ordinary call to
-   the library function `__builtin_saveregs'.  */
-
-#define EXPAND_BUILTIN_SAVEREGS() frv_expand_builtin_saveregs ()
-
 /* This macro offers an alternative to using `__builtin_saveregs' and defining
-   the macro `EXPAND_BUILTIN_SAVEREGS'.  Use it to store the anonymous register
-   arguments into the stack so that all the arguments appear to have been
-   passed consecutively on the stack.  Once this is done, you can use the
-   standard implementation of varargs that works for machines that pass all
-   their arguments on the stack.
+   the target hook `TARGET_EXPAND_BUILTIN_SAVEREGS'.  Use it to store
+   the anonymous register arguments into the stack so that all the
+   arguments appear to have been passed consecutively on the stack.
+   Once this is done, you can use the standard implementation of
+   varargs that works for machines that pass all their arguments on
+   the stack.
 
    The argument ARGS_SO_FAR is the `CUMULATIVE_ARGS' data structure, containing
    the values that obtain after processing of the named arguments.  The


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