This is the mail archive of the gcc-bugs@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]

i386 constant data alignment patch


Hello,

This change implements the alignment of constant data following
the recommendations of the "Intel Architecture Optimization Manual".

ChangeLog:

Sun May 17 17:21:26 EDT 1998  John Wehle  (john@feith.com)

	* i386.h (ALIGN_DFmode): Delete.
	(CONSTANT_ALIGNMENT): Define.
	* varasm.c (force_const_mem): Use it.

Enjoy!

-- John Wehle
------------------8<------------------------8<------------------------
*** gcc/config/i386/i386.h.ORIGINAL	Sat May  9 17:24:07 1998
--- gcc/config/i386/i386.h	Sun May 17 17:13:47 1998
***************
*** 419,426 ****
     aligned on 64 bit boundaries. */
  #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
  
! /* align DFmode constants and nonaggregates */
! #define ALIGN_DFmode (!TARGET_386)
  
  /* If defined, a C expression to compute the alignment for a static
     variable.  TYPE is the data type, and ALIGN is the alignment that
--- 419,448 ----
     aligned on 64 bit boundaries. */
  #define BIGGEST_ALIGNMENT (TARGET_ALIGN_DOUBLE ? 64 : 32)
  
! /* If defined, a C expression to compute the alignment given to a
!    constant that is being placed in memory.  CONSTANT is the constant
!    and ALIGN is the alignment that the object would ordinarily have.
!    The value of this macro is used instead of that alignment to align
!    the object.
! 
!    If this macro is not defined, then ALIGN is used.
! 
!    The typical use of this macro is to increase alignment for string
!    constants to be word aligned so that `strcpy' calls that copy
!    constants can be done inline.  */
! 
! #define CONSTANT_ALIGNMENT(EXP, ALIGN)					\
!   (TREE_CODE (EXP) == REAL_CST						\
!     ? ((TYPE_MODE (TREE_TYPE (EXP)) == DFmode && (ALIGN) < 64)		\
! 	? 64								\
!    	: (TYPE_MODE (TREE_TYPE (EXP)) == XFmode && (ALIGN) < 128)	\
! 	? 128								\
! 	: (ALIGN))							\
!     : TREE_CODE (EXP) == STRING_CST					\
!     ? ((TREE_STRING_LENGTH (EXP) >= 31 && (ALIGN) < 256)		\
! 	? 256								\
! 	: (ALIGN))							\
!     : (ALIGN))
  
  /* If defined, a C expression to compute the alignment for a static
     variable.  TYPE is the data type, and ALIGN is the alignment that
*** gcc/varasm.c.ORIGINAL	Sat May  9 17:20:28 1998
--- gcc/varasm.c	Sun May 17 01:32:13 1998
***************
*** 3422,3427 ****
--- 3422,3431 ----
        align = (mode == VOIDmode) ? UNITS_PER_WORD : GET_MODE_SIZE (mode);
        if (align > BIGGEST_ALIGNMENT / BITS_PER_UNIT)
  	align = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
+ #ifdef CONSTANT_ALIGNMENT
+       align = CONSTANT_ALIGNMENT (make_tree (type_for_mode (mode, 0), x),
+ 				 align * BITS_PER_UNIT) / BITS_PER_UNIT;
+ #endif
  
        pool_offset += align - 1;
        pool_offset &= ~ (align - 1);
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



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