/* 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.
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. */
-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. */
-extern enum machine_mode smallest_mode_for_size PARAMS ((unsigned int,
- enum mode_class));
+extern enum machine_mode smallest_mode_for_size
+ PARAMS ((int, enum mode_class));
/* Return an integer mode of the exact same size as the input mode,
enum machine_mode
mode_for_size (size, class, limit)
- unsigned int size;
+ int size;
enum mode_class class;
int limit;
{
register enum machine_mode mode;
- if (limit && size > (unsigned int)(MAX_FIXED_MODE_SIZE))
+ if (limit && size > MAX_FIXED_MODE_SIZE)
return BLKmode;
/* Get the first mode which has this size, in the specified class. */
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
- if ((unsigned int)GET_MODE_BITSIZE (mode) == size)
+ if (GET_MODE_BITSIZE (mode) == size)
return mode;
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
contains at least the requested number of bits. */
enum machine_mode
smallest_mode_for_size (size, class)
- unsigned int size;
+ int size;
enum mode_class class;
{
register enum machine_mode mode;
specified class. */
for (mode = GET_CLASS_NARROWEST_MODE (class); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
- if ((unsigned int)GET_MODE_BITSIZE (mode) >= size)
+ if (GET_MODE_BITSIZE (mode) >= size)
return mode;
abort ();
&& GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
{
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
&& known_align % GET_MODE_ALIGNMENT (xmode) == 0)
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. */
&& (TYPE_MODE (TREE_TYPE (type)) != BLKmode
|| TYPE_NO_FORCE_BLK (TREE_TYPE (type))))
{
TYPE_MODE (type)
- = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
- MODE_INT, 1);
+ = mode_for_size_tree (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)))
+ 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)
{
TYPE_NO_FORCE_BLK (type) = 1;
TYPE_MODE (type) = mode;
else
TYPE_MODE (type)
- = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
- MODE_INT, 1);
+ = 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 (STRICT_ALIGNMENT
+ if (TYPE_MODE (type) != BLKmode
+ && STRICT_ALIGNMENT
&& ! (TYPE_ALIGN (type) >= BIGGEST_ALIGNMENT
- || ((int) TYPE_ALIGN (type)
- >= TREE_INT_CST_LOW (TYPE_SIZE (type)))))
+ || (TYPE_ALIGN (type) >=
+ GET_MODE_ALIGNMENT (TYPE_MODE (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;
+ /* 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;
}
}
TYPE_MODE (type)
- = mode_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
- MODE_INT, 1);
+ = mode_for_size_tree (TYPE_SIZE (type), MODE_INT, 1);
union_lose: ;
}