Commit 72c602fc by Richard Kenner Committed by Richard Kenner

machmode.h (mode_for_size, [...]): SIZE now signed.

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

From-SVN: r32326
parent 32070bf2
Sat Mar 4 11:32:30 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu> 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.
* toplev.c (debug_ignore_block): Mark arg BLOCK as possibly unused. * toplev.c (debug_ignore_block): Mark arg BLOCK as possibly unused.
2000-03-04 Jason Merrill <jason@casey.cygnus.com> 2000-03-04 Jason Merrill <jason@casey.cygnus.com>
......
/* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h. /* Machine mode definitions for GNU C-Compiler; included by rtl.h and tree.h.
Copyright (C) 1991, 93, 94, 96, 98, 99, 2000 Free Software Foundation, Inc. Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000
Free Software Foundation, Inc.
This file is part of GNU CC. This file is part of GNU CC.
...@@ -105,12 +106,12 @@ extern const unsigned char mode_wider_mode[]; ...@@ -105,12 +106,12 @@ extern const unsigned char mode_wider_mode[];
If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE. 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. */ The value is BLKmode if no other mode is found. */
extern enum machine_mode mode_for_size PARAMS ((unsigned int, enum mode_class, int)); extern enum machine_mode mode_for_size PARAMS ((int, enum mode_class, int));
/* Similar, but find the smallest mode for a given width. */ /* Similar, but find the smallest mode for a given width. */
extern enum machine_mode smallest_mode_for_size PARAMS ((unsigned int, extern enum machine_mode smallest_mode_for_size
enum mode_class)); PARAMS ((int, enum mode_class));
/* Return an integer mode of the exact same size as the input mode, /* Return an integer mode of the exact same size as the input mode,
......
...@@ -150,30 +150,52 @@ variable_size (size) ...@@ -150,30 +150,52 @@ variable_size (size)
enum machine_mode enum machine_mode
mode_for_size (size, class, limit) mode_for_size (size, class, limit)
unsigned int size; int size;
enum mode_class class; enum mode_class class;
int limit; int limit;
{ {
register enum machine_mode mode; register enum machine_mode mode;
if (limit && size > (unsigned int)(MAX_FIXED_MODE_SIZE)) if (limit && size > MAX_FIXED_MODE_SIZE)
return BLKmode; return BLKmode;
/* Get the first mode which has this size, in the specified class. */ /* Get the first mode which has this size, in the specified class. */
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode; for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode)) mode = GET_MODE_WIDER_MODE (mode))
if ((unsigned int)GET_MODE_BITSIZE (mode) == size) if (GET_MODE_BITSIZE (mode) == size)
return mode; return mode;
return BLKmode; return BLKmode;
} }
/* 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 /* Similar, but never return BLKmode; return the narrowest mode that
contains at least the requested number of bits. */ contains at least the requested number of bits. */
enum machine_mode enum machine_mode
smallest_mode_for_size (size, class) smallest_mode_for_size (size, class)
unsigned int size; int size;
enum mode_class class; enum mode_class class;
{ {
register enum machine_mode mode; register enum machine_mode mode;
...@@ -182,7 +204,7 @@ smallest_mode_for_size (size, class) ...@@ -182,7 +204,7 @@ smallest_mode_for_size (size, class)
specified class. */ specified class. */
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode; for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode)) mode = GET_MODE_WIDER_MODE (mode))
if ((unsigned int)GET_MODE_BITSIZE (mode) >= size) if (GET_MODE_BITSIZE (mode) >= size)
return mode; return mode;
abort (); abort ();
...@@ -332,7 +354,7 @@ layout_decl (decl, known_align) ...@@ -332,7 +354,7 @@ layout_decl (decl, known_align)
&& GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT) && GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
{ {
register enum machine_mode xmode register enum machine_mode xmode
= mode_for_size (TREE_INT_CST_LOW (DECL_SIZE (decl)), MODE_INT, 1); = mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
if (xmode != BLKmode if (xmode != BLKmode
&& known_align % GET_MODE_ALIGNMENT (xmode) == 0) && known_align % GET_MODE_ALIGNMENT (xmode) == 0)
...@@ -1058,19 +1080,17 @@ layout_type (type) ...@@ -1058,19 +1080,17 @@ layout_type (type)
TYPE_MODE (type) = BLKmode; TYPE_MODE (type) = BLKmode;
if (TYPE_SIZE (type) != 0 if (TYPE_SIZE (type) != 0
&& TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
/* BLKmode elements force BLKmode aggregate; /* BLKmode elements force BLKmode aggregate;
else extract/store fields may lose. */ else extract/store fields may lose. */
&& (TYPE_MODE (TREE_TYPE (type)) != BLKmode && (TYPE_MODE (TREE_TYPE (type)) != BLKmode
|| TYPE_NO_FORCE_BLK (TREE_TYPE (type)))) || TYPE_NO_FORCE_BLK (TREE_TYPE (type))))
{ {
TYPE_MODE (type) TYPE_MODE (type)
= mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
MODE_INT, 1);
if (STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT if (TYPE_MODE (type) != BLKmode
&& ((int) TYPE_ALIGN (type) && STRICT_ALIGNMENT && TYPE_ALIGN (type) < BIGGEST_ALIGNMENT
< TREE_INT_CST_LOW (TYPE_SIZE (type))) && TYPE_ALIGN (type) < GET_MODE_ALIGNMENT (TYPE_MODE (type))
&& TYPE_MODE (type) != BLKmode) && TYPE_MODE (type) != BLKmode)
{ {
TYPE_NO_FORCE_BLK (type) = 1; TYPE_NO_FORCE_BLK (type) = 1;
...@@ -1136,21 +1156,20 @@ layout_type (type) ...@@ -1136,21 +1156,20 @@ layout_type (type)
TYPE_MODE (type) = mode; TYPE_MODE (type) = mode;
else else
TYPE_MODE (type) TYPE_MODE (type)
= mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
MODE_INT, 1);
/* If structure's known alignment is less than /* If structure's known alignment is less than
what the scalar mode would need, and it matters, what the scalar mode would need, and it matters,
then stick with BLKmode. */ then stick with BLKmode. */
if (STRICT_ALIGNMENT if (TYPE_MODE (type) != BLKmode
&& STRICT_ALIGNMENT
&& ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT && ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
|| ((int) TYPE_ALIGN (type) || (TYPE_ALIGN (type) >=
>= TREE_INT_CST_LOW (TYPE_SIZE (type))))) GET_MODE_ALIGNMENT (TYPE_MODE (type)))))
{ {
if (TYPE_MODE (type) != BLKmode) /* If this is the only reason this type is BLKmode,
/* If this is the only reason this type is BLKmode, then don't force containing types to be BLKmode. */
then don't force containing types to be BLKmode. */ TYPE_NO_FORCE_BLK (type) = 1;
TYPE_NO_FORCE_BLK (type) = 1;
TYPE_MODE (type) = BLKmode; TYPE_MODE (type) = BLKmode;
} }
...@@ -1195,8 +1214,7 @@ layout_type (type) ...@@ -1195,8 +1214,7 @@ layout_type (type)
} }
TYPE_MODE (type) TYPE_MODE (type)
= mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)), = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
MODE_INT, 1);
union_lose: ; union_lose: ;
} }
......
...@@ -1799,6 +1799,14 @@ extern tree type_hash_canon PARAMS ((int, tree)); ...@@ -1799,6 +1799,14 @@ extern tree type_hash_canon PARAMS ((int, tree));
extern void layout_decl PARAMS ((tree, unsigned)); 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. */ /* Return an expr equal to X but certainly not valid as an lvalue. */
extern tree non_lvalue PARAMS ((tree)); extern tree non_lvalue PARAMS ((tree));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment