This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [arm, patch] Remove redundant promotion of function arguments


> There's a problem with the ARM implementation.  Specifically, you've
> changed the ABI for the 'ATPCS' and APCS.  Previously those ABIs would
> promote things somewhat randomly (varies depending on the -march value)
> at the caller side, so you need TARGET_PROMOTE_PROTOTYPES to return TRUE
> when the ABI is not AAPCS conformant.

Ok. I only tested current gcc, which seemed to do the right thing.

> You should also poison PROMOTE_FOR_CALL_ONLY.

The patch below does both these. 
It also catches some uses of PROMOTE_FOR_CALL_ONLY that I missed.

Tested on sparc-sun-solaris2.8 and cross-compiler to arm-none-elf.
Ok?

Paul

2004-04-15  Paul Brook  <paul@codesourcery.com>

	* calls.c (precompute_arguments): Change ifdef PROMOTE_FOR_CALL_ONLY
	to !PROMOTE_MODE.
	* function.c (assign_temp): Ditto.
	* system.h (PROMOTE_FOR_CALL_ONLY): Poison.
	* config/arm/arm.c (arm_promote_prototypes): New function.
	(TARGET_PROMOTE_PROTOTYPES): Use it.
	

Index: calls.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/calls.c,v
retrieving revision 1.329
diff -u -p -r1.329 calls.c
--- a/calls.c	5 Apr 2004 12:24:59 -0000	1.329
+++ b/calls.c	15 Apr 2004 14:19:49 -0000
@@ -1407,7 +1407,7 @@ precompute_arguments (int flags, int num
 	    args[i].value
 	      = convert_modes (args[i].mode, mode,
 			       args[i].value, args[i].unsignedp);
-#ifdef PROMOTE_FOR_CALL_ONLY
+#ifndef PROMOTE_MODE
 	    /* CSE will replace this only if it contains args[i].value
 	       pseudo, so convert it down to the declared mode using
 	       a SUBREG.  */
Index: function.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/function.c,v
retrieving revision 1.510
diff -u -p -r1.510 function.c
--- a/function.c	9 Apr 2004 01:38:12 -0000	1.510
+++ b/function.c	15 Apr 2004 14:18:47 -0000
@@ -841,7 +841,7 @@ assign_temp (tree type_or_decl, int keep
 {
   tree type, decl;
   enum machine_mode mode;
-#ifndef PROMOTE_FOR_CALL_ONLY
+#ifdef PROMOTE_MODE
   int unsignedp;
 #endif
 
@@ -851,7 +851,7 @@ assign_temp (tree type_or_decl, int keep
     decl = NULL, type = type_or_decl;
 
   mode = TYPE_MODE (type);
-#ifndef PROMOTE_FOR_CALL_ONLY
+#ifdef PROMOTE_MODE
   unsignedp = TYPE_UNSIGNED (type);
 #endif
 
@@ -889,7 +889,7 @@ assign_temp (tree type_or_decl, int keep
       return tmp;
     }
 
-#ifndef PROMOTE_FOR_CALL_ONLY
+#ifdef PROMOTE_MODE
   if (! dont_promote)
     mode = promote_mode (type, mode, &unsignedp, 0);
 #endif
Index: system.h
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/system.h,v
retrieving revision 1.208
diff -u -p -r1.208 system.h
--- a/system.h	19 Mar 2004 00:52:24 -0000	1.208
+++ b/system.h	15 Apr 2004 14:04:31 -0000
@@ -641,7 +641,7 @@ typedef char _Bool;
 	FINAL_REG_PARM_STACK_SPACE MAYBE_REG_PARM_STACK_SPACE		   \
 	TRADITIONAL_PIPELINE_INTERFACE DFA_PIPELINE_INTERFACE		   \
 	DBX_OUTPUT_STANDARD_TYPES BUILTIN_SETJMP_FRAME_VALUE		   \
-	SUNOS4_SHARED_LIBRARIES
+	SUNOS4_SHARED_LIBRARIES PROMOTE_FOR_CALL_ONLY
 
 /* Hooks that are no longer used.  */
  #pragma GCC poison LANG_HOOKS_FUNCTION_MARK LANG_HOOKS_FUNCTION_FREE	\
Index: config/arm/arm.c
===================================================================
RCS file: /var/cvsroot/gcc-cvs/gcc/gcc/config/arm/arm.c,v
retrieving revision 1.345
diff -u -p -r1.345 arm.c
--- a/config/arm/arm.c	14 Apr 2004 17:31:32 -0000	1.345
+++ b/config/arm/arm.c	15 Apr 2004 14:04:31 -0000
@@ -158,6 +158,7 @@ static void aof_file_end (void);
 static rtx arm_struct_value_rtx (tree, int);
 static void arm_setup_incoming_varargs (CUMULATIVE_ARGS *, enum machine_mode,
 					tree, int *, int);
+static bool arm_promote_prototypes (tree);
 
 
 /* Initialize the GCC target structure.  */
@@ -247,7 +248,7 @@ static void arm_setup_incoming_varargs (
 #undef TARGET_PROMOTE_FUNCTION_RETURN
 #define TARGET_PROMOTE_FUNCTION_RETURN hook_bool_tree_true
 #undef TARGET_PROMOTE_PROTOTYPES
-#define TARGET_PROMOTE_PROTOTYPES hook_bool_tree_false
+#define TARGET_PROMOTE_PROTOTYPES arm_promote_prototypes
 
 #undef TARGET_STRUCT_VALUE_RTX
 #define TARGET_STRUCT_VALUE_RTX arm_struct_value_rtx
@@ -14444,3 +14445,13 @@ arm_no_early_mul_dep (rtx producer, rtx 
 	  && !reg_overlap_mentioned_p (value, XEXP (op, 0)));
 }
 
+
+/* We can't rely on the caller doing the proper promotion when
+   using APCS or ATPCS.  */
+
+static bool
+arm_promote_prototypes (tree t ATTRIBUTE_UNUSED)
+{
+    return arm_abi == ARM_ABI_APCS || arm_abi == ARM_ABI_ATPCS;
+}
+


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]