PROMOTE_PROTOTYPES runtime selection

Jakub Jelinek jj@sunsite.ms.mff.cuni.cz
Thu Jun 3 04:27:00 GMT 1999


Hi!

As sparc32 ABI requires PROMOTE_PROTOTYPES, but sparc v9 ABI specifies
the caller widens all arguments, I need following change which changes
the definition of PROMOTE_PROTOTYPES. So far all the code just tested if
that define is present, but that's not sufficient in the sparc case, because
one binary handles both sparc32 and sparc v9 ABI. So I changed it to a C
expression which evaluates to non-zero if prototype promotion is desired.
It seems i960 header already moans about PROMOTE_PROTOTYPES not beeing a C
expression, so I guess i960 will profit from this change as well.
If there is a fear about this patch breaking frontends not included in egcs,
then I should not that on sparc v9 PROMOTE_PROTOTYPES just will be defined
and thus it will perform the unneeded sign/zero extension on the argument
for those frontends, but that's the worst thing that will happen.

Fri Jun  3 13:21:52 1999  Jakub Jelinek  (jj@ultra.linux.cz)

	* cp/call.c (convert_default_arg, build_over_call):
	Change all uses of PROMOTE_PROTOTYPES, so that it
	tests it as a C expression to see whether prototype
	promotion is required.
	* cp/decl.c (grokparams): Ditto.
	* cp/pt.c (tsubst_decl): Ditto.
	* cp/typecheck (convert_arguments): Ditto.
	* java/decl.c (start_java_method): Ditto.
	* java/expr.c (pop_arguments): Ditto.
	* c-decl.c (get_parm_info, store_parm_decls): Ditto.
	* c-typecheck.c (convert_arguments): Ditto.

	* config/arc/arc.h: Define PROMOTE_PROTOTYPES to 1.
	* config/convex/convex.h: Ditto.
	* config/dsp16xx/dsp16xx.h: Ditto.
	* config/fx80/fx80.h: Ditto.
	* config/gmicro/gmicro.h: Ditto.
	* config/i370/i370.h: Ditto.
	* config/i386/i386.h: Ditto.
	* config/m32r/m32r.h: Ditto.
	* config/m68k/m68k.h: Ditto.
	* config/m88k/m88k.h: Ditto.
	* config/mips/mips.h: Ditto.
	* config/pa/pa.h: Ditto.
	* config/pyr/pyr.h: Ditto.
	* config/tahoe/tahoe.h: Ditto.
	* config/we32k/we32k.h: Ditto.

	* config/sparc/sparc.h: Define PROMOTE_PROTOTYPES
	based on arch size.

	* config/1750a/1750a.h: Change PROMOTE_PROTOTYPES
	related comment.
	* config/i860/paragon.h: Ditto.

	* tm.texi: Document new usage of PROMOTE_PROTOTYPES.

--- ./cp/call.c~	Fri May 28 07:34:31 1999
+++ ./cp/call.c	Fri May 28 17:23:09 1999
@@ -3098,8 +3098,9 @@ convert_default_arg (type, arg, fn)
       arg = convert_for_initialization (0, type, arg, LOOKUP_NORMAL,
 					"default argument", 0, 0);
 #ifdef PROMOTE_PROTOTYPES
-      if ((TREE_CODE (type) == INTEGER_TYPE
-	   || TREE_CODE (type) == ENUMERAL_TYPE)
+      if (PROMOTE_PROTOTYPES
+	  && (TREE_CODE (type) == INTEGER_TYPE
+	      || TREE_CODE (type) == ENUMERAL_TYPE)
 	  && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
 	arg = default_conversion (arg);
 #endif
@@ -3214,8 +3215,9 @@ build_over_call (cand, args, flags)
 	}
 
 #ifdef PROMOTE_PROTOTYPES
-      if ((TREE_CODE (type) == INTEGER_TYPE
-	   || TREE_CODE (type) == ENUMERAL_TYPE)
+      if (PROMOTE_PROTOTYPES
+	  && (TREE_CODE (type) == INTEGER_TYPE
+	      || TREE_CODE (type) == ENUMERAL_TYPE)
 	  && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
 	val = default_conversion (val);
 #endif
--- ./cp/decl.c~	Fri May 28 07:34:40 1999
+++ ./cp/decl.c	Fri May 28 17:24:00 1999
@@ -11944,8 +11944,9 @@ grokparms (first_parm, funcdef_flag)
 	      /* Since there is a prototype, args are passed in their own types.  */
 	      DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
 #ifdef PROMOTE_PROTOTYPES
-	      if ((TREE_CODE (type) == INTEGER_TYPE
-		   || TREE_CODE (type) == ENUMERAL_TYPE)
+	      if (PROMOTE_PROTOTYPES
+		  && (TREE_CODE (type) == INTEGER_TYPE
+		      || TREE_CODE (type) == ENUMERAL_TYPE)
 		  && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
 		DECL_ARG_TYPE (decl) = integer_type_node;
 #endif
--- ./cp/pt.c~	Fri May 28 07:35:05 1999
+++ ./cp/pt.c	Fri May 28 17:24:43 1999
@@ -5788,8 +5788,9 @@ tsubst_decl (t, args, type, in_decl)
 
 	DECL_CONTEXT (r) = NULL_TREE;
 #ifdef PROMOTE_PROTOTYPES
-	if ((TREE_CODE (type) == INTEGER_TYPE
-	     || TREE_CODE (type) == ENUMERAL_TYPE)
+	if (PROMOTE_PROTOTYPES
+	    && (TREE_CODE (type) == INTEGER_TYPE
+		|| TREE_CODE (type) == ENUMERAL_TYPE)
 	    && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
 	  DECL_ARG_TYPE (r) = integer_type_node;
 #endif
--- ./cp/typeck.c~	Fri May 28 07:35:15 1999
+++ ./cp/typeck.c	Fri May 28 17:25:32 1999
@@ -3181,8 +3181,9 @@ convert_arguments (typelist, values, fnd
 		(NULL_TREE, type, val, flags,
 		 "argument passing", fndecl, i);
 #ifdef PROMOTE_PROTOTYPES
-	      if ((TREE_CODE (type) == INTEGER_TYPE
-		   || TREE_CODE (type) == ENUMERAL_TYPE)
+	      if (PROMOTE_PROTOTYPES
+		  && (TREE_CODE (type) == INTEGER_TYPE
+		      || TREE_CODE (type) == ENUMERAL_TYPE)
 		  && (TYPE_PRECISION (type)
 		      < TYPE_PRECISION (integer_type_node)))
 		parmval = default_conversion (parmval);
--- ./java/decl.c~	Fri May 28 07:36:21 1999
+++ ./java/decl.c	Fri May 28 17:28:35 1999
@@ -1610,7 +1610,8 @@ start_java_method (fndecl)
       parm_decl = build_decl (PARM_DECL, parm_name, parm_type);
       DECL_CONTEXT (parm_decl) = fndecl;
 #ifdef PROMOTE_PROTOTYPES
-      if (TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
+      if (PROMOTE_PROTOTYPES
+	  && TYPE_PRECISION (parm_type) < TYPE_PRECISION (integer_type_node)
 	  && INTEGRAL_TYPE_P (parm_type))
 	parm_type = integer_type_node;
 #endif
--- ./java/expr.c~	Fri May 28 07:36:23 1999
+++ ./java/expr.c	Fri May 28 17:29:07 1999
@@ -1391,7 +1391,8 @@ pop_arguments (arg_types)
       tree type = TREE_VALUE (arg_types);
       tree arg = pop_value (type);
 #ifdef PROMOTE_PROTOTYPES
-      if (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
+      if (PROMOTE_PROTOTYPES
+	  && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
 	  && INTEGRAL_TYPE_P (type))
 	arg = convert (integer_type_node, arg);
 #endif
--- ./config/1750a/1750a.h~	Mon Mar 22 01:08:23 1999
+++ ./config/1750a/1750a.h	Fri May 28 17:35:33 1999
@@ -880,7 +880,7 @@ enum reg_class { NO_REGS, R2, R0_1, INDE
 
 /* When a prototype says `char' or `short', really pass an `int'. 
    1750: for now, `char' is 16 bits wide anyway.
-   #define PROMOTE_PROTOTYPES */
+   #define PROMOTE_PROTOTYPES 1 */
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/arc/arc.h~	Wed Dec 16 22:01:18 1998
+++ ./config/arc/arc.h	Fri May 28 17:35:53 1999
@@ -634,7 +634,7 @@ extern enum reg_class arc_regno_reg_clas
 /* Function argument passing.  */
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* If defined, the maximum amount of space required for outgoing
    arguments will be computed and placed into the variable
--- ./config/convex/convex.h~	Wed Dec 16 22:02:25 1998
+++ ./config/convex/convex.h	Fri May 28 17:37:09 1999
@@ -1077,7 +1077,7 @@ enum reg_class {
 #define NO_FUNCTION_CSE
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/dsp16xx/dsp16xx.h~	Wed Jan 27 02:43:04 1999
+++ ./config/dsp16xx/dsp16xx.h	Fri May 28 17:37:46 1999
@@ -1940,7 +1940,7 @@ const_section ()                        
 #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* An alias for the machine mode used for pointers */
 #define Pmode  QImode
--- ./config/fx80/fx80.h~	Mon Mar 22 01:08:17 1999
+++ ./config/fx80/fx80.h	Fri May 28 17:38:01 1999
@@ -858,7 +858,7 @@ extern enum reg_class regno_reg_class[];
 #define STORE_FLAG_VALUE -1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/gmicro/gmicro.h~	Wed Dec 16 22:02:48 1998
+++ ./config/gmicro/gmicro.h	Fri May 28 17:38:19 1999
@@ -1160,7 +1160,7 @@ extern enum reg_class regno_reg_class[];
 /* #define STORE_FLAG_VALUE -1 */
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/i370/i370.h~	Mon Mar 22 01:08:15 1999
+++ ./config/i370/i370.h	Fri May 28 17:38:33 1999
@@ -839,7 +839,7 @@ enum reg_class
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
 
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Don't perform CSE on function addresses.  */
 
--- ./config/i386/i386.h~	Fri May 28 07:33:00 1999
+++ ./config/i386/i386.h	Fri May 28 17:38:51 1999
@@ -1958,7 +1958,7 @@ while (0)
 /* When a prototype says `char' or `short', really pass an `int'.
    (The 386 can't easily push less than an int.)  */
 
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/i860/paragon.h~	Mon Mar 22 01:08:14 1999
+++ ./config/i860/paragon.h	Fri May 28 17:39:40 1999
@@ -178,7 +178,7 @@ Boston, MA 02111-1307, USA.  */
    prototype should actually be passed as an `int'.  In addition to
    avoiding errors in certain cases of mismatch, it also makes for
    better code on certain machines. */
-/*#define PROMOTE_PROTOTYPES*/
+/*#define PROMOTE_PROTOTYPES 0*/
 
 /* Define this macro if an instruction to load a value narrower
    than a word from memory into a register also zero-extends the
--- ./config/m32r/m32r.h~	Wed Dec 16 22:06:02 1998
+++ ./config/m32r/m32r.h	Fri May 28 17:40:43 1999
@@ -810,7 +810,7 @@ M32R_STACK_ALIGN (current_function_outgo
 /* Function argument passing.  */
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* If defined, the maximum amount of space required for outgoing
    arguments will be computed and placed into the variable
--- ./config/m68k/m68k.h~	Mon Mar  1 16:06:46 1999
+++ ./config/m68k/m68k.h	Fri May 28 17:41:04 1999
@@ -1600,7 +1600,7 @@ __transfer_from_trampoline ()					\
 #define STORE_FLAG_VALUE -1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/m88k/m88k.h~	Wed Dec 16 22:08:23 1998
+++ ./config/m88k/m88k.h	Fri May 28 17:41:29 1999
@@ -1576,7 +1576,7 @@ enum reg_class { NO_REGS, AP_REG, XRF_RE
    `short' in a prototype should actually be passed as an
    `int'.  In addition to avoiding errors in certain cases of
    mismatch, it also makes for better code on certain machines.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Define this macro if a float function always returns float
    (even in traditional mode).  Redefined in luna.h.  */
--- ./config/mips/mips.h~	Fri May 28 07:33:32 1999
+++ ./config/mips/mips.h	Fri May 28 17:41:49 1999
@@ -1495,7 +1495,7 @@ do {							\
    avoiding errors in certain cases of mismatch, it also makes for
    better code on certain machines. */
 
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Define if operations between registers always perform the operation
    on the full register even if a narrower mode is specified.  */
--- ./config/pa/pa.h~	Fri May 28 07:33:49 1999
+++ ./config/pa/pa.h	Fri May 28 17:42:10 1999
@@ -1884,7 +1884,7 @@ while (0)
 #define STORE_FLAG_VALUE 1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./config/pyr/pyr.h~	Wed Dec 16 22:11:31 1998
+++ ./config/pyr/pyr.h	Fri May 28 17:42:44 1999
@@ -1045,7 +1045,7 @@ extern int current_function_calls_alloca
 /* #define NO_FUNCTION_CSE */
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* There are no flag store insns on a pyr. */
 /* #define STORE_FLAG_VALUE */
--- ./config/sparc/sparc.h~	Fri May 28 07:34:19 1999
+++ ./config/sparc/sparc.h	Fri May 28 17:44:04 1999
@@ -2686,7 +2686,7 @@ do {                                    
 #define STORE_FLAG_VALUE 1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES (TARGET_ARCH32)
 
 /* Define this to be nonzero if shift instructions ignore all but the low-order
    few bits. */
--- ./config/tahoe/tahoe.h~	Wed Dec 16 22:14:11 1998
+++ ./config/tahoe/tahoe.h	Fri May 28 17:51:39 1999
@@ -627,7 +627,7 @@ enum reg_class {NO_REGS,GENERAL_REGS,FPP
 
 /* pass chars as ints */
 
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* pointers can be represented by an si mode expression */
 
--- ./config/we32k/we32k.h~	Wed Dec 16 22:14:35 1998
+++ ./config/we32k/we32k.h	Fri May 28 17:51:57 1999
@@ -664,7 +664,7 @@ enum reg_class { NO_REGS, GENERAL_REGS,
 #define STORE_FLAG_VALUE -1
 
 /* When a prototype says `char' or `short', really pass an `int'.  */
-#define PROMOTE_PROTOTYPES
+#define PROMOTE_PROTOTYPES 1
 
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
--- ./c-decl.c~	Mon Apr 12 16:05:29 1999
+++ ./c-decl.c	Fri May 28 17:27:02 1999
@@ -5604,8 +5604,9 @@ get_parm_info (void_at_end)
 	tree type = TREE_TYPE (decl);
 	DECL_ARG_TYPE (decl) = type;
 #ifdef PROMOTE_PROTOTYPES
-	if ((TREE_CODE (type) == INTEGER_TYPE
-	     || TREE_CODE (type) == ENUMERAL_TYPE)
+	if (PROMOTE_PROTOTYPES
+	    && (TREE_CODE (type) == INTEGER_TYPE
+		|| TREE_CODE (type) == ENUMERAL_TYPE)
 	    && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
 	  DECL_ARG_TYPE (decl) = integer_type_node;
 #endif
@@ -6942,8 +6943,9 @@ store_parm_decls ()
 			 useful for argument types like uid_t.  */
 		      DECL_ARG_TYPE (parm) = TREE_TYPE (parm);
 #ifdef PROMOTE_PROTOTYPES
-		      if ((TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
-			   || TREE_CODE (TREE_TYPE (parm)) == ENUMERAL_TYPE)
+		      if (PROMOTE_PROTOTYPES
+			  && (TREE_CODE (TREE_TYPE (parm)) == INTEGER_TYPE
+			      || TREE_CODE (TREE_TYPE (parm)) == ENUMERAL_TYPE)
 			  && TYPE_PRECISION (TREE_TYPE (parm))
 			  < TYPE_PRECISION (integer_type_node))
 			DECL_ARG_TYPE (parm) = integer_type_node;
--- ./c-typeck.c~	Fri May 28 07:30:14 1999
+++ ./c-typeck.c	Fri May 28 17:27:45 1999
@@ -1766,8 +1766,9 @@ convert_arguments (typelist, values, nam
 						fundecl, name, parmnum + 1);
 	      
 #ifdef PROMOTE_PROTOTYPES
-	      if ((TREE_CODE (type) == INTEGER_TYPE
-		   || TREE_CODE (type) == ENUMERAL_TYPE)
+	      if (PROMOTE_PROTOTYPES
+		  && (TREE_CODE (type) == INTEGER_TYPE
+		      || TREE_CODE (type) == ENUMERAL_TYPE)
 		  && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
 		parmval = default_conversion (parmval);
 #endif
--- ./tm.texi~	Fri May 28 07:31:49 1999
+++ ./tm.texi	Fri May 28 17:34:55 1999
@@ -2607,10 +2607,12 @@ control passing certain arguments in reg
 @table @code
 @findex PROMOTE_PROTOTYPES
 @item PROMOTE_PROTOTYPES
-Define this macro if an argument declared in a prototype as an
-integral type smaller than @code{int} should actually be passed as an
-@code{int}.  In addition to avoiding errors in certain cases of
-mismatch, it also makes for better code on certain machines.
+A C expression whose value is nonzero if an argument declared in
+a prototype as an integral type smaller than @code{int} should
+actually be passed as an @code{int}.  In addition to avoiding
+errors in certain cases of mismatch, it also makes for better
+code on certain machines.  Do not define this macro if it is
+never nonzero.
 
 @findex PUSH_ROUNDING
 @item PUSH_ROUNDING (@var{npushed})


Cheers,
    Jakub
___________________________________________________________________
Jakub Jelinek | jj@sunsite.mff.cuni.cz | http://sunsite.mff.cuni.cz
Administrator of SunSITE Czech Republic, MFF, Charles University
___________________________________________________________________
UltraLinux  |  http://ultra.linux.cz/  |  http://ultra.penguin.cz/
Linux version 2.3.4 on a sparc64 machine (1343.49 BogoMips)
___________________________________________________________________


More information about the Gcc-patches mailing list