machmode.h (to_machine_mode): New.
[gcc.git] / gcc / machmode.h
index 4c4086c312dd6abd6040b451b03e90a62dbc049d..f8ff132372909671fa35edf0a3db9cd857f3816f 100644 (file)
@@ -25,6 +25,10 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 /* Make an enum class that gives all the machine modes.  */
 #include "insn-modes.h"
 
+/* Given MODE as integer value, get the corresponding enum machine_mode
+   enumeration value.  */
+#define to_machine_mode(MODE)  ((enum machine_mode) (MODE))
+
 /* Get the name of mode MODE as a string.  */
 
 extern const char * const mode_name[NUM_MACHINE_MODES];
@@ -76,30 +80,15 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
 #define SCALAR_FLOAT_MODE_P(MODE)              \
   (GET_MODE_CLASS (MODE) == MODE_FLOAT)
 
-/* Get the size in bytes of an object of mode MODE.  */
-
-extern const unsigned char mode_size[NUM_MACHINE_MODES];
-#define GET_MODE_SIZE(MODE)   mode_size[MODE]
-
-/* Get the size in bytes of the basic parts of an object of mode MODE.  */
-
-extern const unsigned char mode_unit_size[NUM_MACHINE_MODES];
-#define GET_MODE_UNIT_SIZE(MODE)  mode_unit_size[MODE]
+/* Get the size in bytes and bits of an object of mode MODE.  */
 
-/* Get the number of units in the object.  */
-
-#define GET_MODE_NUNITS(MODE)  \
-  ((GET_MODE_UNIT_SIZE ((MODE)) == 0) ? 0 \
-   : (GET_MODE_SIZE ((MODE)) / GET_MODE_UNIT_SIZE ((MODE))))
-
-/* Get the size in bits of an object of mode MODE.  */
-
-extern const unsigned short mode_bitsize[NUM_MACHINE_MODES];
-#define GET_MODE_BITSIZE(MODE)  mode_bitsize[MODE]
-
-#endif /* not HAVE_MACHINE_MODES */
+extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
+#define GET_MODE_SIZE(MODE)    ((unsigned short) mode_size[MODE])
+#define GET_MODE_BITSIZE(MODE) ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT))
 
-#if defined HOST_WIDE_INT && ! defined GET_MODE_MASK
+/* Get the number of value bits of an object of mode MODE.  */
+extern const unsigned short mode_precision[NUM_MACHINE_MODES];
+#define GET_MODE_PRECISION(MODE)  mode_precision[MODE]
 
 /* Get a bitmask containing 1 for all bits in a word
    that fit within mode MODE.  */
@@ -108,22 +97,31 @@ extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
 
 #define GET_MODE_MASK(MODE) mode_mask_array[MODE]
 
-extern const unsigned char mode_inner[NUM_MACHINE_MODES];
-
 /* Return the mode of the inner elements in a vector.  */
 
+extern const unsigned char mode_inner[NUM_MACHINE_MODES];
 #define GET_MODE_INNER(MODE) mode_inner[MODE]
 
-#endif /* defined (HOST_WIDE_INT) && ! defined GET_MODE_MASK */
+/* Get the size in bytes of the basic parts of an object of mode MODE.  */
+
+#define GET_MODE_UNIT_SIZE(MODE)               \
+  (GET_MODE_INNER (MODE) == VOIDmode           \
+   ? GET_MODE_SIZE (MODE)                      \
+   : GET_MODE_SIZE (GET_MODE_INNER (MODE)))
 
-#if ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT \
-    || ! defined GET_CLASS_NARROWEST_MODE
+/* Get the number of units in the object.  */
+
+extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
+#define GET_MODE_NUNITS(MODE)  mode_nunits[MODE]
 
 /* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI).  */
 
 extern const unsigned char mode_wider[NUM_MACHINE_MODES];
 #define GET_MODE_WIDER_MODE(MODE) mode_wider[MODE]
 
+extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
+#define GET_MODE_2XWIDER_MODE(MODE) mode_2xwider[MODE]
+
 /* 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.  */
@@ -148,7 +146,7 @@ extern enum machine_mode get_best_mode (int, int, unsigned int,
 
 /* Determine alignment, 1<=result<=BIGGEST_ALIGNMENT.  */
 
-extern const unsigned char mode_base_align[NUM_MACHINE_MODES];
+extern CONST_MODE_BASE_ALIGN unsigned char mode_base_align[NUM_MACHINE_MODES];
 
 extern unsigned get_mode_alignment (enum machine_mode);
 
@@ -166,5 +164,7 @@ extern enum machine_mode byte_mode;
 extern enum machine_mode word_mode;
 extern enum machine_mode ptr_mode;
 
-#endif /* ! defined GET_MODE_WIDER_MODE || ! defined GET_MODE_ALIGNMENT
-         || ! defined GET_CLASS_NARROWEST_MODE */
+/* Target-dependent machine mode initialization - in insn-modes.c.  */
+extern void init_adjust_machine_modes (void);
+
+#endif /* not HAVE_MACHINE_MODES */