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] mcore: Hookize some target macros.


Hi,

Attached is a patch to hookize some target macros.

Built cc1 of mcore-elf.  OK to apply?

Kazu Hirata

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

	* config/mcore/mcore-protos.h: Remove the prototype for
	mcore_setup_incoming_varargs.
	* config/mcore/mcore.c (TARGET_ASM_EXTERNAL_LIBCALL): New.
	(TARGET_PROMOTE_FUNCTION_ARGS): Likewise.
	(TARGET_PROMOTE_FUNCTION_RETURN): Likewise.
	(TARGET_PROMOTE_PROTOTYPES): Likewise.
	(TARGET_STRUCT_VALUE_RTX): Likewise.
	(TARGET_RETURN_IN_MEMORY): Likewise.
	(TARGET_SETUP_INCOMING_VARARGS): Likewise.
	(mcore_setup_incoming_varargs): Make it static.  Receive the
	first argument by reference.  Add argument second_time.
	(mcore_external_libcall): New.
	(mcore_return_in_memory): Likewise.
	* config/mcore/mcore.h (PROMOTE_FUNCTION_ARGS): New.
	(PROMOTE_FUNCTION_RETURN): Likewise.
	(STRUCT_VALUE): Likewise.
	(RETURN_IN_MEMORY): Likewise.
	(SETUP_INCOMING_VARARGS): Likewise.
	(PROMOTE_PROTOTYPES): Likewise.
	(ASM_OUTPUT_EXTERNAL_LIBCALL): Likewise.

Index: mcore-protos.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mcore/mcore-protos.h,v
retrieving revision 1.15
diff -u -r1.15 mcore-protos.h
--- mcore-protos.h	2 Oct 2003 10:48:54 -0000	1.15
+++ mcore-protos.h	25 Jan 2004 07:23:07 -0000
@@ -1,5 +1,5 @@
 /* Prototypes for exported functions defined in mcore.c
-   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
    Contributed by Nick Clifton (nickc@redhat.com)
 
    This file is part of GCC.
@@ -37,7 +37,6 @@
 #ifdef TREE_CODE
 #ifdef HAVE_MACHINE_MODES
 extern int          mcore_function_arg_partial_nregs	(CUMULATIVE_ARGS, enum machine_mode, tree, int);
-extern void         mcore_setup_incoming_varargs	(CUMULATIVE_ARGS, enum machine_mode, tree, int *);
 extern int          mcore_num_arg_regs           	(enum machine_mode, tree);
 extern int          mcore_must_pass_on_stack     	(enum machine_mode, tree);
 #endif /* HAVE_MACHINE_MODES */
Index: mcore.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mcore/mcore.c,v
retrieving revision 1.55
diff -u -r1.55 mcore.c
--- mcore.c	11 Jan 2004 08:15:32 -0000	1.55
+++ mcore.c	25 Jan 2004 07:23:08 -0000
@@ -1,5 +1,6 @@
 /* Output routines for Motorola MCore processor
-   Copyright (C) 1993, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1999, 2000, 2001, 2002, 2003, 2004
+   Free Software Foundation, Inc.
 
    This file is part of GCC.
 
@@ -123,6 +124,7 @@
 static const char *     output_inline_const     (enum machine_mode, rtx *);
 static void       block_move_sequence           (rtx, rtx, rtx, rtx, int, int, int);
 static void       layout_mcore_frame            (struct mcore_frame *);
+static void       mcore_setup_incoming_varargs	(CUMULATIVE_ARGS *, enum machine_mode, tree, int *, int);
 static cond_type  is_cond_candidate             (rtx);
 static rtx        emit_new_cond_insn            (rtx, int);
 static rtx        conditionalize_block          (rtx);
@@ -146,8 +148,14 @@
 static int        mcore_and_cost               	(rtx);
 static int        mcore_ior_cost               	(rtx);
 static bool       mcore_rtx_costs		(rtx, int, int, int *);
+static void       mcore_external_libcall	(rtx);
+static bool       mcore_return_in_memory	(tree, tree);
+
 
 /* Initialize the GCC target structure.  */
+#undef  TARGET_ASM_EXTERNAL_LIBCALL
+#define TARGET_ASM_EXTERNAL_LIBCALL	mcore_external_libcall
+
 #ifdef TARGET_DLLIMPORT_DECL_ATTRIBUTES
 #undef  TARGET_MERGE_DECL_ATTRIBUTES
 #define TARGET_MERGE_DECL_ATTRIBUTES	merge_dllimport_decl_attributes
@@ -175,6 +183,21 @@
 #undef  TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG	mcore_reorg
 
+#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		mcore_return_in_memory
+
+#undef  TARGET_SETUP_INCOMING_VARARGS
+#define TARGET_SETUP_INCOMING_VARARGS	mcore_setup_incoming_varargs
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Adjust the stack and return the number of bytes taken to do it.  */
@@ -2188,22 +2211,23 @@
 
 /* Keep track of some information about varargs for the prolog.  */
 
-void
-mcore_setup_incoming_varargs (CUMULATIVE_ARGS args_so_far,
+static void
+mcore_setup_incoming_varargs (CUMULATIVE_ARGS *args_so_far,
 			      enum machine_mode mode, tree type,
-			      int * ptr_pretend_size ATTRIBUTE_UNUSED)
+			      int * ptr_pretend_size ATTRIBUTE_UNUSED,
+			      int second_time ATTRIBUTE_UNUSED)
 {
   current_function_anonymous_args = 1;
 
   /* We need to know how many argument registers are used before
      the varargs start, so that we can push the remaining argument
      registers during the prologue.  */
-  number_of_regs_before_varargs = args_so_far + mcore_num_arg_regs (mode, type);
+  number_of_regs_before_varargs = *args_so_far + mcore_num_arg_regs (mode, type);
   
   /* There is a bug somewhere in the arg handling code.
      Until I can find it this workaround always pushes the
      last named argument onto the stack.  */
-  number_of_regs_before_varargs = args_so_far;
+  number_of_regs_before_varargs = *args_so_far;
   
   /* The last named argument may be split between argument registers
      and the stack.  Allow for this here.  */
@@ -3428,3 +3452,17 @@
   fprintf (asm_out_file, "\t.section %s\n", name);
 }
 #endif /* OBJECT_FORMAT_ELF */
+
+static void
+mcore_external_libcall (rtx fun)
+{
+  fprintf (asm_out_file, "\t.import\t");
+  assemble_name (asm_out_file, XSTR (fun, 0));
+  fprintf (asm_out_file, "\n");
+}
+
+static bool
+mcore_return_in_memory (tree type, tree fntype ATTRIBUTE_UNUSED)
+{
+  return int_size_in_bytes (type) > 2 * UNITS_PER_WORD;
+}
Index: mcore.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mcore/mcore.h,v
retrieving revision 1.57
diff -u -r1.57 mcore.h
--- mcore.h	11 Jan 2004 08:15:33 -0000	1.57
+++ mcore.h	25 Jan 2004 07:23:09 -0000
@@ -1,6 +1,6 @@
 /* Definitions of target machine for GNU compiler,
    for Motorola M*CORE Processor.
-   Copyright (C) 1993, 1999, 2000, 2001, 2002, 2003
+   Copyright (C) 1993, 1999, 2000, 2001, 2002, 2003, 2004
    Free Software Foundation, Inc.
 
    This file is part of GCC.
@@ -216,10 +216,6 @@
       (UNSIGNEDP) = 1;				\
     }
 
-#define PROMOTE_FUNCTION_ARGS
-
-#define PROMOTE_FUNCTION_RETURN
-
 /* Define this if most significant bit is lowest numbered
    in instructions that operate on numbered bit-fields.  */
 #define BITS_BIG_ENDIAN  0
@@ -435,9 +431,6 @@
 #define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \
   OFFSET = mcore_initial_elimination_offset (FROM, TO)
 
-/* Place that structure value return address is placed.  */
-#define STRUCT_VALUE 0
-
 /* Define the classes of registers for register constraints in the
    machine description.  Also define ranges of constants.
 
@@ -661,9 +654,6 @@
    we want to retain compatibility with older gcc versions.  */
 #define DEFAULT_PCC_STRUCT_RETURN 0
 
-/* How many registers to use for struct return.  */
-#define	RETURN_IN_MEMORY(TYPE) (int_size_in_bytes (TYPE) > 2 * UNITS_PER_WORD)
-
 /* Define how to find the value returned by a library function
    assuming the value has mode MODE.  */
 #define LIBCALL_VALUE(MODE)  gen_rtx (REG, MODE, FIRST_RET_REG)
@@ -741,11 +731,6 @@
 #define FUNCTION_ARG_PARTIAL_NREGS(CUM, MODE, TYPE, NAMED) \
   mcore_function_arg_partial_nregs (CUM, MODE, TYPE, NAMED)
 
-/* Perform any needed actions needed for a function that is receiving a
-   variable number of arguments.  */
-#define SETUP_INCOMING_VARARGS(ASF, MODE, TYPE, PAS, ST) \
-  mcore_setup_incoming_varargs (ASF, MODE, TYPE, & PAS)
-
 /* Call the function profiler with a given profile label.  */
 #define FUNCTION_PROFILER(STREAM,LABELNO)		\
 {							\
@@ -962,9 +947,6 @@
 /* Why is this defined??? -- dac */
 #define NO_FUNCTION_CSE 1
 
-/* Chars and shorts should be passed as ints.  */
-#define PROMOTE_PROTOTYPES 1
-
 /* The machine modes of pointers and functions.  */
 #define Pmode          SImode
 #define FUNCTION_MODE  Pmode
@@ -1163,18 +1145,6 @@
    inlined member functions (or any inlined function) to be instantiated
    regardless of whether any call sites remain.
    This makes this aspect of the compiler non-ABI compliant.  */
-
-/* Similar, but for libcall. FUN is an rtx.  */
-#undef  ASM_OUTPUT_EXTERNAL_LIBCALL
-#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN)	\
-  do						\
-    {						\
-      fprintf (FILE, "\t.import\t");		\
-      assemble_name (FILE, XSTR (FUN, 0));	\
-      fprintf (FILE, "\n");			\
-    }						\
-  while (0)
-
 
 /* This says how to output an assembler line
    to define a local common symbol....  */


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