public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] un-constify CUMULATIVE_ARGS parameter to function_arg hook
@ 2010-08-19 20:31 Nathan Froyd
  2010-08-19 21:11 ` Richard Henderson
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Froyd @ 2010-08-19 20:31 UTC (permalink / raw)
  To: gcc-patches

In my naivete, I assumed that because the first target (i386) I hookized
for FUNCTION_ARG and friends didn't modify its CUMULATIVE_ARGS
parameter, the parameter could be const.  Alas, this was not to be, as
several other targets *do* modify the CUMULATIVE_ARGS parameter (a
common reason to do so being to accommodate aligned multi-word register
arguments).  This seems like bad style, though I suppose there is a
small efficiency argument to be made.

I had a look at untangling such targets, but that quickly became a
quagmire.  Therefore, I am proposing this patch, which unconst-ifies
the CUMULATIVE_ARGS parameter to FUNCTION_{INCOMING_,}ARG and should
therefore make hookizing the remaining targets proceed more smoothly.

I think this patch qualifies as obvious.  However, I will wait until the
middle of next week before committing to give time for discussion.  If
people have comments, or they think I should just buck up and untangle
the targets in question, please feel free to speak up.  Explicit
approvals also welcome.

Tested on x86_64-unknown-linux-gnu.

-Nathan

	* target.def (function_arg, function_incoming_arg): Remove const
	qualifier on CUMULATIVE_ARGS parameter.
	* targhooks.h (default_function_arg, default_function_incoming_arg):
	Likewise.
	* targhooks.c (default_function_arg, default_function_incoming_arg):
	Likewise.
	* config/i386/i386.c (ix86_function_arg): Likewise.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index c90d576..0bc1c66 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -6466,7 +6466,7 @@ function_arg_ms_64 (const CUMULATIVE_ARGS *cum, enum machine_mode mode,
    ellipsis).  */
 
 static rtx
-ix86_function_arg (const CUMULATIVE_ARGS *cum, enum machine_mode omode,
+ix86_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode omode,
 		   const_tree type, bool named)
 {
   enum machine_mode mode = omode;
diff --git a/gcc/target.def b/gcc/target.def
index 46e3ef7..3ca3f36 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -1788,7 +1788,7 @@ DEFHOOK_UNDOC
 DEFHOOK_UNDOC
 (function_arg,
  "",
- rtx, (const CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
+ rtx, (CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
        bool named),
  default_function_arg)
 
@@ -1798,7 +1798,7 @@ DEFHOOK_UNDOC
 DEFHOOK_UNDOC
 (function_incoming_arg,
  "",
- rtx, (const CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
+ rtx, (CUMULATIVE_ARGS *ca, enum machine_mode mode, const_tree type,
        bool named),
  default_function_incoming_arg)
 
diff --git a/gcc/targhooks.c b/gcc/targhooks.c
index 9898225..f8cb522 100644
--- a/gcc/targhooks.c
+++ b/gcc/targhooks.c
@@ -568,28 +568,26 @@ default_function_arg_advance (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
 }
 
 rtx
-default_function_arg (const CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+default_function_arg (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
 		      enum machine_mode mode ATTRIBUTE_UNUSED,
 		      const_tree type ATTRIBUTE_UNUSED,
 		      bool named ATTRIBUTE_UNUSED)
 {
 #ifdef FUNCTION_ARG
-  return FUNCTION_ARG (*(CONST_CAST (CUMULATIVE_ARGS *, ca)), mode,
-		       CONST_CAST_TREE (type), named);
+  return FUNCTION_ARG (*ca, mode, CONST_CAST_TREE (type), named);
 #else
   gcc_unreachable ();
 #endif
 }
 
 rtx
-default_function_incoming_arg (const CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
+default_function_incoming_arg (CUMULATIVE_ARGS *ca ATTRIBUTE_UNUSED,
 			       enum machine_mode mode ATTRIBUTE_UNUSED,
 			       const_tree type ATTRIBUTE_UNUSED,
 			       bool named ATTRIBUTE_UNUSED)
 {
 #ifdef FUNCTION_INCOMING_ARG
-  return FUNCTION_INCOMING_ARG (*(CONST_CAST (CUMULATIVE_ARGS *, ca)), mode,
-				CONST_CAST_TREE (type), named);
+  return FUNCTION_INCOMING_ARG (*ca, mode, CONST_CAST_TREE (type), named);
 #else
   gcc_unreachable ();
 #endif
diff --git a/gcc/targhooks.h b/gcc/targhooks.h
index bc43bc2..75b3191 100644
--- a/gcc/targhooks.h
+++ b/gcc/targhooks.h
@@ -104,9 +104,9 @@ extern const char *hook_invalid_arg_for_unprototyped_fn
 extern void default_function_arg_advance
   (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
 extern rtx default_function_arg
-  (const CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
+  (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
 extern rtx default_function_incoming_arg
-  (const CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
+  (CUMULATIVE_ARGS *, enum machine_mode, const_tree, bool);
 extern bool hook_bool_const_rtx_commutative_p (const_rtx, int);
 extern rtx default_function_value (const_tree, const_tree, bool);
 extern rtx default_libcall_value (enum machine_mode, const_rtx);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] un-constify CUMULATIVE_ARGS parameter to function_arg hook
  2010-08-19 20:31 [PATCH] un-constify CUMULATIVE_ARGS parameter to function_arg hook Nathan Froyd
@ 2010-08-19 21:11 ` Richard Henderson
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2010-08-19 21:11 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: gcc-patches

On 08/19/2010 12:51 PM, Nathan Froyd wrote:
> I think this patch qualifies as obvious.  However, I will wait until the
> middle of next week before committing to give time for discussion.  If
> people have comments, or they think I should just buck up and untangle
> the targets in question, please feel free to speak up.  Explicit
> approvals also welcome.

Patch is ok as-is.

I don't think there's anything a target can do to avoid this
modification in some circumstances.  Nor should it try.


r~

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-08-19 19:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-19 20:31 [PATCH] un-constify CUMULATIVE_ARGS parameter to function_arg hook Nathan Froyd
2010-08-19 21:11 ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).