aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog35
-rw-r--r--gcc/config/powerpcspe/powerpcspe-c.c4
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-types.c16
-rw-r--r--gcc/genconditions.c1
-rw-r--r--gcc/genmodes.c6
-rw-r--r--gcc/machmode.h146
-rw-r--r--gcc/system.h6
8 files changed, 166 insertions, 55 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 6e24d26..b15b1b7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -2,6 +2,41 @@
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
+ * genconditions.c (write_header): Add a "#define USE_ENUM_MODES".
+ * genmodes.c (emit_insn_modes_h): Define FOOmode to E_FOOmode if
+ USE_ENUM_MODES is defined and to ((void) 0, E_FOOmode) otherwise.
+ * machmode.h (mode_size): Move earlier in file.
+ (mode_precision): Likewise.
+ (mode_inner): Likewise.
+ (mode_nunits): Likewise.
+ (mode_unit_size): Likewise.
+ (unit_unit_precision): Likewise.
+ (mode_wider): Likewise.
+ (mode_2xwider): Likewise.
+ (machine_mode): New class.
+ (mode_to_bytes): New function.
+ (mode_to_bits): Likewise.
+ (mode_to_precision): Likewise.
+ (mode_to_inner): Likewise.
+ (mode_to_unit_size): Likewise.
+ (mode_to_unit_precision): Likewise.
+ (mode_to_nunits): Likewise.
+ (GET_MODE_SIZE): Use mode_to_bytes.
+ (GET_MODE_BITSIZE): Use mode_to_bits.
+ (GET_MODE_PRECISION): Use mode_to_precision.
+ (GET_MODE_INNER): Use mode_to_inner.
+ (GET_MODE_UNIT_SIZE): Use mode_to_unit_size.
+ (GET_MODE_UNIT_PRECISION): Use mode_to_unit_precision.
+ (GET_MODE_NUNITS): Use mode_to_nunits.
+ * system.h (ALWAYS_INLINE): New macro.
+ * config/powerpcspe/powerpcspe-c.c
+ (altivec_resolve_overloaded_builtin): Use machine_mode instead of
+ int for arg1_mode and arg2_mode.
+
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
* config/aarch64/aarch64-builtins.c (aarch64_simd_builtin_std_type):
Prefix mode names with E_ in case statements.
* config/aarch64/aarch64-elf.h (ASM_OUTPUT_ADDR_DIFF_ELT): Likewise.
diff --git a/gcc/config/powerpcspe/powerpcspe-c.c b/gcc/config/powerpcspe/powerpcspe-c.c
index 0da84ad..db04153 100644
--- a/gcc/config/powerpcspe/powerpcspe-c.c
+++ b/gcc/config/powerpcspe/powerpcspe-c.c
@@ -6504,8 +6504,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
if (fcode == P6_OV_BUILTIN_CMPB)
{
int overloaded_code;
- int arg1_mode = TYPE_MODE (types[0]);
- int arg2_mode = TYPE_MODE (types[1]);
+ machine_mode arg1_mode = TYPE_MODE (types[0]);
+ machine_mode arg2_mode = TYPE_MODE (types[1]);
if (nargs != 2)
{
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 56a0ed9..fe2d802 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
+ Alan Hayward <alan.hayward@arm.com>
+ David Sherwood <david.sherwood@arm.com>
+
+ * trans-types.c (gfc_init_kinds): Use machine_mode instead of int
+ for "mode".
+
2017-08-28 Janus Weil <janus@gcc.gnu.org>
PR fortran/81770
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 76ee97b..7d2d274 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -363,22 +363,23 @@ gfc_init_c_interop_kinds (void)
void
gfc_init_kinds (void)
{
- unsigned int mode;
+ machine_mode mode;
int i_index, r_index, kind;
bool saw_i4 = false, saw_i8 = false;
bool saw_r4 = false, saw_r8 = false, saw_r10 = false, saw_r16 = false;
- for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT; mode++)
+ for (i_index = 0, mode = MIN_MODE_INT; mode <= MAX_MODE_INT;
+ mode = (machine_mode) ((int) mode + 1))
{
int kind, bitsize;
- if (!targetm.scalar_mode_supported_p ((machine_mode) mode))
+ if (!targetm.scalar_mode_supported_p (mode))
continue;
/* The middle end doesn't support constants larger than 2*HWI.
Perhaps the target hook shouldn't have accepted these either,
but just to be safe... */
- bitsize = GET_MODE_BITSIZE ((machine_mode) mode);
+ bitsize = GET_MODE_BITSIZE (mode);
if (bitsize > 2*HOST_BITS_PER_WIDE_INT)
continue;
@@ -418,15 +419,16 @@ gfc_init_kinds (void)
/* Set the maximum integer kind. Used with at least BOZ constants. */
gfc_max_integer_kind = gfc_integer_kinds[i_index - 1].kind;
- for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT; mode++)
+ for (r_index = 0, mode = MIN_MODE_FLOAT; mode <= MAX_MODE_FLOAT;
+ mode = (machine_mode) ((int) mode + 1))
{
const struct real_format *fmt =
- REAL_MODE_FORMAT ((machine_mode) mode);
+ REAL_MODE_FORMAT (mode);
int kind;
if (fmt == NULL)
continue;
- if (!targetm.scalar_mode_supported_p ((machine_mode) mode))
+ if (!targetm.scalar_mode_supported_p (mode))
continue;
/* Only let float, double, long double and __float128 go through.
diff --git a/gcc/genconditions.c b/gcc/genconditions.c
index afe3a4f..f62ff16 100644
--- a/gcc/genconditions.c
+++ b/gcc/genconditions.c
@@ -67,6 +67,7 @@ write_header (void)
#undef ENABLE_RTL_FLAG_CHECKING\n\
#undef ENABLE_GC_CHECKING\n\
#undef ENABLE_GC_ALWAYS_COLLECT\n\
+#define USE_ENUM_MODES\n\
\n\
#include \"coretypes.h\"\n\
#include \"tm.h\"\n\
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 4cd0dc1..96b6ece 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -1155,8 +1155,12 @@ enum machine_mode\n{");
printf ("%*s/* %s:%d */\n", 27 - count_, "",
trim_filename (m->file), m->line);
printf ("#define HAVE_%smode\n", m->name);
- printf ("#define %smode E_%smode\n",
+ printf ("#ifdef USE_ENUM_MODES\n");
+ printf ("#define %smode E_%smode\n", m->name, m->name);
+ printf ("#else\n");
+ printf ("#define %smode ((void) 0, E_%smode)\n",
m->name, m->name);
+ printf ("#endif\n");
}
puts (" MAX_MACHINE_MODE,\n");
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 4b861ac..330fdf9 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -20,6 +20,15 @@ along with GCC; see the file COPYING3. If not see
#ifndef HAVE_MACHINE_MODES
#define HAVE_MACHINE_MODES
+extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES];
+extern const unsigned short mode_precision[NUM_MACHINE_MODES];
+extern const unsigned char mode_inner[NUM_MACHINE_MODES];
+extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
+extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
+extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
+extern const unsigned char mode_wider[NUM_MACHINE_MODES];
+extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
+
/* Get the name of mode MODE as a string. */
extern const char * const mode_name[NUM_MACHINE_MODES];
@@ -174,22 +183,98 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
#define POINTER_BOUNDS_MODE_P(MODE) \
(GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
-/* Get the size in bytes and bits of an object of mode MODE. */
+/* Return the base GET_MODE_SIZE value for MODE. */
-extern CONST_MODE_SIZE unsigned short mode_size[NUM_MACHINE_MODES];
+ALWAYS_INLINE unsigned short
+mode_to_bytes (machine_mode mode)
+{
+#if GCC_VERSION >= 4001
+ return (__builtin_constant_p (mode)
+ ? mode_size_inline (mode) : mode_size[mode]);
+#else
+ return mode_size[mode];
+#endif
+}
+
+/* Return the base GET_MODE_BITSIZE value for MODE. */
+
+ALWAYS_INLINE unsigned short
+mode_to_bits (machine_mode mode)
+{
+ return mode_to_bytes (mode) * BITS_PER_UNIT;
+}
+
+/* Return the base GET_MODE_PRECISION value for MODE. */
+
+ALWAYS_INLINE unsigned short
+mode_to_precision (machine_mode mode)
+{
+ return mode_precision[mode];
+}
+
+/* Return the base GET_MODE_INNER value for MODE. */
+
+ALWAYS_INLINE machine_mode
+mode_to_inner (machine_mode mode)
+{
+#if GCC_VERSION >= 4001
+ return (machine_mode) (__builtin_constant_p (mode)
+ ? mode_inner_inline (mode) : mode_inner[mode]);
+#else
+ return (machine_mode) mode_inner[mode];
+#endif
+}
+
+/* Return the base GET_MODE_UNIT_SIZE value for MODE. */
+
+ALWAYS_INLINE unsigned char
+mode_to_unit_size (machine_mode mode)
+{
+#if GCC_VERSION >= 4001
+ return (__builtin_constant_p (mode)
+ ? mode_unit_size_inline (mode) : mode_unit_size[mode]);
+#else
+ return mode_unit_size[mode];
+#endif
+}
+
+/* Return the base GET_MODE_UNIT_PRECISION value for MODE. */
+
+ALWAYS_INLINE unsigned short
+mode_to_unit_precision (machine_mode mode)
+{
+#if GCC_VERSION >= 4001
+ return (__builtin_constant_p (mode)
+ ? mode_unit_precision_inline (mode) : mode_unit_precision[mode]);
+#else
+ return mode_unit_precision[mode];
+#endif
+}
+
+/* Return the base GET_MODE_NUNITS value for MODE. */
+
+ALWAYS_INLINE unsigned short
+mode_to_nunits (machine_mode mode)
+{
#if GCC_VERSION >= 4001
-#define GET_MODE_SIZE(MODE) \
- ((unsigned short) (__builtin_constant_p (MODE) \
- ? mode_size_inline (MODE) : mode_size[MODE]))
+ return (__builtin_constant_p (mode)
+ ? mode_nunits_inline (mode) : mode_nunits[mode]);
#else
-#define GET_MODE_SIZE(MODE) ((unsigned short) mode_size[MODE])
+ return mode_nunits[mode];
#endif
-#define GET_MODE_BITSIZE(MODE) \
- ((unsigned short) (GET_MODE_SIZE (MODE) * BITS_PER_UNIT))
+}
+
+/* Get the size in bytes of an object of mode MODE. */
+
+#define GET_MODE_SIZE(MODE) (mode_to_bytes (MODE))
+
+/* Get the size in bits of an object of mode MODE. */
+
+#define GET_MODE_BITSIZE(MODE) (mode_to_bits (MODE))
/* 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]
+
+#define GET_MODE_PRECISION(MODE) (mode_to_precision (MODE))
/* Get the number of integral bits of an object of mode MODE. */
extern CONST_MODE_IBIT unsigned char mode_ibit[NUM_MACHINE_MODES];
@@ -210,51 +295,22 @@ extern const unsigned HOST_WIDE_INT mode_mask_array[NUM_MACHINE_MODES];
mode of the vector elements. For complex modes it is the mode of the real
and imaginary parts. For other modes it is MODE itself. */
-extern const unsigned char mode_inner[NUM_MACHINE_MODES];
-#if GCC_VERSION >= 4001
-#define GET_MODE_INNER(MODE) \
- ((machine_mode) (__builtin_constant_p (MODE) \
- ? mode_inner_inline (MODE) : mode_inner[MODE]))
-#else
-#define GET_MODE_INNER(MODE) ((machine_mode) mode_inner[MODE])
-#endif
+#define GET_MODE_INNER(MODE) (mode_to_inner (MODE))
/* Get the size in bytes or bits of the basic parts of an
object of mode MODE. */
-extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
-#if GCC_VERSION >= 4001
-#define GET_MODE_UNIT_SIZE(MODE) \
- ((unsigned char) (__builtin_constant_p (MODE) \
- ? mode_unit_size_inline (MODE) : mode_unit_size[MODE]))
-#else
-#define GET_MODE_UNIT_SIZE(MODE) mode_unit_size[MODE]
-#endif
+#define GET_MODE_UNIT_SIZE(MODE) mode_to_unit_size (MODE)
#define GET_MODE_UNIT_BITSIZE(MODE) \
((unsigned short) (GET_MODE_UNIT_SIZE (MODE) * BITS_PER_UNIT))
-extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
-#if GCC_VERSION >= 4001
-#define GET_MODE_UNIT_PRECISION(MODE) \
- ((unsigned short) (__builtin_constant_p (MODE) \
- ? mode_unit_precision_inline (MODE)\
- : mode_unit_precision[MODE]))
-#else
-#define GET_MODE_UNIT_PRECISION(MODE) mode_unit_precision[MODE]
-#endif
-
+#define GET_MODE_UNIT_PRECISION(MODE) (mode_to_unit_precision (MODE))
-/* Get the number of units in the object. */
+/* Get the number of units in an object of mode MODE. This is 2 for
+ complex modes and the number of elements for vector modes. */
-extern const unsigned char mode_nunits[NUM_MACHINE_MODES];
-#if GCC_VERSION >= 4001
-#define GET_MODE_NUNITS(MODE) \
- ((unsigned char) (__builtin_constant_p (MODE) \
- ? mode_nunits_inline (MODE) : mode_nunits[MODE]))
-#else
-#define GET_MODE_NUNITS(MODE) mode_nunits[MODE]
-#endif
+#define GET_MODE_NUNITS(MODE) (mode_to_nunits (MODE))
/* Get the next wider natural mode (eg, QI -> HI -> SI -> DI -> TI). */
diff --git a/gcc/system.h b/gcc/system.h
index b091794..5e16a77 100644
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -745,6 +745,12 @@ extern void fancy_abort (const char *, int, const char *)
#define gcc_checking_assert(EXPR) ((void)(0 && (EXPR)))
#endif
+#if GCC_VERSION >= 4000
+#define ALWAYS_INLINE inline __attribute__ ((always_inline))
+#else
+#define ALWAYS_INLINE inline
+#endif
+
/* Use gcc_unreachable() to mark unreachable locations (like an
unreachable default case of a switch. Do not use gcc_assert(0). */
#if (GCC_VERSION >= 4005) && !ENABLE_ASSERT_CHECKING