Patchwork [avr] hookize FUNCTION_ARG &co.

login
register
mail settings
Submitter Nathan Froyd
Date Oct. 8, 2010, 1:58 p.m.
Message ID <1286546329-17801-1-git-send-email-froydnj@codesourcery.com>
Download mbox | patch
Permalink /patch/67222/
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 avr
backend.  Nothing special here.

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

	* config/avr/avr-protos.h (function_arg): Delete.
	(function_arg_advance): Delete.
	* config/avr/avr.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
	* config/avr/avr.c (function_arg): Rename to...
	(avr_function_arg): ...this.  Make static.  Take a const_tree and
	a bool.
	(function_arg_advance):	Rename to...
	(avr_function_arg_advance): ...this.  Make static.  Take a
	const_tree and a bool.
	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.
---
 gcc/config/avr/avr-protos.h |    7 -------
 gcc/config/avr/avr.c        |   20 ++++++++++++++------
 gcc/config/avr/avr.h        |    5 -----
 3 files changed, 14 insertions(+), 18 deletions(-)
Weddington, Eric - Oct. 8, 2010, 2:55 p.m.
> -----Original Message-----
> From: Nathan Froyd [mailto:froydnj@codesourcery.com] 
> Sent: Friday, October 08, 2010 7:59 AM
> To: gcc-patches@gcc.gnu.org
> Cc: chertykov@gmail.com; Weddington, Eric
> Subject: [avr] hookize FUNCTION_ARG &co.
> 
> The patch below hookizes FUNCTION_ARG and related macros for the avr
> backend.  Nothing special here.
> 
> Tested by inspection with cross to avr-elf.  I plan to commit this
> under the obvious rule after waiting a week for comments/approval.
> 
> 	* config/avr/avr-protos.h (function_arg): Delete.
> 	(function_arg_advance): Delete.
> 	* config/avr/avr.h (FUNCTION_ARG, FUNCTION_ARG_ADVANCE): Delete.
> 	* config/avr/avr.c (function_arg): Rename to...
> 	(avr_function_arg): ...this.  Make static.  Take a 
> const_tree and
> 	a bool.
> 	(function_arg_advance):	Rename to...
> 	(avr_function_arg_advance): ...this.  Make static.  Take a
> 	const_tree and a bool.
> 	(TARGET_FUNCTION_ARG, TARGET_FUNCTION_ARG_ADVANCE): Define.

Looks obvious to me. Please commit. And thanks for doing this. :-)

Eric Weddington

Patch

diff --git a/gcc/config/avr/avr-protos.h b/gcc/config/avr/avr-protos.h
index 83de685..3d717a2 100644
--- a/gcc/config/avr/avr-protos.h
+++ b/gcc/config/avr/avr-protos.h
@@ -42,15 +42,8 @@  extern int avr_progmem_p (tree decl, tree attributes);
 #ifdef RTX_CODE /* inside TREE_CODE */
 extern void init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
 				  rtx libname, tree fndecl);
-extern rtx function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
-			 tree type, int named);
 #endif /* RTX_CODE inside TREE_CODE */
 
-#ifdef HAVE_MACHINE_MODES /* inside TREE_CODE */
-extern void function_arg_advance (CUMULATIVE_ARGS *cum,
-				  enum machine_mode mode, tree type,
-				  int named);
-#endif /* HAVE_MACHINE_MODES inside TREE_CODE*/
 #endif /* TREE_CODE */
 
 #ifdef RTX_CODE
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index e300dd6..c1cd778 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -93,6 +93,10 @@  static unsigned int avr_case_values_threshold (void);
 static bool avr_frame_pointer_required_p (void);
 static bool avr_can_eliminate (const int, const int);
 static bool avr_class_likely_spilled_p (reg_class_t c);
+static rtx avr_function_arg (CUMULATIVE_ARGS *, enum machine_mode,
+			     const_tree, bool);
+static void avr_function_arg_advance (CUMULATIVE_ARGS *, enum machine_mode,
+				      const_tree, bool);
 
 /* Allocate registers from r25 to r8 for parameters for function calls.  */
 #define FIRST_CUM_REG 26
@@ -168,6 +172,10 @@  static const struct attribute_spec avr_attribute_table[] =
 #define TARGET_ADDRESS_COST avr_address_cost
 #undef TARGET_MACHINE_DEPENDENT_REORG
 #define TARGET_MACHINE_DEPENDENT_REORG avr_reorg
+#undef TARGET_FUNCTION_ARG
+#define TARGET_FUNCTION_ARG avr_function_arg
+#undef TARGET_FUNCTION_ARG_ADVANCE
+#define TARGET_FUNCTION_ARG_ADVANCE avr_function_arg_advance
 
 #undef TARGET_LEGITIMIZE_ADDRESS
 #define TARGET_LEGITIMIZE_ADDRESS avr_legitimize_address
@@ -1566,9 +1574,9 @@  avr_num_arg_regs (enum machine_mode mode, tree type)
 /* Controls whether a function argument is passed
    in a register, and which register.  */
 
-rtx
-function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
-	      int named ATTRIBUTE_UNUSED)
+static rtx
+avr_function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+		  const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int bytes = avr_num_arg_regs (mode, type);
 
@@ -1581,9 +1589,9 @@  function_arg (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
 /* Update the summarizer variable CUM to advance past an argument
    in the argument list.  */
    
-void
-function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode, tree type,
-		      int named ATTRIBUTE_UNUSED)
+static void
+avr_function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
+			  const_tree type, bool named ATTRIBUTE_UNUSED)
 {
   int bytes = avr_num_arg_regs (mode, type);
 
diff --git a/gcc/config/avr/avr.h b/gcc/config/avr/avr.h
index 60a5899..3c7c4a4 100644
--- a/gcc/config/avr/avr.h
+++ b/gcc/config/avr/avr.h
@@ -372,8 +372,6 @@  enum reg_class {
    for POST_DEC targets (PR27386).  */
 /*#define PUSH_ROUNDING(NPUSHED) (NPUSHED)*/
 
-#define FUNCTION_ARG(CUM, MODE, TYPE, NAMED) (function_arg (&(CUM), MODE, TYPE, NAMED))
-
 typedef struct avr_args {
   int nregs;			/* # registers available for passing */
   int regno;			/* next available register number */
@@ -382,9 +380,6 @@  typedef struct avr_args {
 #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, FNDECL, N_NAMED_ARGS) \
   init_cumulative_args (&(CUM), FNTYPE, LIBNAME, FNDECL)
 
-#define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)	\
-  (function_arg_advance (&CUM, MODE, TYPE, NAMED))
-
 #define FUNCTION_ARG_REGNO_P(r) function_arg_regno_p(r)
 
 extern int avr_reg_order[];