OSDN Git Service

* doc/rtl.texi (Machine Modes): Document QQ, HQ, SQ, DQ, TQ,
authorchaoyingfu <chaoyingfu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Jun 2007 22:51:27 +0000 (22:51 +0000)
committerchaoyingfu <chaoyingfu@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 Jun 2007 22:51:27 +0000 (22:51 +0000)
UQQ, UHQ, USQ, UDQ, UTQ, HA, SA, DA, TA, UHA, USA, UDA, and UTAmodes.
Document MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM.
Document GET_MODE_IBIT, and GET_MODE_FBIT.

* machmode.h (VECTOR_MODE_P): Test MODE_VECTOR_FRACT,
MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM.
(SCALAR_FRACT_MODE_P, SCALAR_UFRACT_MODE_P, ALL_SCALAR_FRACT_MODE_P,
SCALAR_ACCUM_MODE_P, SCALAR_UACCUM_MODE_P, ALL_SCALAR_ACCUM_MODE_P,
SIGNED_SCALAR_FIXED_POINT_MODE_P, UNSIGNED_SCALAR_FIXED_POINT_MODE_P,
ALL_SCALAR_FIXED_POINT_MODE_P, FRACT_MODE_P, UFRACT_MODE_P,
ALL_FRACT_MODE_P, ACCUM_MODE_P, UACCUM_MODE_P, ALL_ACCUM_MODE_P,
SIGNED_FIXED_POINT_MODE_P, UNSIGNED_FIXED_POINT_MODE_P,
ALL_FIXED_POINT_MODE_P): New define.
(CLASS_HAS_WIDER_MODES_P): Test MODE_FRACT, MODE_UFRACT, MODE_ACCUM,
MODE_UACCUM.
(GET_MODE_IBIT, GET_MODE_FBIT): New define.

* mode-classes.def (MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM,
MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM,
MODE_VECTOR_UACCUM): New mode classes.

* machmode.def: Document FRACT_MODE, UFRACT_MODE, ACCUM_MODE,
UACCUM_MODE, ADJUST_IBIT, and ADJUST_FBIT.
Add QQ, HQ, SQ, DQ, TQ, UQQ, UHQ, USQ, UDQ, UTQ, HA, SA, DA, TA, UHA,
USA, UDA, and UTA.

* genmodes.c (struct mode_data): Add ibit and fbit fields.
(blank_mode): Initialize ibit and fbit.
(adj_ibit, adj_fbit): New to adjust ibit and fbit.
(vector_class): Handle MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM.
(new_adjust): Change required_class to required_class_from and
required_class_to for testing within a range.
(complete_mode): Handle MODE_FRACT, MODE_UFRACT, MODE_ACCUM,
MODE_UACCUM, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM,
MODE_VECTOR_UACCUM.
(FRACT_MODE, UFRACT_MODE, ACCUM_MODE, UACCUM_MODE): New define.
(make_fixed_point_mode): New.
(_ADD_ADJUST): Change C to C1 and C2.
(ADJUST_BYTESIZE, ADJUST_ALIGNMENT, ADJUST_FLOAT_FORMAT): Change to
use a range for machine classes.
(ADJUST_IBIT, ADJUST_FBIT): New.
(emit_insn_modes_h): Output defines of CONST_MODE_IBIT and
CONST_MODE_FBIT.
(emit_mode_adjustments): Handle MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT,
MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM.
Emit adjustment for ibit and fbit.
(emit_mode_ibit, emit_mode_fbit): New.
(emit_insn_modes_c): Add emit_mode_ibit and emit_mode_fbit.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@126007 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/doc/rtl.texi
gcc/genmodes.c
gcc/machmode.def
gcc/machmode.h
gcc/mode-classes.def

index 125db40..ed785d5 100644 (file)
@@ -1,3 +1,55 @@
+2007-06-25  Chao-ying Fu  <fu@mips.com>
+
+       * doc/rtl.texi (Machine Modes): Document QQ, HQ, SQ, DQ, TQ,
+       UQQ, UHQ, USQ, UDQ, UTQ, HA, SA, DA, TA, UHA, USA, UDA, and UTAmodes.
+       Document MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM.
+       Document GET_MODE_IBIT, and GET_MODE_FBIT.
+
+       * machmode.h (VECTOR_MODE_P): Test MODE_VECTOR_FRACT,
+       MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM.
+       (SCALAR_FRACT_MODE_P, SCALAR_UFRACT_MODE_P, ALL_SCALAR_FRACT_MODE_P,
+       SCALAR_ACCUM_MODE_P, SCALAR_UACCUM_MODE_P, ALL_SCALAR_ACCUM_MODE_P,
+       SIGNED_SCALAR_FIXED_POINT_MODE_P, UNSIGNED_SCALAR_FIXED_POINT_MODE_P,
+       ALL_SCALAR_FIXED_POINT_MODE_P, FRACT_MODE_P, UFRACT_MODE_P,
+       ALL_FRACT_MODE_P, ACCUM_MODE_P, UACCUM_MODE_P, ALL_ACCUM_MODE_P,
+       SIGNED_FIXED_POINT_MODE_P, UNSIGNED_FIXED_POINT_MODE_P,
+       ALL_FIXED_POINT_MODE_P): New define.
+       (CLASS_HAS_WIDER_MODES_P): Test MODE_FRACT, MODE_UFRACT, MODE_ACCUM,
+       MODE_UACCUM.
+       (GET_MODE_IBIT, GET_MODE_FBIT): New define.
+
+       * mode-classes.def (MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM,
+       MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM,
+       MODE_VECTOR_UACCUM): New mode classes.
+
+       * machmode.def: Document FRACT_MODE, UFRACT_MODE, ACCUM_MODE,
+       UACCUM_MODE, ADJUST_IBIT, and ADJUST_FBIT.
+       Add QQ, HQ, SQ, DQ, TQ, UQQ, UHQ, USQ, UDQ, UTQ, HA, SA, DA, TA, UHA,
+       USA, UDA, and UTA.
+
+       * genmodes.c (struct mode_data): Add ibit and fbit fields.
+       (blank_mode): Initialize ibit and fbit.
+       (adj_ibit, adj_fbit): New to adjust ibit and fbit.
+       (vector_class): Handle MODE_FRACT, MODE_UFRACT, MODE_ACCUM, MODE_UACCUM.
+       (new_adjust): Change required_class to required_class_from and
+       required_class_to for testing within a range.
+       (complete_mode): Handle MODE_FRACT, MODE_UFRACT, MODE_ACCUM,
+       MODE_UACCUM, MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT, MODE_VECTOR_ACCUM,
+       MODE_VECTOR_UACCUM.
+       (FRACT_MODE, UFRACT_MODE, ACCUM_MODE, UACCUM_MODE): New define.
+       (make_fixed_point_mode): New.
+       (_ADD_ADJUST): Change C to C1 and C2.
+       (ADJUST_BYTESIZE, ADJUST_ALIGNMENT, ADJUST_FLOAT_FORMAT): Change to
+       use a range for machine classes.
+       (ADJUST_IBIT, ADJUST_FBIT): New.
+       (emit_insn_modes_h): Output defines of CONST_MODE_IBIT and
+       CONST_MODE_FBIT.
+       (emit_mode_adjustments): Handle MODE_VECTOR_FRACT, MODE_VECTOR_UFRACT,
+       MODE_VECTOR_ACCUM, MODE_VECTOR_UACCUM.
+       Emit adjustment for ibit and fbit.
+       (emit_mode_ibit, emit_mode_fbit): New.
+       (emit_insn_modes_c): Add emit_mode_ibit and emit_mode_fbit.
+
 2007-06-25  Nathan Froyd  <froydnj@codesourcery.com>
 
        * config/rs6000/spe.md (*frob_ti_tf_2): Specify an input_operand
index 09e73e1..fb38f7f 100644 (file)
@@ -1135,6 +1135,96 @@ floating point number all 128 of whose bits are meaningful.
 all 128 of whose bits are meaningful.  One common use is the
 IEEE quad-precision format.
 
+@findex QQmode
+@item QQmode
+``Quarter-Fractional'' mode represents a single byte treated as a signed
+fractional number.  The default format is ``s.7''.
+
+@findex HQmode
+@item HQmode
+``Half-Fractional'' mode represents a two-byte signed fractional number.
+The default format is ``s.15''.
+
+@findex SQmode
+@item SQmode
+``Single Fractional'' mode represents a four-byte signed fractional number.
+The default format is ``s.31''.
+
+@findex DQmode
+@item DQmode
+``Double Fractional'' mode represents an eight-byte signed fractional number.
+The default format is ``s.63''.
+
+@findex TQmode
+@item TQmode
+``Tetra Fractional'' mode represents a sixteen-byte signed fractional number.
+The default format is ``s.127''.
+
+@findex UQQmode
+@item UQQmode
+``Unsigned Quarter-Fractional'' mode represents a single byte treated as an
+unsigned fractional number.  The default format is ``.8''.
+
+@findex UHQmode
+@item UHQmode
+``Unsigned Half-Fractional'' mode represents a two-byte unsigned fractional
+number.  The default format is ``.16''.
+
+@findex USQmode
+@item USQmode
+``Unsigned Single Fractional'' mode represents a four-byte unsigned fractional
+number.  The default format is ``.32''.
+
+@findex UDQmode
+@item UDQmode
+``Unsigned Double Fractional'' mode represents an eight-byte unsigned
+fractional number.  The default format is ``.64''.
+
+@findex UTQmode
+@item UTQmode
+``Unsigned Tetra Fractional'' mode represents a sixteen-byte unsigned
+fractional number.  The default format is ``.128''.
+
+@findex HAmode
+@item HAmode
+``Half-Accumulator'' mode represents a two-byte signed accumulator.
+The default format is ``s8.7''.
+
+@findex SAmode
+@item SAmode
+``Single Accumulator'' mode represents a four-byte signed accumulator.
+The default format is ``s16.15''.
+
+@findex DAmode
+@item DAmode
+``Double Accumulator'' mode represents an eight-byte signed accumulator.
+The default format is ``s32.31''.
+
+@findex TAmode
+@item TAmode
+``Tetra Accumulator'' mode represents a sixteen-byte signed accumulator.
+The default format is ``s64.63''.
+
+@findex UHAmode
+@item UHAmode
+``Unsigned Half-Accumulator'' mode represents a two-byte unsigned accumulator.
+The default format is ``8.8''.
+
+@findex USAmode
+@item USAmode
+``Unsigned Single Accumulator'' mode represents a four-byte unsigned
+accumulator.  The default format is ``16.16''.
+
+@findex UDAmode
+@item UDAmode
+``Unsigned Double Accumulator'' mode represents an eight-byte unsigned
+accumulator.  The default format is ``32.32''.
+
+@findex UTAmode
+@item UTAmode
+``Unsigned Tetra Accumulator'' mode represents a sixteen-byte unsigned
+accumulator.  The default format is ``64.64''.
+
 @findex CCmode
 @item CCmode
 ``Condition Code'' mode represents the value of a condition code, which
@@ -1226,6 +1316,26 @@ Floating point modes.  By default these are @code{QFmode},
 Decimal floating point modes.  By default these are @code{SDmode},
 @code{DDmode} and @code{TDmode}.
 
+@findex MODE_FRACT
+@item MODE_FRACT
+Signed fractional modes.  By default these are @code{QQmode}, @code{HQmode},
+@code{SQmode}, @code{DQmode} and @code{TQmode}.
+
+@findex MODE_UFRACT
+@item MODE_UFRACT
+Unsigned fractional modes.  By default these are @code{UQQmode}, @code{UHQmode},
+@code{USQmode}, @code{UDQmode} and @code{UTQmode}.
+
+@findex MODE_ACCUM
+@item MODE_ACCUM
+Signed accumulator modes.  By default these are @code{HAmode},
+@code{SAmode}, @code{DAmode} and @code{TAmode}.
+
+@findex MODE_UACCUM
+@item MODE_UACCUM
+Unsigned accumulator modes.  By default these are @code{UHAmode},
+@code{USAmode}, @code{UDAmode} and @code{UTAmode}.
+
 @findex MODE_COMPLEX_INT
 @item MODE_COMPLEX_INT
 Complex integer modes.  (These are not currently implemented).
@@ -1293,6 +1403,14 @@ Returns the size in bytes of a datum of mode @var{m}.
 @item GET_MODE_BITSIZE (@var{m})
 Returns the size in bits of a datum of mode @var{m}.
 
+@findex GET_MODE_IBIT
+@item GET_MODE_IBIT (@var{m})
+Returns the number of integral bits of a datum of fixed-point mode @var{m}.
+
+@findex GET_MODE_FBIT
+@item GET_MODE_FBIT (@var{m})
+Returns the number of fractional bits of a datum of fixed-point mode @var{m}.
+
 @findex GET_MODE_MASK
 @item GET_MODE_MASK (@var{m})
 Returns a bitmask containing 1 for all bits in a word that fit within
index 8e71a12..0a2e6f3 100644 (file)
@@ -73,6 +73,8 @@ struct mode_data
   const char *file;            /* file and line of definition, */
   unsigned int line;           /* for error reporting */
   unsigned int counter;                /* Rank ordering of modes */
+  unsigned int ibit;           /* the number of integral bits */
+  unsigned int fbit;           /* the number of fractional bits */
 };
 
 static struct mode_data *modes[MAX_MODE_CLASS];
@@ -83,7 +85,7 @@ static const struct mode_data blank_mode = {
   0, "<unknown>", MAX_MODE_CLASS,
   -1U, -1U, -1U, -1U,
   0, 0, 0, 0, 0, 0,
-  "<unknown>", 0, 0
+  "<unknown>", 0, 0, 0, 0
 };
 
 static htab_t modes_by_name;
@@ -104,6 +106,8 @@ struct mode_adjust
 static struct mode_adjust *adj_bytesize;
 static struct mode_adjust *adj_alignment;
 static struct mode_adjust *adj_format;
+static struct mode_adjust *adj_ibit;
+static struct mode_adjust *adj_fbit;
 
 /* Mode class operations.  */
 static enum mode_class
@@ -126,6 +130,10 @@ vector_class (enum mode_class cl)
     {
     case MODE_INT: return MODE_VECTOR_INT;
     case MODE_FLOAT: return MODE_VECTOR_FLOAT;
+    case MODE_FRACT: return MODE_VECTOR_FRACT;
+    case MODE_UFRACT: return MODE_VECTOR_UFRACT;
+    case MODE_ACCUM: return MODE_VECTOR_ACCUM;
+    case MODE_UACCUM: return MODE_VECTOR_UACCUM;
     default:
       error ("no vector class for class %s", mode_class_names[cl]);
       return MODE_RANDOM;
@@ -200,7 +208,8 @@ static void ATTRIBUTE_UNUSED
 new_adjust (const char *name,
            struct mode_adjust **category, const char *catname,
            const char *adjustment,
-           enum mode_class required_class,
+           enum mode_class required_class_from,
+           enum mode_class required_class_to,
            const char *file, unsigned int line)
 {
   struct mode_data *mode = find_mode (name);
@@ -214,10 +223,12 @@ new_adjust (const char *name,
       return;
     }
 
-  if (required_class != MODE_RANDOM && mode->cl != required_class)
+  if (required_class_from != MODE_RANDOM
+      && (mode->cl < required_class_from || mode->cl > required_class_to))
     {
-      error ("%s:%d: mode \"%s\" is not class %s",
-            file, line, name, mode_class_names[required_class] + 5);
+      error ("%s:%d: mode \"%s\" is not among class {%s, %s}",
+            file, line, name, mode_class_names[required_class_from] + 5,
+            mode_class_names[required_class_to] + 5);
       return;
     }
   
@@ -327,11 +338,16 @@ complete_mode (struct mode_data *m)
     case MODE_INT:
     case MODE_FLOAT:
     case MODE_DECIMAL_FLOAT:
+    case MODE_FRACT:
+    case MODE_UFRACT:
+    case MODE_ACCUM:
+    case MODE_UACCUM:
       /* A scalar mode must have a byte size, may have a bit size,
         and must not have components.   A float mode must have a
          format.  */
       validate_mode (m, OPTIONAL, SET, UNSET, UNSET,
-                    m->cl != MODE_INT ? SET : UNSET);
+                    (m->cl == MODE_FLOAT || m->cl == MODE_DECIMAL_FLOAT)
+                    ? SET : UNSET);
 
       m->ncomponents = 1;
       m->component = 0;
@@ -361,6 +377,10 @@ complete_mode (struct mode_data *m)
 
     case MODE_VECTOR_INT:
     case MODE_VECTOR_FLOAT:
+    case MODE_VECTOR_FRACT:
+    case MODE_VECTOR_UFRACT:
+    case MODE_VECTOR_ACCUM:
+    case MODE_VECTOR_UACCUM:
       /* Vector modes should have a component and a number of components.  */
       validate_mode (m, UNSET, UNSET, SET, SET, UNSET);
       if (m->component->precision != (unsigned int)-1)
@@ -533,6 +553,35 @@ make_int_mode (const char *name,
   m->precision = precision;
 }
 
+#define FRACT_MODE(N, Y, F) \
+       make_fixed_point_mode (MODE_FRACT, #N, Y, 0, F, __FILE__, __LINE__)
+
+#define UFRACT_MODE(N, Y, F) \
+       make_fixed_point_mode (MODE_UFRACT, #N, Y, 0, F, __FILE__, __LINE__)
+
+#define ACCUM_MODE(N, Y, I, F) \
+       make_fixed_point_mode (MODE_ACCUM, #N, Y, I, F, __FILE__, __LINE__)
+
+#define UACCUM_MODE(N, Y, I, F) \
+       make_fixed_point_mode (MODE_UACCUM, #N, Y, I, F, __FILE__, __LINE__)
+
+/* Create a fixed-point mode by setting CL, NAME, BYTESIZE, IBIT, FBIT,
+   FILE, and LINE.  */
+
+static void
+make_fixed_point_mode (enum mode_class cl,
+                      const char *name,
+                      unsigned int bytesize,
+                      unsigned int ibit,
+                      unsigned int fbit,
+                      const char *file, unsigned int line)
+{
+  struct mode_data *m = new_mode (cl, name, file, line);
+  m->bytesize = bytesize;
+  m->ibit = ibit;
+  m->fbit = fbit;
+}
+
 #define FLOAT_MODE(N, Y, F)             FRACTIONAL_FLOAT_MODE (N, -1U, Y, F)
 #define FRACTIONAL_FLOAT_MODE(N, B, Y, F) \
   make_float_mode (#N, B, Y, #F, __FILE__, __LINE__)
@@ -658,12 +707,14 @@ make_vector_mode (enum mode_class bclass,
 }
 
 /* Adjustability.  */
-#define _ADD_ADJUST(A, M, X, C) \
-  new_adjust (#M, &adj_##A, #A, #X, MODE_##C, __FILE__, __LINE__)
+#define _ADD_ADJUST(A, M, X, C1, C2) \
+  new_adjust (#M, &adj_##A, #A, #X, MODE_##C1, MODE_##C2, __FILE__, __LINE__)
 
-#define ADJUST_BYTESIZE(M, X)  _ADD_ADJUST(bytesize, M, X, RANDOM)
-#define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST(alignment, M, X, RANDOM)
-#define ADJUST_FLOAT_FORMAT(M, X)    _ADD_ADJUST(format, M, X, FLOAT)
+#define ADJUST_BYTESIZE(M, X)  _ADD_ADJUST(bytesize, M, X, RANDOM, RANDOM)
+#define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST(alignment, M, X, RANDOM, RANDOM)
+#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)
 
 static void
 create_modes (void)
@@ -861,6 +912,8 @@ enum machine_mode\n{");
 #if 0 /* disabled for backward compatibility, temporary */
   printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" const");
 #endif
+  printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
+  printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
   puts ("\
 \n\
 #endif /* insn-modes.h */");
@@ -1173,6 +1226,10 @@ emit_mode_adjustments (void)
 
            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_size[%smode] = %d*s;\n",
                      m->name, m->ncomponents);
              printf ("  mode_base_align[%smode] = (%d*s) & (~(%d*s)+1);\n",
@@ -1207,6 +1264,10 @@ emit_mode_adjustments (void)
 
            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_base_align[%smode] = %d*s;\n",
                      m->name, m->ncomponents);
              break;
@@ -1219,6 +1280,22 @@ emit_mode_adjustments (void)
            }
        }
     }
+
+  /* Ibit adjustments don't have to propagate.  */
+  for (a = adj_ibit; a; a = a->next)
+    {
+      printf ("\n  /* %s:%d */\n  s = %s;\n",
+             a->file, a->line, a->adjustment);
+      printf ("  mode_ibit[%smode] = s;\n", a->mode->name);
+    }
+
+  /* Fbit adjustments don't have to propagate.  */
+  for (a = adj_fbit; a; a = a->next)
+    {
+      printf ("\n  /* %s:%d */\n  s = %s;\n",
+             a->file, a->line, a->adjustment);
+      printf ("  mode_fbit[%smode] = s;\n", a->mode->name);
+    }
       
   /* Real mode formats don't have to propagate anywhere.  */
   for (a = adj_format; a; a = a->next)
@@ -1228,6 +1305,43 @@ emit_mode_adjustments (void)
   puts ("}");
 }
 
+/* Emit ibit for all modes.  */
+
+static void
+emit_mode_ibit (void)
+{
+  int c;
+  struct mode_data *m;
+
+  print_maybe_const_decl ("%sunsigned char",
+                         "mode_ibit", "NUM_MACHINE_MODES",
+                         ibit);
+
+  for_all_modes (c, m)
+    tagged_printf ("%u", m->ibit, m->name);
+
+  print_closer ();
+}
+
+/* Emit fbit for all modes.  */
+
+static void
+emit_mode_fbit (void)
+{
+  int c;
+  struct mode_data *m;
+
+  print_maybe_const_decl ("%sunsigned char",
+                         "mode_fbit", "NUM_MACHINE_MODES",
+                         fbit);
+
+  for_all_modes (c, m)
+    tagged_printf ("%u", m->fbit, m->name);
+
+  print_closer ();
+}
+
+
 static void
 emit_insn_modes_c (void)
 {
@@ -1244,6 +1358,8 @@ emit_insn_modes_c (void)
   emit_class_narrowest_mode ();
   emit_real_format_for_mode ();
   emit_mode_adjustments ();
+  emit_mode_ibit ();
+  emit_mode_fbit ();
 }
 
 static void
index ffb675d..51d6980 100644 (file)
@@ -96,6 +96,24 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
        storage, but with only PRECISION significant bits, using
        floating point format FORMAT.
 
+     FRACT_MODE (MODE, BYTESIZE, FBIT);
+       declares MODE to be of class FRACT and BYTESIZE bytes wide
+       with FBIT fractional bits.  There may be padding bits.
+
+     UFRACT_MODE (MODE, BYTESIZE, FBIT);
+       declares MODE to be of class UFRACT and BYTESIZE bytes wide
+       with FBIT fractional bits.  There may be padding bits.
+
+     ACCUM_MODE (MODE, BYTESIZE, IBIT, FBIT);
+       declares MODE to be of class ACCUM and BYTESIZE bytes wide
+       with IBIT integral bits and FBIT fractional bits.
+       There may be padding bits.
+
+     UACCUM_MODE (MODE, BYTESIZE, FBIT);
+       declares MODE to be of class UACCUM and BYTESIZE bytes wide
+       with IBIT integral bits and FBIT fractional bits.
+       There may be padding bits.
+
      RESET_FLOAT_FORMAT (MODE, FORMAT);
        changes the format of MODE, which must be class FLOAT,
        to FORMAT.  Use in an ARCH-modes.def to reset the format
@@ -133,10 +151,12 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
      ADJUST_BYTESIZE (MODE, EXPR);
      ADJUST_ALIGNMENT (MODE, EXPR);
      ADJUST_FLOAT_FORMAT (MODE, EXPR);
-        Arrange for the byte size, alignment, or floating point format
-       of MODE to be adjustable at run time.  EXPR will be executed
+     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
-       evaluate to the desired byte size, alignment, or format.
+       evaluate to the desired byte size, alignment, format, ibit or fbit.
 
        Unlike a FORMAT argument, if you are adjusting a float format
        you must put an & in front of the name of each format structure.
@@ -181,6 +201,29 @@ FLOAT_MODE (DF, 8, ieee_double_format);
    FIXME define this only for targets that need it.  */
 CC_MODE (CC);
 
+/* Fixed-point modes.  */
+FRACT_MODE (QQ, 1, 7); /* s.7 */
+FRACT_MODE (HQ, 2, 15); /* s.15 */
+FRACT_MODE (SQ, 4, 31); /* s.31 */
+FRACT_MODE (DQ, 8, 63); /* s.63 */
+FRACT_MODE (TQ, 16, 127); /* s.127 */
+
+UFRACT_MODE (UQQ, 1, 8); /* .8 */
+UFRACT_MODE (UHQ, 2, 16); /* .16 */
+UFRACT_MODE (USQ, 4, 32); /* .32 */
+UFRACT_MODE (UDQ, 8, 64); /* .64 */
+UFRACT_MODE (UTQ, 16, 128); /* .128 */
+
+ACCUM_MODE (HA, 2, 8, 7); /* s8.7 */
+ACCUM_MODE (SA, 4, 16, 15); /* s16.15 */
+ACCUM_MODE (DA, 8, 32, 31); /* s32.31 */
+ACCUM_MODE (TA, 16, 64, 63); /* s64.63 */
+
+UACCUM_MODE (UHA, 2, 8, 8); /* 8.8 */
+UACCUM_MODE (USA, 4, 16, 16); /* 16.16 */
+UACCUM_MODE (UDA, 8, 32, 32); /* 32.32 */
+UACCUM_MODE (UTA, 16, 64, 64); /* 64.64 */
+
 /* Allow the target to specify additional modes of various kinds.  */
 #if HAVE_EXTRA_MODES
 # include EXTRA_MODES_FILE
index 3948fc9..68a2071 100644 (file)
@@ -66,7 +66,11 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
 /* Nonzero if MODE is a vector mode.  */
 #define VECTOR_MODE_P(MODE)                    \
   (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT    \
-   || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT)
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_FLOAT       \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT       \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT      \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM       \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
 
 /* Nonzero if MODE is a scalar integral mode.  */
 #define SCALAR_INT_MODE_P(MODE)                        \
@@ -82,12 +86,94 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
 #define DECIMAL_FLOAT_MODE_P(MODE)             \
   (GET_MODE_CLASS (MODE) == MODE_DECIMAL_FLOAT)
 
+/* Nonzero if MODE is a scalar fract mode.  */
+#define SCALAR_FRACT_MODE_P(MODE)      \
+  (GET_MODE_CLASS (MODE) == MODE_FRACT)
+
+/* Nonzero if MODE is a scalar ufract mode.  */
+#define SCALAR_UFRACT_MODE_P(MODE)     \
+  (GET_MODE_CLASS (MODE) == MODE_UFRACT)
+
+/* Nonzero if MODE is a scalar fract or ufract mode.  */
+#define ALL_SCALAR_FRACT_MODE_P(MODE)  \
+  (SCALAR_FRACT_MODE_P (MODE) || SCALAR_UFRACT_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar accum mode.  */
+#define SCALAR_ACCUM_MODE_P(MODE)      \
+  (GET_MODE_CLASS (MODE) == MODE_ACCUM)
+
+/* Nonzero if MODE is a scalar uaccum mode.  */
+#define SCALAR_UACCUM_MODE_P(MODE)     \
+  (GET_MODE_CLASS (MODE) == MODE_UACCUM)
+
+/* Nonzero if MODE is a scalar accum or uaccum mode.  */
+#define ALL_SCALAR_ACCUM_MODE_P(MODE)  \
+  (SCALAR_ACCUM_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar fract or accum mode.  */
+#define SIGNED_SCALAR_FIXED_POINT_MODE_P(MODE) \
+  (SCALAR_FRACT_MODE_P (MODE) || SCALAR_ACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar ufract or uaccum mode.  */
+#define UNSIGNED_SCALAR_FIXED_POINT_MODE_P(MODE)       \
+  (SCALAR_UFRACT_MODE_P (MODE) || SCALAR_UACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar fract, ufract, accum or uaccum mode.  */
+#define ALL_SCALAR_FIXED_POINT_MODE_P(MODE)    \
+  (SIGNED_SCALAR_FIXED_POINT_MODE_P (MODE)     \
+   || UNSIGNED_SCALAR_FIXED_POINT_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar/vector fract mode.  */
+#define FRACT_MODE_P(MODE)             \
+  (GET_MODE_CLASS (MODE) == MODE_FRACT \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_FRACT)
+
+/* Nonzero if MODE is a scalar/vector ufract mode.  */
+#define UFRACT_MODE_P(MODE)            \
+  (GET_MODE_CLASS (MODE) == MODE_UFRACT        \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_UFRACT)
+
+/* Nonzero if MODE is a scalar/vector fract or ufract mode.  */
+#define ALL_FRACT_MODE_P(MODE)         \
+  (FRACT_MODE_P (MODE) || UFRACT_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar/vector accum mode.  */
+#define ACCUM_MODE_P(MODE)             \
+  (GET_MODE_CLASS (MODE) == MODE_ACCUM \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_ACCUM)
+
+/* Nonzero if MODE is a scalar/vector uaccum mode.  */
+#define UACCUM_MODE_P(MODE)            \
+  (GET_MODE_CLASS (MODE) == MODE_UACCUM        \
+   || GET_MODE_CLASS (MODE) == MODE_VECTOR_UACCUM)
+
+/* Nonzero if MODE is a scalar/vector accum or uaccum mode.  */
+#define ALL_ACCUM_MODE_P(MODE)         \
+  (ACCUM_MODE_P (MODE) || UACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar/vector fract or accum mode.  */
+#define SIGNED_FIXED_POINT_MODE_P(MODE)                \
+  (FRACT_MODE_P (MODE) || ACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar/vector ufract or uaccum mode.  */
+#define UNSIGNED_FIXED_POINT_MODE_P(MODE)      \
+  (UFRACT_MODE_P (MODE) || UACCUM_MODE_P (MODE))
+
+/* Nonzero if MODE is a scalar/vector fract, ufract, accum or uaccum mode.  */
+#define ALL_FIXED_POINT_MODE_P(MODE)           \
+  (SIGNED_FIXED_POINT_MODE_P (MODE)            \
+   || UNSIGNED_FIXED_POINT_MODE_P (MODE))
+
 /* Nonzero if CLASS modes can be widened.  */
 #define CLASS_HAS_WIDER_MODES_P(CLASS)         \
   (CLASS == MODE_INT                           \
    || CLASS == MODE_FLOAT                      \
    || CLASS == MODE_DECIMAL_FLOAT              \
-   || CLASS == MODE_COMPLEX_FLOAT)
+   || CLASS == MODE_COMPLEX_FLOAT              \
+   || CLASS == MODE_FRACT                      \
+   || CLASS == MODE_UFRACT                     \
+   || CLASS == MODE_ACCUM                      \
+   || CLASS == MODE_UACCUM)
 
 /* Get the size in bytes and bits of an object of mode MODE.  */
 
@@ -99,6 +185,14 @@ extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
 extern const unsigned short mode_precision[NUM_MACHINE_MODES];
 #define GET_MODE_PRECISION(MODE)  mode_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];
+#define GET_MODE_IBIT(MODE) mode_ibit[MODE]
+
+/* Get the number of fractional bits of an object of mode MODE.  */
+extern CONST_MODE_FBIT unsigned char mode_fbit[NUM_MACHINE_MODES];
+#define GET_MODE_FBIT(MODE) mode_fbit[MODE]
+
 /* Get a bitmask containing 1 for all bits in a word
    that fit within mode MODE.  */
 
index 7fc7a9b..2f56efa 100644 (file)
@@ -23,10 +23,18 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
   DEF_MODE_CLASS (MODE_RANDOM),                /* other */                        \
   DEF_MODE_CLASS (MODE_CC),            /* condition code in a register */ \
   DEF_MODE_CLASS (MODE_INT),           /* integer */                      \
-  DEF_MODE_CLASS (MODE_PARTIAL_INT),   /* integer with padding bits */    \
+  DEF_MODE_CLASS (MODE_PARTIAL_INT),   /* integer with padding bits */    \
+  DEF_MODE_CLASS (MODE_FRACT),         /* signed fractional number */     \
+  DEF_MODE_CLASS (MODE_UFRACT),                /* unsigned fractional number */   \
+  DEF_MODE_CLASS (MODE_ACCUM),         /* signed accumulator */           \
+  DEF_MODE_CLASS (MODE_UACCUM),                /* unsigned accumulator */         \
   DEF_MODE_CLASS (MODE_FLOAT),         /* floating point */               \
   DEF_MODE_CLASS (MODE_DECIMAL_FLOAT), /* decimal floating point */       \
   DEF_MODE_CLASS (MODE_COMPLEX_INT),   /* complex numbers */              \
   DEF_MODE_CLASS (MODE_COMPLEX_FLOAT),                                    \
   DEF_MODE_CLASS (MODE_VECTOR_INT),    /* SIMD vectors */                 \
+  DEF_MODE_CLASS (MODE_VECTOR_FRACT),  /* SIMD vectors */                 \
+  DEF_MODE_CLASS (MODE_VECTOR_UFRACT), /* SIMD vectors */                 \
+  DEF_MODE_CLASS (MODE_VECTOR_ACCUM),  /* SIMD vectors */                 \
+  DEF_MODE_CLASS (MODE_VECTOR_UACCUM), /* SIMD vectors */                 \
   DEF_MODE_CLASS (MODE_VECTOR_FLOAT)