Patchwork [picochip] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Oct. 8, 2010, 1:58 p.m.
Message ID <1286546305-17439-1-git-send-email-froydnj@codesourcery.com>
Download mbox | patch
Permalink /patch/67202/
State New
Headers show

Comments

Nathan Froyd - Oct. 8, 2010, 1:58 p.m.
The patch below hookizes FUNCTION_ARG and related macros for the
picochip backend.  The only odd thing is that the hook functions are not
made static, in accordance with what appears to be picochip.c policy.

I'm not sure how to test this port; binutils doesn't appear to support
it.  I think the changes are trivial, though.  I plan to commit this
under the obvious rule after waiting a week for comments/approval.

	* config/picochip/picochip-protos.h (picochip_function_arg): Delete.
	(picochip_incoming_function_arg): Delete.
	(picochip_arg_advance): Delete.
	* config/picochip/picochip.h (FUNCTION_ARG): Delete.
	(FUNCTION_INCOMING_ARG): Delete.
	(FUNCTION_ARG_ADVANCE): Delete.
	* config/picochip/picochip.c (picochip_function_arg): Take a
	const_tree and a bool.
	(picochip_incoming_function_arg): Likewise.
	(picochip_arg_advance): Likewise.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_INCOMING_ARG): Define.
	(TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/picochip/picochip-protos.h |    7 ----
 gcc/config/picochip/picochip.c        |   53 +++++++++++++++++++++-----------
 gcc/config/picochip/picochip.h        |   13 --------
 3 files changed, 35 insertions(+), 38 deletions(-)
Hariharan Sandanagobalane - Oct. 11, 2010, 2:52 p.m.
Hi Nathan,
The patch didn't compile for mismatch of argument types (const 
CUMULATIVE_ARGS vs non-const) etc. I have corrected them and committed 
to mainline as r165312.

Cheers
Hari

On 08/10/10 14:58, Nathan Froyd wrote:
> The patch below hookizes FUNCTION_ARG and related macros for the
> picochip backend.  The only odd thing is that the hook functions are not
> made static, in accordance with what appears to be picochip.c policy.
>
> I'm not sure how to test this port; binutils doesn't appear to support
> it.  I think the changes are trivial, though.  I plan to commit this
> under the obvious rule after waiting a week for comments/approval.
>
> 	* config/picochip/picochip-protos.h (picochip_function_arg): Delete.
> 	(picochip_incoming_function_arg): Delete.
> 	(picochip_arg_advance): Delete.
> 	* config/picochip/picochip.h (FUNCTION_ARG): Delete.
> 	(FUNCTION_INCOMING_ARG): Delete.
> 	(FUNCTION_ARG_ADVANCE): Delete.
> 	* config/picochip/picochip.c (picochip_function_arg): Take a
> 	const_tree and a bool.
> 	(picochip_incoming_function_arg): Likewise.
> 	(picochip_arg_advance): Likewise.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_INCOMING_ARG): Define.
> 	(TARGET_FUNCTION_ARG_ADVANCE): Define.
> ---
>   gcc/config/picochip/picochip-protos.h |    7 ----
>   gcc/config/picochip/picochip.c        |   53 +++++++++++++++++++++-----------
>   gcc/config/picochip/picochip.h        |   13 --------
>   3 files changed, 35 insertions(+), 38 deletions(-)
>
> diff --git a/gcc/config/picochip/picochip-protos.h b/gcc/config/picochip/picochip-protos.h
> index 4acfdb0..b3755a6 100644
> --- a/gcc/config/picochip/picochip-protos.h
> +++ b/gcc/config/picochip/picochip-protos.h
> @@ -54,13 +54,6 @@ extern bool ok_to_peephole_ldw(rtx opnd0, rtx opnd1, rtx opnd2, rtx opnd3);
>
>   extern rtx gen_min_reg(rtx opnd1,rtx opnd2);
>
> -extern rtx picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
> -			   int named);
> -
> -extern rtx picochip_incoming_function_arg (CUMULATIVE_ARGS, int, tree, int);
> -extern CUMULATIVE_ARGS picochip_arg_advance (CUMULATIVE_ARGS cum, int mode,
> -				      tree type, int named);
> -
>   extern int picochip_regno_nregs (int regno, int mode);
>   extern int picochip_class_max_nregs (int klass, int mode);
>
> diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
> index 9656583..985fd10 100644
> --- a/gcc/config/picochip/picochip.c
> +++ b/gcc/config/picochip/picochip.c
> @@ -81,6 +81,14 @@ void picochip_reorg (void);
>   int picochip_arg_partial_bytes (CUMULATIVE_ARGS * p_cum,
>   				       enum machine_mode mode,
>   				       tree type, bool named);
> +rtx picochip_function_arg (const CUMULATIVE_ARGS * p_cum,
> +			   enum machine_mode mode,
> +			   const_tree type, bool named);
> +rtx picochip_incoming_function_arg (const CUMULATIVE_ARGS * p_cum,
> +				    enum machine_mode mode,
> +				    const_tree type, bool named);
> +void picochip_arg_advance (CUMULATIVE_ARGS * p_cum, enum machine_mode mode,
> +			   const_tree type, bool named);
>
>   int picochip_sched_lookahead (void);
>   int picochip_sched_issue_rate (void);
> @@ -262,6 +270,15 @@ static char picochip_get_vliw_alu_id (void);
>   #undef TARGET_ARG_PARTIAL_BYTES
>   #define TARGET_ARG_PARTIAL_BYTES picochip_arg_partial_bytes
>
> +#undef TARGET_FUNCTION_ARG
> +#define TARGET_FUNCTION_ARG picochip_function_arg
> +
> +#undef TARGET_FUNCTION_INCOMING_ARG
> +#define TARGET_FUNCTION_INCOMING_ARG picochip_incoming_function_arg
> +
> +#undef TARGET_FUNCTION_ARG_ADVANCE
> +#define TARGET_FUNCTION_ARG_ADVANCE picochip_arg_advance
> +
>   #undef TARGET_PROMOTE_FUNCTION_MODE
>   #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
>   #undef TARGET_PROMOTE_PROTOTYPES
> @@ -814,8 +831,8 @@ picochip_compute_arg_size (tree type, enum machine_mode mode)
>
>   /* Determine where the next outgoing arg should be placed. */
>   rtx
> -picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
> -		       int named ATTRIBUTE_UNUSED)
> +picochip_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
> +		       const_tree type, bool named ATTRIBUTE_UNUSED)
>   {
>     int reg = 0;
>     int type_align_in_units = 0;
> @@ -835,17 +852,17 @@ picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
>
>     /* Compute the correct offset (i.e., ensure that the offset meets
>        the alignment requirements). */
> -  offset_overflow = cum % type_align_in_units;
> +  offset_overflow = *cum % type_align_in_units;
>     if (offset_overflow == 0)
> -    new_offset = cum;
> +    new_offset = *cum;
>     else
> -    new_offset = (cum - offset_overflow) + type_align_in_units;
> +    new_offset = (*cum - offset_overflow) + type_align_in_units;
>
>     if (TARGET_DEBUG)
>       {
>         printf ("Function arg:\n");
>         printf ("  Type valid: %s\n", (type ? "yes" : "no"));
> -      printf ("  Cumulative Value: %d\n", cum);
> +      printf ("  Cumulative Value: %d\n", *cum);
>         printf ("  Mode: %s\n", GET_MODE_NAME (mode));
>         printf ("  Type size: %i units\n", type_size_in_units);
>         printf ("  Alignment: %i units\n", type_align_in_units);
> @@ -879,7 +896,7 @@ picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
>       case CSImode:
>       case SCmode:
>       case CQImode:
> -      return gen_rtx_REG ((enum machine_mode) mode, reg);
> +      return gen_rtx_REG (mode, reg);
>
>       case BLKmode:
>         {
> @@ -912,8 +929,9 @@ picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
>      passed in registers, which are then pushed onto the stack by the
>      function prologue). */
>   rtx
> -picochip_incoming_function_arg (CUMULATIVE_ARGS cum, int mode,
> -				tree type, int named)
> +picochip_incoming_function_arg (CUMULATIVE_ARGS *cum,
> +				enum machine_mode mode,
> +				const_tree type, bool named)
>   {
>
>     if (cfun->stdarg)
> @@ -998,10 +1016,10 @@ picochip_arg_partial_bytes (CUMULATIVE_ARGS * p_cum, enum machine_mode mode,
>
>   }
>
> -/* Advance the cumulative args counter, returning the new counter. */
> -CUMULATIVE_ARGS
> -picochip_arg_advance (const CUMULATIVE_ARGS cum, int mode,
> -		      tree type, int named ATTRIBUTE_UNUSED)
> +/* Advance the cumulative args counter CUM. */
> +void
> +picochip_arg_advance (CUMULATIVE_ARGS *cum, int mode,
> +		      const_tree type, bool named ATTRIBUTE_UNUSED)
>   {
>     int type_align_in_units = 0;
>     int type_size_in_units;
> @@ -1020,17 +1038,16 @@ picochip_arg_advance (const CUMULATIVE_ARGS cum, int mode,
>
>     /* Compute the correct offset (i.e., ensure that the offset meets
>        the alignment requirements). */
> -  offset_overflow = cum % type_align_in_units;
> +  offset_overflow = *cum % type_align_in_units;
>     if (offset_overflow == 0)
> -    new_offset = cum;
> +    new_offset = *cum;
>     else
> -    new_offset = (cum - offset_overflow) + type_align_in_units;
> +    new_offset = (*cum - offset_overflow) + type_align_in_units;
>
>     /* Advance past the last argument. */
>     new_offset += type_size_in_units;
>
> -  return new_offset;
> -
> +  *cum = new_offset;
>   }
>
>   /* Determine whether a register needs saving/restoring. It does if it
> diff --git a/gcc/config/picochip/picochip.h b/gcc/config/picochip/picochip.h
> index cf81f59..61571d6 100644
> --- a/gcc/config/picochip/picochip.h
> +++ b/gcc/config/picochip/picochip.h
> @@ -405,22 +405,9 @@ extern const enum reg_class picochip_regno_reg_class[FIRST_PSEUDO_REGISTER];
>   /* Store the offset of the next argument. */
>   #define CUMULATIVE_ARGS unsigned
>
> -/* Decide how function arguments are handled. */
> -#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
> -  picochip_function_arg (CUM, MODE, TYPE, NAMED)
> -
> -/* Incoming arguments are always the same as normal arguments, except
> -   for a function which uses variadic arguments, in which case all
> -   arguments are effectively passed on the stack. */
> -#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
> -  picochip_incoming_function_arg(CUM, MODE, TYPE, NAMED)
> -
>   #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
>     ((CUM) = 0)
>
> -#define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
> -  (CUM) = picochip_arg_advance (CUM, MODE, TYPE, NAMED)
> -
>   /* Originally this used TYPE_ALIGN to determine the
>      alignment.  Unfortunately, this fails in some cases, because the
>      type is unknown (e.g., libcall's). Instead, use GET_MODE_ALIGNMENT
Nathan Froyd - Oct. 11, 2010, 2:55 p.m.
On Mon, Oct 11, 2010 at 03:52:38PM +0100, Hariharan Sandanagobalane wrote:
> The patch didn't compile for mismatch of argument types (const
> CUMULATIVE_ARGS vs non-const) etc. I have corrected them and
> committed to mainline as r165312.

Thank you!

-Nathan

Patch

diff --git a/gcc/config/picochip/picochip-protos.h b/gcc/config/picochip/picochip-protos.h
index 4acfdb0..b3755a6 100644
--- a/gcc/config/picochip/picochip-protos.h
+++ b/gcc/config/picochip/picochip-protos.h
@@ -54,13 +54,6 @@  extern bool ok_to_peephole_ldw(rtx opnd0, rtx opnd1, rtx opnd2, rtx opnd3);
 
 extern rtx gen_min_reg(rtx opnd1,rtx opnd2);
 
-extern rtx picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
-			   int named);
-
-extern rtx picochip_incoming_function_arg (CUMULATIVE_ARGS, int, tree, int);
-extern CUMULATIVE_ARGS picochip_arg_advance (CUMULATIVE_ARGS cum, int mode,
-				      tree type, int named);
-
 extern int picochip_regno_nregs (int regno, int mode);
 extern int picochip_class_max_nregs (int klass, int mode);
 
diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c
index 9656583..985fd10 100644
--- a/gcc/config/picochip/picochip.c
+++ b/gcc/config/picochip/picochip.c
@@ -81,6 +81,14 @@  void picochip_reorg (void);
 int picochip_arg_partial_bytes (CUMULATIVE_ARGS * p_cum,
 				       enum machine_mode mode,
 				       tree type, bool named);
+rtx picochip_function_arg (const CUMULATIVE_ARGS * p_cum,
+			   enum machine_mode mode,
+			   const_tree type, bool named);
+rtx picochip_incoming_function_arg (const CUMULATIVE_ARGS * p_cum,
+				    enum machine_mode mode,
+				    const_tree type, bool named);
+void picochip_arg_advance (CUMULATIVE_ARGS * p_cum, enum machine_mode mode,
+			   const_tree type, bool named);
 
 int picochip_sched_lookahead (void);
 int picochip_sched_issue_rate (void);
@@ -262,6 +270,15 @@  static char picochip_get_vliw_alu_id (void);
 #undef TARGET_ARG_PARTIAL_BYTES
 #define TARGET_ARG_PARTIAL_BYTES picochip_arg_partial_bytes
 
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG picochip_function_arg
+
+#undef TARGET_FUNCTION_INCOMING_ARG
+#define TARGET_FUNCTION_INCOMING_ARG picochip_incoming_function_arg
+
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE picochip_arg_advance
+
 #undef TARGET_PROMOTE_FUNCTION_MODE
 #define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote
 #undef TARGET_PROMOTE_PROTOTYPES
@@ -814,8 +831,8 @@  picochip_compute_arg_size (tree type, enum machine_mode mode)
 
 /* Determine where the next outgoing arg should be placed. */
 rtx
-picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
-		       int named ATTRIBUTE_UNUSED)
+picochip_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		       const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int reg = 0;
   int type_align_in_units = 0;
@@ -835,17 +852,17 @@  picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
 
   /* Compute the correct offset (i.e., ensure that the offset meets
      the alignment requirements). */
-  offset_overflow = cum % type_align_in_units;
+  offset_overflow = *cum % type_align_in_units;
   if (offset_overflow == 0)
-    new_offset = cum;
+    new_offset = *cum;
   else
-    new_offset = (cum - offset_overflow) + type_align_in_units;
+    new_offset = (*cum - offset_overflow) + type_align_in_units;
 
   if (TARGET_DEBUG)
     {
       printf ("Function arg:\n");
       printf ("  Type valid: %s\n", (type ? "yes" : "no"));
-      printf ("  Cumulative Value: %d\n", cum);
+      printf ("  Cumulative Value: %d\n", *cum);
       printf ("  Mode: %s\n", GET_MODE_NAME (mode));
       printf ("  Type size: %i units\n", type_size_in_units);
       printf ("  Alignment: %i units\n", type_align_in_units);
@@ -879,7 +896,7 @@  picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
     case CSImode:
     case SCmode:
     case CQImode:
-      return gen_rtx_REG ((enum machine_mode) mode, reg);
+      return gen_rtx_REG (mode, reg);
 
     case BLKmode:
       {
@@ -912,8 +929,9 @@  picochip_function_arg (CUMULATIVE_ARGS cum, int mode, tree type,
    passed in registers, which are then pushed onto the stack by the
    function prologue). */
 rtx
-picochip_incoming_function_arg (CUMULATIVE_ARGS cum, int mode,
-				tree type, int named)
+picochip_incoming_function_arg (CUMULATIVE_ARGS *cum,
+				enum machine_mode mode,
+				const_tree type, bool named)
 {
 
   if (cfun->stdarg)
@@ -998,10 +1016,10 @@  picochip_arg_partial_bytes (CUMULATIVE_ARGS * p_cum, enum machine_mode mode,
 
 }
 
-/* Advance the cumulative args counter, returning the new counter. */
-CUMULATIVE_ARGS
-picochip_arg_advance (const CUMULATIVE_ARGS cum, int mode,
-		      tree type, int named ATTRIBUTE_UNUSED)
+/* Advance the cumulative args counter CUM. */
+void
+picochip_arg_advance (CUMULATIVE_ARGS *cum, int mode,
+		      const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int type_align_in_units = 0;
   int type_size_in_units;
@@ -1020,17 +1038,16 @@  picochip_arg_advance (const CUMULATIVE_ARGS cum, int mode,
 
   /* Compute the correct offset (i.e., ensure that the offset meets
      the alignment requirements). */
-  offset_overflow = cum % type_align_in_units;
+  offset_overflow = *cum % type_align_in_units;
   if (offset_overflow == 0)
-    new_offset = cum;
+    new_offset = *cum;
   else
-    new_offset = (cum - offset_overflow) + type_align_in_units;
+    new_offset = (*cum - offset_overflow) + type_align_in_units;
 
   /* Advance past the last argument. */
   new_offset += type_size_in_units;
 
-  return new_offset;
-
+  *cum = new_offset;
 }
 
 /* Determine whether a register needs saving/restoring. It does if it
diff --git a/gcc/config/picochip/picochip.h b/gcc/config/picochip/picochip.h
index cf81f59..61571d6 100644
--- a/gcc/config/picochip/picochip.h
+++ b/gcc/config/picochip/picochip.h
@@ -405,22 +405,9 @@  extern const enum reg_class picochip_regno_reg_class[FIRST_PSEUDO_REGISTER];
 /* Store the offset of the next argument. */
 #define CUMULATIVE_ARGS unsigned
 
-/* Decide how function arguments are handled. */
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) \
-  picochip_function_arg (CUM, MODE, TYPE, NAMED)
-
-/* Incoming arguments are always the same as normal arguments, except
-   for a function which uses variadic arguments, in which case all
-   arguments are effectively passed on the stack. */
-#define FUNCTION_INCOMING_ARG(CUM, MODE, TYPE, NAMED) \
-  picochip_incoming_function_arg(CUM, MODE, TYPE, NAMED)
-
 #define INIT_CUMULATIVE_ARGS(CUM,FNTYPE,LIBNAME,INDIRECT,N_NAMED_ARGS) \
   ((CUM) = 0)
 
-#define FUNCTION_ARG_ADVANCE(CUM,MODE,TYPE,NAMED) \
-  (CUM) = picochip_arg_advance (CUM, MODE, TYPE, NAMED)
-
 /* Originally this used TYPE_ALIGN to determine the
    alignment.  Unfortunately, this fails in some cases, because the
    type is unknown (e.g., libcall's). Instead, use GET_MODE_ALIGNMENT