diff mbox

[mmix] hookize FUNCTION_ARG &co.

Message ID 1286546320-17667-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 mmix
backend.  Nothing special here.

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

	* config/mmix/mmix-protos.h (mmix_function_arg): Delete.
	* config/mmix/mmix.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/mmix/mmix.c (mmix_function_arg): Rename to...
	(mmix_function_arg_1): ...this.  Make static.  Take a const_tree and
	bool arguments.
	(mmix_function_arg): New function.
	(mmix_function_incoming_arg): New function.
	(mmix_function_arg_advance): New function.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_INCOMING_ARG): Define.
	(TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/mmix/mmix-protos.h |    2 -
 gcc/config/mmix/mmix.c        |   77 +++++++++++++++++++++++++++++++++--------
 gcc/config/mmix/mmix.h        |   13 -------
 3 files changed, 62 insertions(+), 30 deletions(-)

Comments

Hans-Peter Nilsson Oct. 9, 2010, 2:04 a.m. UTC | #1
On Fri, 8 Oct 2010, Nathan Froyd wrote:

> The patch below hookizes FUNCTION_ARG and related macros for the mmix
> backend.  Nothing special here.

Depends on the value of special...

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

No, not obvious.

> 	* config/mmix/mmix-protos.h (mmix_function_arg): Delete.
> 	* config/mmix/mmix.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
> 	* config/mmix/mmix.c (mmix_function_arg): Rename to...
> 	(mmix_function_arg_1): ...this.  Make static.  Take a const_tree and
> 	bool arguments.
> 	(mmix_function_arg): New function.
> 	(mmix_function_incoming_arg): New function.
> 	(mmix_function_arg_advance): New function.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_INCOMING_ARG): Define.
> 	(TARGET_FUNCTION_ARG_ADVANCE): Define.

> --- a/gcc/config/mmix/mmix.c

> -/* INCOMING_REGNO and OUTGOING_REGNO worker function.
> -   Those two macros must only be applied to function argument
> -   registers.  FIXME: for their current use in gcc, it'd be better
> -   with an explicit specific additional FUNCTION_INCOMING_ARG_REGNO_P
> -   a'la FUNCTION_ARG / FUNCTION_INCOMING_ARG instead of forcing the
> -   target to commit to a fixed mapping and for any unspecified
> -   register use.  */
> +/* INCOMING_REGNO and OUTGOING_REGNO worker function.  Those two macros
> +   must only be applied to function argument registers.  FIXME: for
> +   their current use in gcc, it'd be better with an explicit specific
> +   additional FUNCTION_INCOMING_ARG_REGNO_P a'la TARGET_FUNCTION_ARG /
> +   TARGET_FUNCTION_INCOMING_ARG instead of forcing the target to commit
> +   to a fixed mapping and for any unspecified register use.  */

No thanks, no reformatting.  (If you actually changed something
here, it's hard to spot at a glance.)

Actually, in mmix.c I see mostly a bunch of spurious changes
(most of the macros were calling mostly-compatible functions),
so I'm going to say no.

Please, in mmix.c, just staticize the global functions and
s/int/bool/ where necessary to fit the hook prototypes, add
mmix_function_arg_advance and resubmit.  Thanks in advance.

brgds, H-P
Nathan Froyd Oct. 9, 2010, 2:14 a.m. UTC | #2
On Fri, Oct 08, 2010 at 10:04:52PM -0400, Hans-Peter Nilsson wrote:
> On Fri, 8 Oct 2010, Nathan Froyd wrote:
> > -/* INCOMING_REGNO and OUTGOING_REGNO worker function.
> > -   Those two macros must only be applied to function argument
> > -   registers.  FIXME: for their current use in gcc, it'd be better
> > -   with an explicit specific additional FUNCTION_INCOMING_ARG_REGNO_P
> > -   a'la FUNCTION_ARG / FUNCTION_INCOMING_ARG instead of forcing the
> > -   target to commit to a fixed mapping and for any unspecified
> > -   register use.  */
> > +/* INCOMING_REGNO and OUTGOING_REGNO worker function.  Those two macros
> > +   must only be applied to function argument registers.  FIXME: for
> > +   their current use in gcc, it'd be better with an explicit specific
> > +   additional FUNCTION_INCOMING_ARG_REGNO_P a'la TARGET_FUNCTION_ARG /
> > +   TARGET_FUNCTION_INCOMING_ARG instead of forcing the target to commit
> > +   to a fixed mapping and for any unspecified register use.  */
> 
> No thanks, no reformatting.  (If you actually changed something
> here, it's hard to spot at a glance.)

The only change here is to use the hook names instead of the macro
names.  I went a little overboard with M-q and missed the obvious header
line in the comment above, sorry about that.

I'm happy to use the hook names and keep the original formatting, long
lines and all.  Or I can reformat from the point of the change forward.

> Actually, in mmix.c I see mostly a bunch of spurious changes
> (most of the macros were calling mostly-compatible functions),
> so I'm going to say no.

diff could have been smarter about the changes, but I don't think
there's much spurious beyond the reformatting you pointed out above.

> Please, in mmix.c, just staticize the global functions and
> s/int/bool/ where necessary to fit the hook prototypes, add
> mmix_function_arg_advance and resubmit.  Thanks in advance.

I can't do that, because mmix_function_arg can't be used for either
TARGET_FUNCTION_ARG or TARGET_FUNCTION_INCOMING_ARG.  Hence the need to
rename it to mmix_function_arg_1 and add trivial forwarding functions.

-Nathan
Hans-Peter Nilsson Oct. 9, 2010, 10:24 a.m. UTC | #3
On Fri, 8 Oct 2010, Nathan Froyd wrote:
> I'm happy to use the hook names and keep the original formatting, long
> lines and all.  Or I can reformat from the point of the change forward.

That's what I usually try to do, so yes to the latter, thanks.

> I can't do that, because mmix_function_arg can't be used for either
> TARGET_FUNCTION_ARG or TARGET_FUNCTION_INCOMING_ARG.  Hence the need to
> rename it to mmix_function_arg_1 and add trivial forwarding functions.

I see "through the diff" now so ok with that.  Thanks for your patience. :)

brgds, H-P
diff mbox

Patch

diff --git a/gcc/config/mmix/mmix-protos.h b/gcc/config/mmix/mmix-protos.h
index d7e0a94..1f9cae0 100644
--- a/gcc/config/mmix/mmix-protos.h
+++ b/gcc/config/mmix/mmix-protos.h
@@ -59,8 +59,6 @@  extern void mmix_asm_output_aligned_common (FILE *, const char *, int, int);
 extern void mmix_asm_output_aligned_local (FILE *, const char *, int, int);
 extern void mmix_asm_declare_register_global
   (FILE *, tree, int, const char *);
-extern rtx mmix_function_arg
-  (const CUMULATIVE_ARGS *, enum machine_mode, tree, int, int);
 extern void mmix_asm_output_addr_diff_elt (FILE *, rtx, int, int);
 extern void mmix_asm_output_addr_vec_elt (FILE *, int);
 extern enum reg_class mmix_preferred_reload_class (rtx, enum reg_class);
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index 293a2f5..b364e9f 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -143,6 +143,14 @@  static rtx mmix_struct_value_rtx (tree, int);
 static enum machine_mode mmix_promote_function_mode (const_tree,
 						     enum machine_mode,
 	                                             int *, const_tree, int);
+static void mmix_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				       const_tree, bool);
+static rtx mmix_function_arg_1 (const CUMULATIVE_ARGS *, enum machine_mode,
+				const_tree, bool, bool);
+static rtx mmix_function_incoming_arg (CUMULATIVE_ARGS *, enum machine_mode,
+				       const_tree, bool);
+static rtx mmix_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			      const_tree, bool);
 static rtx mmix_function_value (const_tree, const_tree, bool);
 static rtx mmix_libcall_value (enum machine_mode, const_rtx);
 static bool mmix_function_value_regno_p (const unsigned int);
@@ -213,6 +221,12 @@  static void mmix_trampoline_init (rtx, tree, rtx);
 #undef TARGET_FUNCTION_VALUE_REGNO_P
 #define TARGET_FUNCTION_VALUE_REGNO_P mmix_function_value_regno_p
 
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG mmix_function_arg
+#undef TARGET_FUNCTION_INCOMING_ARG
+#define TARGET_FUNCTION_INCOMING_ARG mmix_function_incoming_arg
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE mmix_function_arg_advance
 #undef TARGET_STRUCT_VALUE_RTX
 #define TARGET_STRUCT_VALUE_RTX mmix_struct_value_rtx
 #undef TARGET_SETUP_INCOMING_VARARGS
@@ -365,13 +379,12 @@  mmix_conditional_register_usage (void)
 	reg_names[i]++;
 }
 
-/* INCOMING_REGNO and OUTGOING_REGNO worker function.
-   Those two macros must only be applied to function argument
-   registers.  FIXME: for their current use in gcc, it'd be better
-   with an explicit specific additional FUNCTION_INCOMING_ARG_REGNO_P
-   a'la FUNCTION_ARG / FUNCTION_INCOMING_ARG instead of forcing the
-   target to commit to a fixed mapping and for any unspecified
-   register use.  */
+/* INCOMING_REGNO and OUTGOING_REGNO worker function.  Those two macros
+   must only be applied to function argument registers.  FIXME: for
+   their current use in gcc, it'd be better with an explicit specific
+   additional FUNCTION_INCOMING_ARG_REGNO_P a'la TARGET_FUNCTION_ARG /
+   TARGET_FUNCTION_INCOMING_ARG instead of forcing the target to commit
+   to a fixed mapping and for any unspecified register use.  */
 
 int
 mmix_opposite_regno (int regno, int incoming)
@@ -622,15 +635,28 @@  mmix_initial_elimination_offset (int fromreg, int toreg)
     + (fromreg == MMIX_ARG_POINTER_REGNUM ? 0 : 8);
 }
 
-/* Return an rtx for a function argument to go in a register, and 0 for
-   one that must go on stack.  */
+static void
+mmix_function_arg_advance (CUMULATIVE_ARGS *argsp, enum machine_mode mode,
+			   const_tree type, bool named ATTRIBUTE_UNUSED)
+{
+  int arg_size = MMIX_FUNCTION_ARG_SIZE (mode, type);
 
-rtx
-mmix_function_arg (const CUMULATIVE_ARGS *argsp,
-		   enum machine_mode mode,
-		   tree type,
-		   int named ATTRIBUTE_UNUSED,
-		   int incoming)
+  argsp->regs = ((targetm.calls.must_pass_in_stack (mode, type)
+		  || (arg_size > 8
+		      && !TARGET_LIBFUNC
+		      && !argsp->lib))
+		 ? (MMIX_MAX_ARGS_IN_REGS) + 1
+		 : argsp->regs + (7 + arg_size) / 8);
+}
+
+/* Helper function for mmix_function_arg and mmix_function_incoming_arg.  */
+
+static rtx
+mmix_function_arg_1 (const CUMULATIVE_ARGS *argsp,
+		     enum machine_mode mode,
+		     const_tree type,
+		     bool named ATTRIBUTE_UNUSED,
+		     bool incoming)
 {
   /* Last-argument marker.  */
   if (type == void_type_node)
@@ -654,6 +680,27 @@  mmix_function_arg (const CUMULATIVE_ARGS *argsp,
     : NULL_RTX;
 }
 
+/* Return an rtx for a function argument to go in a register, and 0 for
+   one that must go on stack.  */
+
+static rtx
+mmix_function_arg (CUMULATIVE_ARGS *argsp,
+		   enum machine_mode mode,
+		   const_tree type,
+		   bool named)
+{
+  return mmix_function_arg_1 (argsp, mode, type, named, false);
+}
+
+static rtx
+mmix_function_incoming_arg (CUMULATIVE_ARGS *argsp,
+			    enum machine_mode mode,
+			    const_tree type,
+			    bool named)
+{
+  return mmix_function_arg_1 (argsp, mode, type, named, true);
+}
+
 /* Returns nonzero for everything that goes by reference, 0 for
    everything that goes by value.  */
 
diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index b4fc856..02d0528 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -571,25 +571,12 @@  enum reg_class
 
 
 /* Node: Register Arguments */
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED)	\
- mmix_function_arg (&(CUM), MODE, TYPE, NAMED, 0)
-
-#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED)	\
- mmix_function_arg (&(CUM), MODE, TYPE, NAMED, 1)
 
 typedef struct { int regs; int lib; } CUMULATIVE_ARGS;
 
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \
  ((CUM).regs = 0, (CUM).lib = ((LIBNAME) != 0))
 
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)		\
- ((CUM).regs							\
-  = ((targetm.calls.must_pass_in_stack (MODE, TYPE))		\
-     || (MMIX_FUNCTION_ARG_SIZE (MODE, TYPE) > 8		\
-	 && !TARGET_LIBFUNC && !(CUM).lib))			\
-  ? (MMIX_MAX_ARGS_IN_REGS) + 1					\
-  : (CUM).regs + (7 + (MMIX_FUNCTION_ARG_SIZE (MODE, TYPE))) / 8)
-
 #define FUNCTION_ARG_REGNO_P(REGNO)		\
  mmix_function_arg_regno_p (REGNO, 0)