diff mbox

[m68k] hookize FUNCTION_ARG &co.

Message ID 1286546294-17271-1-git-send-email-froydnj@codesourcery.com
State New
Headers show

Commit Message

Nathan Froyd Oct. 8, 2010, 1:58 p.m. UTC
The patch below hookizes FUNCTION_ARG and related macros for the m68k
backend.  Nothing special here.

Tested by inspection with cross to m68k-elf.  I plan to commit this
under the obvious rule after waiting a week for comments/approval.

	* config/m68k/m68k.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/m68k/m68k.c (m68k_function_arg): New function.
	(m68k_function_arg_advance): New function.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/m68k/m68k.c |   30 ++++++++++++++++++++++++++++++
 gcc/config/m68k/m68k.h |    8 --------
 2 files changed, 30 insertions(+), 8 deletions(-)

Comments

Andreas Schwab Oct. 8, 2010, 5:38 p.m. UTC | #1
Nathan Froyd <froydnj@codesourcery.com> writes:

> 	* config/m68k/m68k.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
> 	* config/m68k/m68k.c (m68k_function_arg): New function.
> 	(m68k_function_arg_advance): New function.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Ok.

Thanks, Andreas.
Gunther Nikl April 7, 2011, 3:25 p.m. UTC | #2
On Fri, Oct 08, 2010 at 09:58:14AM -0400, Nathan Froyd wrote:
> The patch below hookizes FUNCTION_ARG and related macros for the m68k
> backend.  Nothing special here.

With the old macro approach it was easy for a subtarget to override
these target properties. That doesn't work anymore for target hooks.
Is there a (recommended) way how a subtarget can override hook
functions?

Thanks,
Gunther
Joseph Myers April 7, 2011, 4:38 p.m. UTC | #3
On Thu, 7 Apr 2011, Gunther Nikl wrote:

> On Fri, Oct 08, 2010 at 09:58:14AM -0400, Nathan Froyd wrote:
> > The patch below hookizes FUNCTION_ARG and related macros for the m68k
> > backend.  Nothing special here.
> 
> With the old macro approach it was easy for a subtarget to override
> these target properties. That doesn't work anymore for target hooks.
> Is there a (recommended) way how a subtarget can override hook
> functions?

The implementation of the hook should contain "if" (preferred over #if) 
conditions on the particular ABI in use, which could be determined by a 
macro in subtarget headers.  (The key difference from the old system is 
that the macro is one only used within target code rather than being used 
in the target-independent compiler.)
Gunther Nikl April 14, 2011, 6:31 p.m. UTC | #4
Joseph S. Myers wrote:
> On Thu, 7 Apr 2011, Gunther Nikl wrote:
> 
>> Is there a (recommended) way how a subtarget can override hook
>> functions?
> 
> The implementation of the hook should contain "if" (preferred over #if) 
> conditions on the particular ABI in use, which could be determined by a 
> macro in subtarget headers.

Yes, that could work. Unfortunately in this particular case "if ()"
won't work because the subtarget does also override CUMULATIVE_ARGS
with a version that has additional fields. This probably means that
the only solution is to redefine the affected target hook definitions
within an #if block and the replacement functions within a similar
#if block.

Regards,
Gunther
diff mbox

Patch

diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c
index 09b7ccb..f032a47 100644
--- a/gcc/config/m68k/m68k.c
+++ b/gcc/config/m68k/m68k.c
@@ -157,6 +157,10 @@  static void m68k_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
 static void m68k_trampoline_init (rtx, tree, rtx);
 static int m68k_return_pops_args (tree, tree, int);
 static rtx m68k_delegitimize_address (rtx);
+static void m68k_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				       const_tree, bool);
+static rtx m68k_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			      const_tree, bool);
 
 
 /* Specify the identification number of the library being built */
@@ -283,6 +287,12 @@  const char *m68k_library_id_string = "_current_shared_library_a5_offset_";
 #undef TARGET_DELEGITIMIZE_ADDRESS
 #define TARGET_DELEGITIMIZE_ADDRESS m68k_delegitimize_address
 
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG m68k_function_arg
+
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE m68k_function_arg_advance
+
 static const struct attribute_spec m68k_attribute_table[] =
 {
   /* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler } */
@@ -1474,6 +1484,26 @@  m68k_ok_for_sibcall_p (tree decl, tree exp)
   return false;
 }
 
+/* On the m68k all args are always pushed.  */
+
+static rtx
+m68k_function_arg (CUMULATIVE_ARGS *cum ATTRIBUTE_UNUSED,
+		   enum machine_mode mode ATTRIBUTE_UNUSED,
+		   const_tree type ATTRIBUTE_UNUSED,
+		   bool named ATTRIBUTE_UNUSED)
+{
+  return NULL_RTX;
+}
+
+static void
+m68k_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			   const_tree type, bool named ATTRIBUTE_UNUSED)
+{
+  *cum += (mode != BLKmode
+	   ? (GET_MODE_SIZE (mode) + 3) & ~3
+	   : (int_size_in_bytes (type) + 3) & ~3);
+}
+
 /* Convert X to a legitimate function call memory reference and return the
    result.  */
 
diff --git a/gcc/config/m68k/m68k.h b/gcc/config/m68k/m68k.h
index 75217ba..5aac599 100644
--- a/gcc/config/m68k/m68k.h
+++ b/gcc/config/m68k/m68k.h
@@ -558,14 +558,6 @@  extern enum reg_class regno_reg_class[];
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
  ((CUM) = 0)
 
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)	\
- ((CUM) += ((MODE) != BLKmode			\
-	    ? (GET_MODE_SIZE (MODE) + 3) & ~3	\
-	    : (int_size_in_bytes (TYPE) + 3) & ~3))
-
-/* On the m68k all args are always pushed.  */
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) 0
-
 #define FUNCTION_PROFILER(FILE, LABELNO)  \
   asm_fprintf (FILE, "\tlea %LLP%d,%Ra0\n\tjsr mcount\n", (LABELNO))