]> gcc.gnu.org Git - gcc.git/commitdiff
Adjust precision sizes.
authorMichael Meissner <meissner@linux.ibm.com>
Thu, 5 Jan 2023 17:59:31 +0000 (12:59 -0500)
committerMichael Meissner <meissner@linux.ibm.com>
Thu, 5 Jan 2023 17:59:31 +0000 (12:59 -0500)
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.

gcc/config/rs6000/rs6000-modes.def
gcc/genmodes.cc
gcc/machmode.def
gcc/machmode.h

index 8ef910869c577cdd57333eeff430df59466b3720..84854ca3b93a726ee05e0cdf90f8aa94f507722a 100644 (file)
 
 /* 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
index 2d418f09aab68f674f9c31536effe19b42cfdac2..67914ae5630004460a5570b2cd971ab2bd7ba1cf 100644 (file)
@@ -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 ("}");
 }
 
index 62e2ba10d45781dad5073ffeaeca10c11a63d908..343dabc1b2e27c7ca32c8b9570a56ce0418b8c12 100644 (file)
@@ -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
index f1865c1ef425d78bf125dd60923ec64712aae10b..e4e0caf9abbcb42b2eb6c35fbd7f771c39e3e3ab 100644 (file)
@@ -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];
This page took 0.069194 seconds and 5 git commands to generate.