public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: byteorder mess (fwd)
@ 1997-12-08 11:24 teunis
  0 siblings, 0 replies; only message in thread
From: teunis @ 1997-12-08 11:24 UTC (permalink / raw)
  To: egcs list

from linux-kernel - this in here somewhere?
G'day, eh? :)
	- Teunis

---------- Forwarded message ----------
Date: Sat, 6 Dec 1997 04:16:13 +0000
From: lkd@tantalophile.demon.co.uk
To: linux-kernel@vger.rutgers.edu
Subject: Re: byteorder mess

>                         Gcc doesn't do constant propagation into inline
> functions (I do hope egcs will fix this), so the __builtin_constant_p() 
> thing doesn't work unless it's a define. 

I wrote a patch for GCC 2.7.2 over a year ago which enabled
__builtin_constant_p() on constants in inline functions, and other
places where constants are propagated (e.g., results from inline
functions).  I used it a lot with a commercial C++ project (a game
running under Linux, amazingly), and submitted it after extensive
testing (i386 only, admittedly).  It was rejected as too fundamental a
change: it adds a new RTX code.

I include the patch below for anyone interested (it's short).

-- Jamie Lokier

diff -c fsf/gcc/ChangeLog:1.3 fsf/gcc/ChangeLog:1.4
*** fsf/gcc/ChangeLog:1.3	Mon Oct 21 18:25:15 1996
--- fsf/gcc/ChangeLog	Mon Oct 21 18:29:40 1996
***************
*** 0 ****
--- 1,10 ----
+ Tue Jul 30 01:58:06 1996  Jamie Lokier  <jamie@rebellion.co.uk>
+ 
+ 	* rtl.def: New code CONSTANT_P_RTX.
+ 	* expr.c (expand_builtin, case BUILT_IN_CONSTANT_P): Emit
+ 	CONSTANT_P_RTX instead of const0_rtx.
+ 	* cse.c (fold_rtx): Fold CONSTANT_P_RTX.
+ 
Index: fsf/gcc/cse.c
diff -c fsf/gcc/cse.c:1.1.1.3 fsf/gcc/cse.c:1.2
*** fsf/gcc/cse.c:1.1.1.3	Mon Oct 21 16:05:00 1996
--- fsf/gcc/cse.c	Mon Oct 21 18:29:41 1996
***************
*** 5687,5692 ****
--- 5687,5698 ----
  					const_arg1 ? const_arg1 : folded_arg1,
  					const_arg2 ? const_arg2 : XEXP (x, 2));
        break;
+ 
+     case 'x':
+       if (code == CONSTANT_P_RTX)
+ 	/* Always eliminate CONSTANT_P_RTX at this stage. */
+ 	return (const_arg0 ? const1_rtx : const0_rtx);
+       break;
      }
  
    return new ? new : x;
Index: fsf/gcc/expr.c
diff -c fsf/gcc/expr.c:1.2 fsf/gcc/expr.c:1.3
*** fsf/gcc/expr.c:1.2	Mon Oct 21 17:09:13 1996
--- fsf/gcc/expr.c	Mon Oct 21 18:29:43 1996
***************
*** 7625,7631 ****
  	  return (TREE_CODE_CLASS (TREE_CODE (arg)) == 'c'
  		  || (TREE_CODE (arg) == ADDR_EXPR
  		      && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
! 		  ? const1_rtx : const0_rtx);
  	}
  
      case BUILT_IN_FRAME_ADDRESS:
--- 7625,7637 ----
  	  return (TREE_CODE_CLASS (TREE_CODE (arg)) == 'c'
  		  || (TREE_CODE (arg) == ADDR_EXPR
  		      && TREE_CODE (TREE_OPERAND (arg, 0)) == STRING_CST)
! 		  ? const1_rtx
! 		  : (optimize > 0
! 		     /* Only emit CONSTANT_P_RTX if CSE will be run. */
! 		     ? gen_rtx (CONSTANT_P_RTX, TYPE_MODE (integer_type_node),
! 				expand_expr (TREE_VALUE (arglist), NULL_RTX,
! 					     VOIDmode, 0))
! 		     : const0_rtx));
  	}
  
      case BUILT_IN_FRAME_ADDRESS:
Index: fsf/gcc/rtl.def
diff -c fsf/gcc/rtl.def:1.1.1.1 fsf/gcc/rtl.def:1.2
*** fsf/gcc/rtl.def:1.1.1.1	Mon Oct 21 15:21:10 1996
--- fsf/gcc/rtl.def	Mon Oct 21 18:29:45 1996
***************
*** 757,762 ****
--- 757,767 ----
     of a constant expression.  */
  DEF_RTL_EXPR(LO_SUM, "lo_sum", "ee", 'o')
  
+ /* A unary `__builtin_constant_p' expression.  These are only emitted
+    during RTL generation, and then only if optimize > 0.  They are
+    eliminated by the first CSE pass. */
+ DEF_RTL_EXPR(CONSTANT_P_RTX, "constant_p", "e", 'x')
+ 
  /*
  Local variables:
  mode:c


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-12-08 11:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-08 11:24 byteorder mess (fwd) teunis

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).