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]

Re: [patch] sparc: Hookize some target macros.


> No problem.

Thanks.  It turned out that one of my ABI patches was conflicting with yours, 
so I re-diffed it and added the missing (or removed) comments.

Bootstrapped, regtested, compat-regtested on sparc64-sun-solaris2.9 and 
sparc-sun-solaris2.8, applied on mainline.


2004-01-30  Kazu Hirata  <kazu@cs.umass.edu>
            Eric Botcazou  <ebotcazou@libertysurf.fr>

        * config/sparc/sparc-protos.h: Remove the prototype for
        sparc_builtin_saveregs.
        * config/sparc/sparc.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_EXPAND_BUILTIN_SAVEREGS): Likewise.
        (TARGET_STRICT_ARGUMENT_NAMING): Likewise.
        (sparc_builtin_saveregs): Make it static.
        (sparc_promote_prototypes): New.
        (sparc_struct_value_rtx): Likewise.
        (sparc_return_in_memory): Likewise.
        * config/sparc/sparc.h: (PROMOTE_FUNCTION_ARGS): Remove.
        (PROMOTE_FUNCTION_RETURN): Likewise.
        (RETURN_IN_MEMORY): Likewise.
        (STRUCT_VALUE): Likewise.
        (STRUCT_VALUE_INCOMING): Likewise.
        (EXPAND_BUILTIN_SAVEREGS): Likewise.
        (STRICT_ARGUMENT_NAMING): Likewise.
        (PROMOTE_PROTOTYPES): Likewise.

	* config/sparc/sparc.h (PROMOTE_MODE): Use word_mode.

-- 
Eric Botcazou
Index: config/sparc/sparc-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc-protos.h,v
retrieving revision 1.38
diff -u -p -r1.38 sparc-protos.h
--- config/sparc/sparc-protos.h	26 Nov 2003 09:48:20 -0000	1.38
+++ config/sparc/sparc-protos.h	30 Jan 2004 08:43:22 -0000
@@ -1,5 +1,5 @@
 /* Prototypes of target machine for SPARC.
-   Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com).
    64-bit SPARC-V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
    at Cygnus Support.
@@ -36,7 +36,6 @@ extern int function_arg_partial_nregs (c
 				       enum machine_mode, tree, int);
 extern int function_arg_pass_by_reference (const CUMULATIVE_ARGS *,
 					   enum machine_mode, tree, int);
-extern struct rtx_def *sparc_builtin_saveregs (void);
 #ifdef RTX_CODE
 extern void init_cumulative_args (CUMULATIVE_ARGS *, tree, rtx, tree);
 extern void sparc_va_start (tree, rtx);
Index: config/sparc/sparc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.c,v
retrieving revision 1.280
diff -u -p -r1.280 sparc.c
--- config/sparc/sparc.c	27 Jan 2004 14:42:35 -0000	1.280
+++ config/sparc/sparc.c	30 Jan 2004 08:43:43 -0000
@@ -148,6 +148,7 @@ static void sparc_output_addr_vec (rtx);
 static void sparc_output_addr_diff_vec (rtx);
 static void sparc_output_deferred_case_vectors (void);
 static int check_return_regs (rtx);
+static rtx sparc_builtin_saveregs (void);
 static int epilogue_renumber (rtx *, int);
 static bool sparc_assemble_integer (rtx, unsigned int, int);
 static int set_extends (rtx);
@@ -194,6 +195,10 @@ static rtx sparc_tls_got (void);
 static const char *get_some_local_dynamic_name (void);
 static int get_some_local_dynamic_name_1 (rtx *, void *);
 static bool sparc_rtx_costs (rtx, int, int, int *);
+static bool sparc_promote_prototypes (tree);
+static rtx sparc_struct_value_rtx (tree, int);
+static bool sparc_return_in_memory (tree, tree);
+static bool sparc_strict_argument_naming (CUMULATIVE_ARGS *);
 
 /* Option handling.  */
 
@@ -277,6 +282,36 @@ enum processor_type sparc_cpu;
 #undef TARGET_ADDRESS_COST
 #define TARGET_ADDRESS_COST hook_int_rtx_0
 
+/* Return TRUE if the promotion described by PROMOTE_MODE should also be done
+   for outgoing function arguments.
+   This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
+   for TARGET_ARCH32 this is ok.  Otherwise we'd need to add a runtime test
+   for this value.  */
+#undef TARGET_PROMOTE_FUNCTION_ARGS
+#define TARGET_PROMOTE_FUNCTION_ARGS hook_bool_tree_true
+
+/* Return TRUE if the promotion described by PROMOTE_MODE should also be done
+   for the return value of functions.  If this macro is defined, FUNCTION_VALUE
+   must perform the same promotions done by PROMOTE_MODE.
+   This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
+   for TARGET_ARCH32 this is ok.  Otherwise we'd need to add a runtime test
+   for this value.  */
+#undef TARGET_PROMOTE_FUNCTION_RETURN
+#define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
+
+#undef TARGET_PROMOTE_PROTOTYPES
+#define TARGET_PROMOTE_PROTOTYPES sparc_promote_prototypes
+
+#undef TARGET_STRUCT_VALUE_RTX
+#define TARGET_STRUCT_VALUE_RTX sparc_struct_value_rtx
+#undef TARGET_RETURN_IN_MEMORY
+#define TARGET_RETURN_IN_MEMORY sparc_return_in_memory
+
+#undef TARGET_EXPAND_BUILTIN_SAVEREGS
+#define TARGET_EXPAND_BUILTIN_SAVEREGS sparc_builtin_saveregs
+#undef TARGET_STRICT_ARGUMENT_NAMING
+#define TARGET_STRICT_ARGUMENT_NAMING sparc_strict_argument_naming
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Validate and override various options, and do some machine dependent
@@ -4817,6 +4852,60 @@ init_cumulative_args (struct sparc_args 
   cum->libcall_p = fntype == 0;
 }
 
+/* Handle the PROMOTE_PROTOTYPES macro.
+   When a prototype says `char' or `short', really pass an `int'.  */
+
+static bool
+sparc_promote_prototypes (tree fntype ATTRIBUTE_UNUSED)
+{
+  return TARGET_ARCH32 ? true : false;
+}
+
+/* Handle the STRICT_ARGUMENT_NAMING macro.  */
+
+static bool
+sparc_strict_argument_naming (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED)
+{
+  /* For the V9 we want NAMED to mean what it says it means.  */
+  return TARGET_V9 ? true : false;
+}
+
+/* Handle the RETURN_IN_MEMORY macro.
+   Specify whether to return the return value in memory.  */
+
+static bool
+sparc_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
+{
+  /* SPARC ABI says that quad-precision floats and all structures are
+     returned in memory.
+     For V9: unions <= 32 bytes in size are returned in int regs,
+     structures up to 32 bytes are returned in int and fp regs.  */
+  return (TARGET_ARCH32
+	  ? (TYPE_MODE (type) == BLKmode
+	     || TYPE_MODE (type) == TFmode)
+	  : (TYPE_MODE (type) == BLKmode
+	     && (unsigned HOST_WIDE_INT) int_size_in_bytes (type) > 32));
+}
+
+/* Handle the STRUCT_VALUE macro.
+   Return where to find the structure return value address.  */
+
+static rtx
+sparc_struct_value_rtx (tree fndecl ATTRIBUTE_UNUSED, int incoming)
+{
+  if (TARGET_ARCH64)
+    return 0;
+  else
+    {
+      if (incoming)
+	return gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx,
+						  STRUCT_VALUE_OFFSET));
+      else
+	return gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx,
+						  STRUCT_VALUE_OFFSET));
+    }
+}
+
 /* Scan the record type TYPE and return the following predicates:
     - INTREGS_P: the record contains at least one field or sub-field
       that is eligible for promotion in integer registers.
@@ -5730,7 +5819,7 @@ function_value (tree type, enum machine_
    to determine if stdarg or varargs is used and return the address of
    the first unnamed parameter.  */
 
-rtx
+static rtx
 sparc_builtin_saveregs (void)
 {
   int first_reg = current_function_args_info.words;
Index: config/sparc/sparc.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/sparc/sparc.h,v
retrieving revision 1.238
diff -u -p -r1.238 sparc.h
--- config/sparc/sparc.h	27 Jan 2004 14:42:36 -0000	1.238
+++ config/sparc/sparc.h	30 Jan 2004 08:43:52 -0000
@@ -1,8 +1,8 @@
 /* Definitions of target machine for GNU compiler, for Sun SPARC.
    Copyright (C) 1987, 1988, 1989, 1992, 1994, 1995, 1996, 1997, 1998, 1999
-   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com).
-   64 bit SPARC V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
+   64-bit SPARC-V9 support by Michael Tiemann, Jim Wilson, and Doug Evans,
    at Cygnus Support.
 
 This file is part of GCC.
@@ -746,23 +746,7 @@ extern struct sparc_cpu_select sparc_sel
 if (TARGET_ARCH64				\
     && GET_MODE_CLASS (MODE) == MODE_INT	\
     && GET_MODE_SIZE (MODE) < UNITS_PER_WORD)	\
-  (MODE) = DImode;
-
-/* Define this macro if the promotion described by PROMOTE_MODE
-   should also be done for outgoing function arguments.  */
-/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
-   for TARGET_ARCH32 this is ok.  Otherwise we'd need to add a runtime test
-   for this value.  */
-#define PROMOTE_FUNCTION_ARGS
-
-/* Define this macro if the promotion described by PROMOTE_MODE
-   should also be done for the return value of functions.
-   If this macro is defined, FUNCTION_VALUE must perform the same
-   promotions done by PROMOTE_MODE.  */
-/* This is only needed for TARGET_ARCH64, but since PROMOTE_MODE is a no-op
-   for TARGET_ARCH32 this is ok.  Otherwise we'd need to add a runtime test
-   for this value.  */
-#define PROMOTE_FUNCTION_RETURN
+  (MODE) = word_mode;
 
 /* Define this macro if the promotion described by PROMOTE_MODE
    should _only_ be performed for outgoing function arguments or
@@ -1149,37 +1133,12 @@ extern int sparc_mode_class[];
 
 #define DEFAULT_PCC_STRUCT_RETURN -1
 
-/* SPARC ABI says that quad-precision floats and all structures are returned
-   in memory.
-   For v9: unions <= 32 bytes in size are returned in int regs,
-   structures up to 32 bytes are returned in int and fp regs.  */
-
-#define RETURN_IN_MEMORY(TYPE)				\
-(TARGET_ARCH32						\
- ? (TYPE_MODE (TYPE) == BLKmode				\
-    || TYPE_MODE (TYPE) == TFmode)			\
- : (TYPE_MODE (TYPE) == BLKmode				\
-    && (unsigned HOST_WIDE_INT) int_size_in_bytes (TYPE) > 32))
-
 /* Functions which return large structures get the address
    to place the wanted value at offset 64 from the frame.
    Must reserve 64 bytes for the in and local registers.
    v9: Functions which return large structures get the address to place the
    wanted value from an invisible first argument.  */
-/* Used only in other #defines in this file.  */
 #define STRUCT_VALUE_OFFSET 64
-
-#define STRUCT_VALUE \
-  (TARGET_ARCH64					\
-   ? 0							\
-   : gen_rtx_MEM (Pmode, plus_constant (stack_pointer_rtx, \
-					STRUCT_VALUE_OFFSET)))
-
-#define STRUCT_VALUE_INCOMING \
-  (TARGET_ARCH64						\
-   ? 0								\
-   : gen_rtx_MEM (Pmode, plus_constant (frame_pointer_rtx,	\
-					STRUCT_VALUE_OFFSET)))
 
 /* Define the classes of registers for register constraints in the
    machine description.  Also define ranges of constants.
@@ -1954,10 +1913,6 @@ do {									\
     else							\
       sparc_initialize_trampoline (TRAMP, FNADDR, CXT)
 
-/* Generate necessary RTL for __builtin_saveregs().  */
-
-#define EXPAND_BUILTIN_SAVEREGS() sparc_builtin_saveregs ()
-
 /* Implement `va_start' for varargs and stdarg.  */
 #define EXPAND_BUILTIN_VA_START(valist, nextarg) \
   sparc_va_start (valist, nextarg)
@@ -1966,19 +1921,6 @@ do {									\
 #define EXPAND_BUILTIN_VA_ARG(valist, type) \
   sparc_va_arg (valist, type)
 
-/* Define this macro if the location where a function argument is passed
-   depends on whether or not it is a named argument.
-
-   This macro controls how the NAMED argument to FUNCTION_ARG
-   is set for varargs and stdarg functions.  With this macro defined,
-   the NAMED argument is always true for named arguments, and false for
-   unnamed arguments.  If this is not defined, but SETUP_INCOMING_VARARGS
-   is defined, then all arguments are treated as named.  Otherwise, all named
-   arguments except the last are treated as named.
-   For the v9 we want NAMED to mean what it says it means.  */
-
-#define STRICT_ARGUMENT_NAMING TARGET_V9
-
 /* Generate RTL to flush the register windows so as to make arbitrary frames
    available.  */
 #define SETUP_FRAME_ADDRESSES()		\
@@ -2385,9 +2327,6 @@ do {                                    
    better than access by words when possible, so grab a whole word
    and maybe make use of that.  */
 #define SLOW_BYTE_ACCESS 1
-
-/* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES (TARGET_ARCH32)
 
 /* Define this to be nonzero if shift instructions ignore all but the low-order
    few bits.  */

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