This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Minor changes to stor-layout.c
- To: gcc-patches at gcc dot gnu dot org
- Subject: Minor changes to stor-layout.c
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- Date: Sat, 4 Mar 00 12:02:55 EST
I noticed that it would make more sense given the usage for the
parameters to mode_for_size and smallest_mode_for_size to be signed
instead of unsigned. Then I noticed that some callers simply pass
TREE_INT_CST_LOW without checking that the value represents the size.
So I committed the following:
Sat Mar 4 11:32:30 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* machmode.h (mode_for_size, smallest_mode_for_size): SIZE now signed.
* stor-layout.c (mode_for_size, smallest_mode_for_size): Likewise.
(mode_for_size_tree): New function.
(layout_decl, layout_type): Call it and clean up BLKmode checks.
* tree.h (mode_for_size_tree): New declaration.
*** machmode.h 2000/02/24 10:07:32 1.20
--- machmode.h 2000/03/04 16:34:37
*************** extern const unsigned char mode_wider_mo
*** 106,115 ****
The value is BLKmode if no other mode is found. */
! extern enum machine_mode mode_for_size PARAMS ((unsigned int, enum mode_class, int));
/* Similar, but find the smallest mode for a given width. */
! extern enum machine_mode smallest_mode_for_size PARAMS ((unsigned int,
! enum mode_class));
--- 106,115 ----
The value is BLKmode if no other mode is found. */
! extern enum machine_mode mode_for_size PARAMS ((int, enum mode_class, int));
/* Similar, but find the smallest mode for a given width. */
! extern enum machine_mode smallest_mode_for_size
! PARAMS ((int, enum mode_class));
*** stor-layout.c 2000/03/02 18:29:55 1.51
--- stor-layout.c 2000/03/04 16:34:38
*************** variable_size (size)
*** 151,155 ****
enum machine_mode
mode_for_size (size, class, limit)
! unsigned int size;
enum mode_class class;
int limit;
--- 151,155 ----
enum machine_mode
mode_for_size (size, class, limit)
! int size;
enum mode_class class;
int limit;
*************** mode_for_size (size, class, limit)
*** 157,161 ****
register enum machine_mode mode;
! if (limit && size > (unsigned int)(MAX_FIXED_MODE_SIZE))
return BLKmode;
--- 157,161 ----
register enum machine_mode mode;
! if (limit && size > MAX_FIXED_MODE_SIZE)
return BLKmode;
*************** mode_for_size (size, class, limit)
*** 163,167 ****
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
! if ((unsigned int)GET_MODE_BITSIZE (mode) == size)
return mode;
--- 163,167 ----
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
! if (GET_MODE_BITSIZE (mode) == size)
return mode;
*************** mode_for_size (size, class, limit)
*** 169,172 ****
--- 169,194 ----
}
+ /* Similar, except passed a tree node. */
+
+ enum machine_mode
+ mode_for_size_tree (size, class, limit)
+ tree size;
+ enum mode_class class;
+ int limit;
+ {
+ if (TREE_CODE (size) != INTEGER_CST
+ || TREE_INT_CST_HIGH (size) != 0
+ /* If the low-order part is so high as to appear negative, we can't
+ find a mode for that many bits. */
+ || TREE_INT_CST_LOW (size) < 0
+ /* What we really want to say here is that the size can fit in a
+ host integer, but we know there's no way we'd find a mode for
+ this many bits, so there's no point in doing the precise test. */
+ || TREE_INT_CST_LOW (size) > 1000)
+ return BLKmode;
+ else
+ return mode_for_size (TREE_INT_CST_LOW (size), class, limit);
+ }
+
/* Similar, but never return BLKmode; return the narrowest mode that
contains at least the requested number of bits. */
*************** mode_for_size (size, class, limit)
*** 174,178 ****
enum machine_mode
smallest_mode_for_size (size, class)
! unsigned int size;
enum mode_class class;
{
--- 196,200 ----
enum machine_mode
smallest_mode_for_size (size, class)
! int size;
enum mode_class class;
{
*************** smallest_mode_for_size (size, class)
*** 183,187 ****
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
! if ((unsigned int)GET_MODE_BITSIZE (mode) >= size)
return mode;
--- 205,209 ----
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
! if (GET_MODE_BITSIZE (mode) >= size)
return mode;
*************** layout_decl (decl, known_align)
*** 333,337 ****
{
register enum machine_mode xmode
! = mode_for_size (TREE_INT_CST_LOW (DECL_SIZE (decl)), MODE_INT, 1);
if (xmode != BLKmode
--- 355,359 ----
{
register enum machine_mode xmode
! = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
if (xmode != BLKmode
*************** layout_type (type)
*** 1059,1063 ****
TYPE_MODE (type) = BLKmode;
if (TYPE_SIZE (type) != 0
- && TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
/* BLKmode elements force BLKmode aggregate;
else extract/store fields may lose. */
--- 1081,1084 ----
*************** layout_type (type)
*** 1066,1075 ****
{
TYPE_MODE (type)
! = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
! MODE_INT, 1);
! if (STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
! && ((int) TYPE_ALIGN (type)
! < TREE_INT_CST_LOW (TYPE_SIZE (type)))
&& TYPE_MODE (type) != BLKmode)
{
--- 1087,1095 ----
{
TYPE_MODE (type)
! = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
! if (TYPE_MODE (type) != BLKmode
! && STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
! && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (TYPE_MODE (type))
&& TYPE_MODE (type) != BLKmode)
{
*************** layout_type (type)
*** 1137,1155 ****
else
TYPE_MODE (type)
! = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
! MODE_INT, 1);
/* If structure's known alignment is less than
what the scalar mode would need, and it matters,
then stick with BLKmode. */
! if (STRICT_ALIGNMENT
&& ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
! || ((int) TYPE_ALIGN (type)
! >= TREE_INT_CST_LOW (TYPE_SIZE (type)))))
{
! if (TYPE_MODE (type) != BLKmode)
! /* If this is the only reason this type is BLKmode,
! then don't force containing types to be BLKmode. */
! TYPE_NO_FORCE_BLK (type) = 1;
TYPE_MODE (type) = BLKmode;
}
--- 1157,1174 ----
else
TYPE_MODE (type)
! = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
/* If structure's known alignment is less than
what the scalar mode would need, and it matters,
then stick with BLKmode. */
! if (TYPE_MODE (type) != BLKmode
! && STRICT_ALIGNMENT
&& ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
! || (TYPE_ALIGN (type) >=
! GET_MODE_ALIGNMENT (TYPE_MODE (type)))))
{
! /* If this is the only reason this type is BLKmode,
! then don't force containing types to be BLKmode. */
! TYPE_NO_FORCE_BLK (type) = 1;
TYPE_MODE (type) = BLKmode;
}
*************** layout_type (type)
*** 1196,1201 ****
TYPE_MODE (type)
! = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
! MODE_INT, 1);
union_lose: ;
--- 1215,1219 ----
TYPE_MODE (type)
! = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
union_lose: ;
*** tree.h 2000/03/04 09:32:35 1.131
--- tree.h 2000/03/04 16:34:41
*************** extern tree type_hash_canon PARAMS ((in
*** 1800,1803 ****
--- 1800,1811 ----
extern void layout_decl PARAMS ((tree, unsigned));
+ /* Return the mode for data of a given size SIZE and mode class CLASS.
+ If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
+ The value is BLKmode if no other mode is found. This is like
+ mode_for_size, but is passed a tree. */
+
+ extern enum machine_mode mode_for_size_tree PARAMS ((tree, enum mode_class,
+ int));
+
/* Return an expr equal to X but certainly not valid as an lvalue. */