summaryrefslogtreecommitdiff
path: root/gcc/fortran
diff options
context:
space:
mode:
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-30 11:08:36 +0000
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>2017-08-30 11:08:36 +0000
commitfb3982299800fc5e3b215af541bebf0140fad231 (patch)
tree7838879f1acc681160dd36fd74ccba491b695ba5 /gcc/fortran
parent916ace949a8cdc6a4b2f2bf187e525549a4c0ad3 (diff)
downloadgcc-fb3982299800fc5e3b215af541bebf0140fad231.tar.gz
[3/77] Allow machine modes to be classes
This patch makes various changes that allow modes like SImode to be classes rather than enums. Firstly, it adds inline functions for all mode size properties, with the macros being simple wrappers around them. This is necessary for the __builtin_constant_p trick to continue working effectively when the mode arguments are slightly more complex (but still foldable at compile time). These inline functions are trivial and heavily used. There's not much point keeping them out-of-line at -O0: if anything it would make debugging harder rather than easier, and it would also slow things down. The patch therefore marks them as "always_inline", if that's available. Later patches use this approach too. Using inline functions means that it's no longer possible to pass an int to GET_MODE_PRECISION etc. The Fortran and powerpcspe-c.c parts are needed to avoid instances of that. The patch continues to use enums for gencondmd.c, so that more mode comparisons are integer constant expressions when checking for always-true or always-false conditions. This is the only intended use of USE_ENUM_MODES. The patch also enforces the previous replacement of case statements by defining modes as: #define FOOmode ((void) 0, E_FOOmode) This adds no overhead but makes sure that new uses of "case FOOmode:" don't accidentally creep in when FOOmode has no specific class associated with it. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * 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. gcc/fortran/ * trans-types.c (gfc_init_kinds): Use machine_mode instead of int for "mode". git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251454 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran')
-rw-r--r--gcc/fortran/ChangeLog7
-rw-r--r--gcc/fortran/trans-types.c16
2 files changed, 16 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 56a0ed94b11..fe2d80214a5 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 76ee97b81c0..7d2d274d3ba 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.