1 /* Machine mode definitions for GCC; included by rtl.h and tree.h.
2 Copyright (C) 1991, 1993, 1994, 1996, 1998, 1999, 2000, 2001, 2003
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef HAVE_MACHINE_MODES
23 #define HAVE_MACHINE_MODES
25 /* Make an enum class that gives all the machine modes. */
26 #include "insn-modes.h"
28 /* Get the name of mode MODE as a string. */
30 extern const char * const mode_name
[NUM_MACHINE_MODES
];
31 #define GET_MODE_NAME(MODE) mode_name[MODE]
35 #include "mode-classes.def"
36 #define DEF_MODE_CLASS(M) M
37 enum mode_class
{ MODE_CLASSES
, MAX_MODE_CLASS
};
41 /* Get the general kind of object that mode MODE represents
42 (integer, floating, complex, etc.) */
44 extern const unsigned char mode_class
[NUM_MACHINE_MODES
];
45 #define GET_MODE_CLASS(MODE) mode_class[MODE]
47 /* Nonzero if MODE is an integral mode. */
48 #define INTEGRAL_MODE_P(MODE) \
49 (GET_MODE_CLASS (MODE) == MODE_INT \
50 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT \
51 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
52 || GET_MODE_CLASS (MODE) == MODE_VECTOR_INT)
54 /* Nonzero if MODE is a floating-point mode. */
55 #define FLOAT_MODE_P(MODE) \
56 (GET_MODE_CLASS (MODE) == MODE_FLOAT \
57 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT \
58 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
60 /* Nonzero if MODE is a complex mode. */
61 #define COMPLEX_MODE_P(MODE) \
62 (GET_MODE_CLASS (MODE) == MODE_COMPLEX_INT \
63 || GET_MODE_CLASS (MODE) == MODE_COMPLEX_FLOAT)
65 /* Nonzero if MODE is a vector mode. */
66 #define VECTOR_MODE_P(MODE) \
67 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \
68 || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
70 /* Nonzero if MODE is a scalar integral mode. */
71 #define SCALAR_INT_MODE_P(MODE) \
72 (GET_MODE_CLASS (MODE) == MODE_INT \
73 || GET_MODE_CLASS (MODE) == MODE_PARTIAL_INT)
75 /* Nonzero if MODE is a scalar floating point mode. */
76 #define SCALAR_FLOAT_MODE_P(MODE) \
77 (GET_MODE_CLASS (MODE) == MODE_FLOAT)
79 /* Get the size in bytes of an object of mode MODE. */
81 extern const unsigned char mode_size
[NUM_MACHINE_MODES
];
82 #define GET_MODE_SIZE(MODE) mode_size[MODE]
84 /* Get the size in bytes of the basic parts of an object of mode MODE. */
86 extern const unsigned char mode_unit_size
[NUM_MACHINE_MODES
];
87 #define GET_MODE_UNIT_SIZE(MODE) mode_unit_size[MODE]
89 /* Get the number of units in the object. */
91 #define GET_MODE_NUNITS(MODE) \
92 ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \
93 : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE))))
95 /* Get the size in bits of an object of mode MODE. */
97 extern const unsigned short mode_bitsize
[NUM_MACHINE_MODES
];
98 #define GET_MODE_BITSIZE(MODE) mode_bitsize[MODE]
100 #endif /* not HAVE_MACHINE_MODES */
102 #if defined HOST_WIDE_INT && ! defined GET_MODE_MASK
104 /* Get a bitmask containing 1 for all bits in a word
105 that fit within mode MODE. */
107 extern const unsigned HOST_WIDE_INT mode_mask_array
[NUM_MACHINE_MODES
];
109 #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
111 extern const unsigned char mode_inner
[NUM_MACHINE_MODES
];
113 /* Return the mode of the inner elements in a vector. */
115 #define GET_MODE_INNER(MODE) mode_inner[MODE]
117 #endif /* defined (HOST_WIDE_INT) && ! defined GET_MODE_MASK */
119 #if ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT \
120 || ! defined GET_CLASS_NARROWEST_MODE
122 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
124 extern const unsigned char mode_wider
[NUM_MACHINE_MODES
];
125 #define GET_MODE_WIDER_MODE(MODE) mode_wider[MODE]
127 /* Return the mode for data of a given size SIZE and mode class CLASS.
128 If LIMIT is nonzero, then don't use modes bigger than MAX_FIXED_MODE_SIZE.
129 The value is BLKmode if no other mode is found. */
131 extern enum machine_mode
mode_for_size (unsigned int, enum mode_class
, int);
133 /* Similar, but find the smallest mode for a given width. */
135 extern enum machine_mode
smallest_mode_for_size (unsigned int,
139 /* Return an integer mode of the exact same size as the input mode,
140 or BLKmode on failure. */
142 extern enum machine_mode
int_mode_for_mode (enum machine_mode
);
144 /* Find the best mode to use to access a bit field. */
146 extern enum machine_mode
get_best_mode (int, int, unsigned int,
147 enum machine_mode
, int);
149 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT. */
151 extern const unsigned char mode_base_align
[NUM_MACHINE_MODES
];
153 extern unsigned get_mode_alignment (enum machine_mode
);
155 #define GET_MODE_ALIGNMENT(MODE) get_mode_alignment (MODE)
157 /* For each class, get the narrowest mode in that class. */
159 extern const unsigned char class_narrowest_mode
[MAX_MODE_CLASS
];
160 #define GET_CLASS_NARROWEST_MODE(CLASS) class_narrowest_mode[CLASS]
162 /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD
163 and the mode whose class is Pmode and whose size is POINTER_SIZE. */
165 extern enum machine_mode byte_mode
;
166 extern enum machine_mode word_mode
;
167 extern enum machine_mode ptr_mode
;
169 #endif /* ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT
170 || ! defined GET_CLASS_NARROWEST_MODE */