public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/meissner/heads/work104)] Adjust precision sizes.
@ 2023-01-05 17:59 Michael Meissner
0 siblings, 0 replies; only message in thread
From: Michael Meissner @ 2023-01-05 17:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c3ee7e1c90431f86c0c9abc92ec18b25b0997db6
commit c3ee7e1c90431f86c0c9abc92ec18b25b0997db6
Author: Michael Meissner <meissner@linux.ibm.com>
Date: Thu Jan 5 12:59:31 2023 -0500
Adjust precision sizes.
2022-01-05 Michael Meissner <meissner@linux.ibm.com>
gcc/
* config/rs6000/rs6000-modes.def (IFmode): Adjust precision to be the
same as TFmode if long double is IBM 128-bit.
(KFmode): Adjust precision to be the same as TFmode if long double is
IEEE 128-bit.
* genmodes.cc (struct mode_data): Add support for ADJUST_PRECISION.
(blank_mode): Likewise.
(adj_precision): Likewise.
(ADJUST_PRECISION): New macro to control precision.
(emit_mode_unit_precision_inline): Add support for ADJUST_PRECISION.
(emit_insn_modes_h): Likewise.
(emit_mode_adjustments): Likewise.
* machmode.def (ADJST_PRECISION): Add to comment describing options that
can modify mode information.
* machmode.h (mode_unit_precision): Add support for ADJUST_PRECISION.
Diff:
---
gcc/config/rs6000/rs6000-modes.def | 4 +++
gcc/genmodes.cc | 57 ++++++++++++++++++++++++++++++++++----
gcc/machmode.def | 7 +++--
gcc/machmode.h | 2 +-
4 files changed, 61 insertions(+), 9 deletions(-)
diff --git a/gcc/config/rs6000/rs6000-modes.def b/gcc/config/rs6000/rs6000-modes.def
index 8ef910869c5..84854ca3b93 100644
--- a/gcc/config/rs6000/rs6000-modes.def
+++ b/gcc/config/rs6000/rs6000-modes.def
@@ -43,9 +43,13 @@
/* IBM 128-bit floating point. */
FRACTIONAL_FLOAT_MODE (IF, FLOAT_PRECISION_IFmode, 16, ibm_extended_format);
+ADJUST_PRECISION(IF, FLOAT128_IBM_P (TFmode) \
+ ? FLOAT_PRECISION_TFmode : FLOAT_PRECISION_IFmode);
/* Explicit IEEE 128-bit floating point. */
FRACTIONAL_FLOAT_MODE (KF, FLOAT_PRECISION_KFmode, 16, ieee_quad_format);
+ADJUST_PRECISION(KF, FLOAT128_IEEE_P (TFmode) \
+ ? FLOAT_PRECISION_TFmode : FLOAT_PRECISION_KFmode);
/* 128-bit floating point, either IBM 128-bit or IEEE 128-bit. This is
adjusted in rs6000_option_override_internal to be the appropriate floating
diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc
index 2d418f09aab..67914ae5630 100644
--- a/gcc/genmodes.cc
+++ b/gcc/genmodes.cc
@@ -77,6 +77,8 @@ struct mode_data
adjustment */
bool need_bytesize_adj; /* true if this mode needs dynamic size
adjustment */
+ bool need_precision_adj; /* true if this mode needs dynamic precision
+ adjustment */
unsigned int int_n; /* If nonzero, then __int<INT_N> will be defined */
bool boolean;
};
@@ -89,7 +91,7 @@ static const struct mode_data blank_mode = {
0, "<unknown>", MAX_MODE_CLASS,
0, -1U, -1U, -1U, -1U,
0, 0, 0, 0, 0, 0,
- "<unknown>", 0, 0, 0, 0, false, false, 0,
+ "<unknown>", 0, 0, 0, 0, false, false, false, 0,
false
};
@@ -114,6 +116,7 @@ static struct mode_adjust *adj_alignment;
static struct mode_adjust *adj_format;
static struct mode_adjust *adj_ibit;
static struct mode_adjust *adj_fbit;
+static struct mode_adjust *adj_precision;
/* Mode class operations. */
static enum mode_class
@@ -822,6 +825,7 @@ make_vector_mode (enum mode_class bclass,
#define ADJUST_FLOAT_FORMAT(M, X) _ADD_ADJUST (format, M, X, FLOAT, FLOAT)
#define ADJUST_IBIT(M, X) _ADD_ADJUST (ibit, M, X, ACCUM, UACCUM)
#define ADJUST_FBIT(M, X) _ADD_ADJUST (fbit, M, X, FRACT, UACCUM)
+#define ADJUST_PRECISION(M, X) _ADD_ADJUST (precision, M, X, FLOAT, FLOAT)
static int bits_per_unit;
static int max_bitsize_mode_any_int;
@@ -1212,7 +1216,8 @@ extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
unsigned short\n\
mode_unit_precision_inline (machine_mode mode)\n\
{\n\
- extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];\n\
+ extern CONST_MODE_PRECISION unsigned short \n\
+ mode_unit_precision[NUM_MACHINE_MODES];\n\
gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
switch (mode)\n\
{");
@@ -1360,7 +1365,8 @@ enum machine_mode\n{");
/* I can't think of a better idea, can you? */
printf ("#define CONST_MODE_NUNITS%s\n", adj_nunits ? "" : " const");
- printf ("#define CONST_MODE_PRECISION%s\n", adj_nunits ? "" : " const");
+ printf ("#define CONST_MODE_PRECISION%s\n",
+ adj_precision || adj_nunits ? "" : " const");
printf ("#define CONST_MODE_SIZE%s\n",
adj_bytesize || adj_nunits ? "" : " const");
printf ("#define CONST_MODE_UNIT_SIZE%s\n", adj_bytesize ? "" : " const");
@@ -1479,7 +1485,7 @@ emit_mode_precision (void)
struct mode_data *m;
print_maybe_const_decl ("%spoly_uint16_pod", "mode_precision",
- "NUM_MACHINE_MODES", adj_nunits);
+ "NUM_MACHINE_MODES", adj_precision || adj_nunits);
for_all_modes (c, m)
if (m->precision != (unsigned int)-1)
@@ -1699,7 +1705,8 @@ emit_mode_unit_precision (void)
int c;
struct mode_data *m;
- print_decl ("unsigned short", "mode_unit_precision", "NUM_MACHINE_MODES");
+ print_maybe_const_decl ("%sunsigned short", "mode_unit_precision",
+ "NUM_MACHINE_MODES", adj_precision);
for_all_modes (c, m)
{
@@ -1963,6 +1970,46 @@ emit_mode_adjustments (void)
printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (E_%smode) = %s;\n",
a->file, a->line, a->mode->name, a->adjustment);
+
+ /* Precision adjustments propagate too. */
+ for (a = adj_precision; a; a = a->next)
+ {
+ printf ("\n /* %s:%d */\n s = %s;\n",
+ a->file, a->line, a->adjustment);
+ printf (" mode_unit_precision[E_%smode] = s;\n", a->mode->name);
+
+ for (m = a->mode->contained; m; m = m->next_cont)
+ {
+ switch (m->cl)
+ {
+ case MODE_COMPLEX_INT:
+ case MODE_COMPLEX_FLOAT:
+ printf (" mode_unit_precision[E_%smode] = s;\n", m->name);
+ break;
+
+ case MODE_VECTOR_BOOL:
+ /* Changes to BImode should not affect vector booleans. */
+ break;
+
+ case MODE_VECTOR_INT:
+ case MODE_VECTOR_FLOAT:
+ case MODE_VECTOR_FRACT:
+ case MODE_VECTOR_UFRACT:
+ case MODE_VECTOR_ACCUM:
+ case MODE_VECTOR_UACCUM:
+ printf (" mode_unit_precision[E_%smode] = %d*s;\n",
+ m->name, m->ncomponents);
+ break;
+
+ default:
+ internal_error (
+ "mode %s is neither vector nor complex but contains %s",
+ m->name, a->mode->name);
+ /* NOTREACHED */
+ }
+ }
+ }
+
puts ("}");
}
diff --git a/gcc/machmode.def b/gcc/machmode.def
index 62e2ba10d45..343dabc1b2e 100644
--- a/gcc/machmode.def
+++ b/gcc/machmode.def
@@ -171,9 +171,10 @@ along with GCC; see the file COPYING3. If not see
ADJUST_FLOAT_FORMAT (MODE, EXPR);
ADJUST_IBIT (MODE, EXPR);
ADJUST_FBIT (MODE, EXPR);
- Arrange for the byte size, alignment, floating point format, ibit,
- or fbit of MODE to be adjustable at run time. EXPR will be executed
- once after processing all command line options, and should
+ ADJUST_PRECISION (MODE, EXPR);
+ Arrange for the byte size, alignment, floating point format, ibit, fbit
+ or precision mode of MODE to be adjustable at run time. EXPR will be
+ executed once after processing all command line options, and should
evaluate to the desired byte size, alignment, format, ibit or fbit.
Unlike a FORMAT argument, if you are adjusting a float format
diff --git a/gcc/machmode.h b/gcc/machmode.h
index f1865c1ef42..e4e0caf9abb 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -27,7 +27,7 @@ extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
extern const unsigned char mode_inner[NUM_MACHINE_MODES];
extern CONST_MODE_NUNITS poly_uint16_pod 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_MODE_PRECISION unsigned short mode_unit_precision[NUM_MACHINE_MODES];
extern const unsigned char mode_next[NUM_MACHINE_MODES];
extern const unsigned char mode_wider[NUM_MACHINE_MODES];
extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-05 17:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 17:59 [gcc(refs/users/meissner/heads/work104)] Adjust precision sizes Michael Meissner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).