This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
MEMBER_TYPE_FORCES_BLK: implement correctly
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 12 Jun 2002 23:01:18 +1000
- Subject: MEMBER_TYPE_FORCES_BLK: implement correctly
hi guys.
the original patch introducing the FUNCTION_ARG_REG_LITTLE_ENDIAN
check to MEMBER_TYPE_FORCES_BLK in compute_record_mode() was a kludge
(as the comment in the source can attest to):
http://gcc.gnu.org/ml/gcc-patches/2001-12/msg00717.html
as it stands, the macro is in direct contradiction to the docs, which
say that the structure's mode will be BLKmode (regardless of if
FIELD is the only FIELD in a structure):
`MEMBER_TYPE_FORCES_BLK (FIELD)'
Return 1 if a structure or array containing FIELD should be
accessed using `BLKMODE'.
the patch above just introduced a kludge testing for
FUNCTION_ARG_REG_LITTLE_ENDIAN to work around c4x's desire for different
behavior for one-fielded structures.
this patch adds a MODE field to the macro so we can clean this up,
and still keep the c4x port happy.
[and of *course* i have an ulterior motive... i need to use
MEMBER_TYPE_FORCES_BLK for a target that doesn't have
FUNCTION_ARG_REG_LITTLE_ENDIAN, and it currently misbehaves for
one fielded structures ;-)]
i don't have either an ia64-hpux nor a c4x. but... i have tested on a port
i'm working on that uses this macro. and i have also verified i can
build a cross cc1 for ia64. the c4x currently doesn't build with or
without my change because _gt_ggc* undefines.
pretty simple change anyhow :).
ok?
2002-06-12 Aldy Hernandez <aldyh@redhat.com>
* tm.texi (MEMBER_TYPE_FORCES_BLK): Document MODE argument.
* stor-layout.c (compute_record_mode): Remove check for
FUNCTION_ARG_REG_LITTLE_ENDIAN and VOIDmode when checking for
MEMBER_TYPE_FORCES_BLK. Pass new mode field to
MEMBER_TYPE_FORCES_BLK.
* config/ia64/hpux.h (MEMBER_TYPE_FORCES_BLK): Same.
* config/c4x/c4x.h (MEMBER_TYPE_FORCES_BLK): Same.
Index: doc/tm.texi
===================================================================
RCS file: /cvs/uberbaum/gcc/doc/tm.texi,v
retrieving revision 1.138
diff -c -p -r1.138 tm.texi
*** doc/tm.texi 11 Jun 2002 07:26:38 -0000 1.138
--- doc/tm.texi 12 Jun 2002 12:53:44 -0000
*************** Like @code{PCC_BITFIELD_TYPE_MATTERS} ex
*** 1213,1221 ****
to aligning a bit-field within the structure.
@findex MEMBER_TYPE_FORCES_BLK
! @item MEMBER_TYPE_FORCES_BLK (@var{field})
Return 1 if a structure or array containing @var{field} should be accessed using
@code{BLKMODE}.
Normally, this is not needed. See the file @file{c4x.h} for an example
of how to use this macro to prevent a structure having a floating point
--- 1213,1226 ----
to aligning a bit-field within the structure.
@findex MEMBER_TYPE_FORCES_BLK
! @item MEMBER_TYPE_FORCES_BLK (@var{field}, @var{mode})
Return 1 if a structure or array containing @var{field} should be accessed using
@code{BLKMODE}.
+
+ If @var{field} is the only field in the structure, @var{mode} is its
+ mode, otherwise @var{mode} is VOIDmode. @var{mode} is provided in the
+ case where structures of one field would require the structure's mode to
+ retain the field's mode.
Normally, this is not needed. See the file @file{c4x.h} for an example
of how to use this macro to prevent a structure having a floating point
Index: stor-layout.c
===================================================================
RCS file: /cvs/uberbaum/gcc/stor-layout.c,v
retrieving revision 1.125
diff -c -p -r1.125 stor-layout.c
*** stor-layout.c 4 Jun 2002 07:07:58 -0000 1.125
--- stor-layout.c 12 Jun 2002 12:53:45 -0000
*************** compute_record_mode (type)
*** 1228,1243 ****
/* With some targets, eg. c4x, it is sub-optimal
to access an aligned BLKmode structure as a scalar. */
! /* On ia64-*-hpux we need to ensure that we don't change the
! mode of a structure containing a single field or else we
! will pass it incorrectly. Since a structure with a single
! field causes mode to get set above we can't allow the
! check for mode == VOIDmode in this case. Perhaps
! MEMBER_TYPE_FORCES_BLK should be extended to include mode
! as an argument and the check could be put in there for c4x. */
!
! if ((mode == VOIDmode || FUNCTION_ARG_REG_LITTLE_ENDIAN)
! && MEMBER_TYPE_FORCES_BLK (field))
return;
#endif /* MEMBER_TYPE_FORCES_BLK */
}
--- 1228,1234 ----
/* With some targets, eg. c4x, it is sub-optimal
to access an aligned BLKmode structure as a scalar. */
! if (MEMBER_TYPE_FORCES_BLK (field, mode))
return;
#endif /* MEMBER_TYPE_FORCES_BLK */
}
*************** layout_type (type)
*** 1577,1583 ****
TYPE_MODE (type) = BLKmode;
if (TYPE_SIZE (type) != 0
#ifdef MEMBER_TYPE_FORCES_BLK
! && ! MEMBER_TYPE_FORCES_BLK (type)
#endif
/* BLKmode elements force BLKmode aggregate;
else extract/store fields may lose. */
--- 1568,1574 ----
TYPE_MODE (type) = BLKmode;
if (TYPE_SIZE (type) != 0
#ifdef MEMBER_TYPE_FORCES_BLK
! && ! MEMBER_TYPE_FORCES_BLK (type, VOIDmode)
#endif
/* BLKmode elements force BLKmode aggregate;
else extract/store fields may lose. */
Index: config/ia64/hpux.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/ia64/hpux.h,v
retrieving revision 1.8
diff -c -p -r1.8 hpux.h
*** config/ia64/hpux.h 18 May 2002 19:27:45 -0000 1.8
--- config/ia64/hpux.h 12 Jun 2002 12:53:45 -0000
*************** Boston, MA 02111-1307, USA. */
*** 103,109 ****
structure handling, this macro simply ensures that single field
structures are always treated like structures. */
! #define MEMBER_TYPE_FORCES_BLK(FIELD) 1
/* Override the setting of FUNCTION_ARG_REG_LITTLE_ENDIAN in
defaults.h. Setting this to true means that we are not passing
--- 103,109 ----
structure handling, this macro simply ensures that single field
structures are always treated like structures. */
! #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) 1
/* Override the setting of FUNCTION_ARG_REG_LITTLE_ENDIAN in
defaults.h. Setting this to true means that we are not passing
Index: config/c4x/c4x.h
===================================================================
RCS file: /cvs/uberbaum/gcc/config/c4x/c4x.h,v
retrieving revision 1.107
diff -c -p -r1.107 c4x.h
*** config/c4x/c4x.h 10 Jun 2002 22:35:46 -0000 1.107
--- config/c4x/c4x.h 12 Jun 2002 12:53:47 -0000
*************** extern const char *c4x_rpts_cycles_strin
*** 378,386 ****
#define MAX_FIXED_MODE_SIZE 64 /* HImode. */
/* If a structure has a floating point field then force structure
! to have BLKMODE. */
! #define MEMBER_TYPE_FORCES_BLK(FIELD) \
! (TREE_CODE (TREE_TYPE (FIELD)) == REAL_TYPE)
/* Number of bits in the high and low parts of a two stage
load of an immediate constant. */
--- 378,386 ----
#define MAX_FIXED_MODE_SIZE 64 /* HImode. */
/* If a structure has a floating point field then force structure
! to have BLKMODE, unless it is the only field. */
! #define MEMBER_TYPE_FORCES_BLK(FIELD, MODE) \
! (TREE_CODE (TREE_TYPE (FIELD)) == REAL_TYPE && (MODE) == VOIDmode)
/* Number of bits in the high and low parts of a two stage
load of an immediate constant. */