x86: drop stray W
[deliverable/binutils-gdb.git] / opcodes / i386-gen.c
index 2f47de64b816c229bfc5e09b782c1d8c1c9d38c2..1c5082ea0dcededd03a07f4624629090f63e0f65 100644 (file)
 #include <libintl.h>
 #define _(String) gettext (String)
 
+/* Build-time checks are preferrable over runtime ones.  Use this construct
+   in preference where possible.  */
+#define static_assert(e) ((void)sizeof (struct { int _:1 - 2 * !(e); }))
+
 static const char *program_name = NULL;
 static int debug = 0;
 
@@ -297,6 +301,8 @@ static initializer cpu_flag_init[] =
     "CpuMOVDIR64B" },
   { "CPU_ENQCMD_FLAGS",
     "CpuENQCMD" },
+  { "CPU_AVX512_VP2INTERSECT_FLAGS",
+    "CpuAVX512_VP2INTERSECT" },
   { "CPU_ANY_X87_FLAGS",
     "CPU_ANY_287_FLAGS|Cpu8087" },
   { "CPU_ANY_287_FLAGS",
@@ -328,7 +334,7 @@ static initializer cpu_flag_init[] =
   { "CPU_ANY_AVX2_FLAGS",
     "CPU_ANY_AVX512F_FLAGS|CpuAVX2" },
   { "CPU_ANY_AVX512F_FLAGS",
-    "CpuAVX512F|CpuAVX512CD|CpuAVX512ER|CpuAVX512PF|CpuAVX512DQ|CpuAVX512BW|CpuAVX512VL|CpuAVX512IFMA|CpuAVX512VBMI|CpuAVX512_4FMAPS|CpuAVX512_4VNNIW|CpuAVX512_VPOPCNTDQ|CpuAVX512_VBMI2|CpuAVX512_VNNI|CpuAVX512_BITALG|CpuAVX512_BF16" },
+    "CpuAVX512F|CpuAVX512CD|CpuAVX512ER|CpuAVX512PF|CpuAVX512DQ|CpuAVX512BW|CpuAVX512VL|CpuAVX512IFMA|CpuAVX512VBMI|CpuAVX512_4FMAPS|CpuAVX512_4VNNIW|CpuAVX512_VPOPCNTDQ|CpuAVX512_VBMI2|CpuAVX512_VNNI|CpuAVX512_BITALG|CpuAVX512_BF16|CpuAVX512_VP2INTERSECT" },
   { "CPU_ANY_AVX512CD_FLAGS",
     "CpuAVX512CD" },
   { "CPU_ANY_AVX512ER_FLAGS",
@@ -369,6 +375,8 @@ static initializer cpu_flag_init[] =
     "CpuMOVDIR64B" },
   { "CPU_ANY_ENQCMD_FLAGS",
     "CpuENQCMD" },
+  { "CPU_ANY_AVX512_VP2INTERSECT_FLAGS",
+    "CpuAVX512_VP2INTERSECT" },
 };
 
 static const initializer operand_type_shorthands[] =
@@ -431,17 +439,13 @@ static initializer operand_type_init[] =
   { "OPERAND_TYPE_TEST",
     "Test" },
   { "OPERAND_TYPE_DEBUG",
-    "FloatReg" },
+    "Debug" },
   { "OPERAND_TYPE_FLOATREG",
     "FloatReg" },
   { "OPERAND_TYPE_FLOATACC",
     "FloatAcc" },
-  { "OPERAND_TYPE_SREG2",
-    "SReg2" },
-  { "OPERAND_TYPE_SREG3",
-    "SReg3" },
-  { "OPERAND_TYPE_ACC",
-    "Acc" },
+  { "OPERAND_TYPE_SREG",
+    "SReg" },
   { "OPERAND_TYPE_JUMPABSOLUTE",
     "JumpAbsolute" },
   { "OPERAND_TYPE_REGMMX",
@@ -456,10 +460,14 @@ static initializer operand_type_init[] =
     "RegMask" },
   { "OPERAND_TYPE_ESSEG",
     "EsSeg" },
+  { "OPERAND_TYPE_ACC8",
+    "Acc|Byte" },
+  { "OPERAND_TYPE_ACC16",
+    "Acc|Word" },
   { "OPERAND_TYPE_ACC32",
-    "Reg32|Acc|Dword" },
+    "Acc|Dword" },
   { "OPERAND_TYPE_ACC64",
-    "Reg64|Acc|Qword" },
+    "Acc|Qword" },
   { "OPERAND_TYPE_DISP16_32",
     "Disp16|Disp32" },
   { "OPERAND_TYPE_ANYDISP",
@@ -480,8 +488,6 @@ static initializer operand_type_init[] =
     "Imm32|Imm32S|Imm64|Disp32" },
   { "OPERAND_TYPE_IMM32_32S_64_DISP32_64",
     "Imm32|Imm32S|Imm64|Disp32|Disp64" },
-  { "OPERAND_TYPE_VEC_IMM4",
-    "Vec_Imm4" },
   { "OPERAND_TYPE_REGBND",
     "RegBND" },
 };
@@ -587,6 +593,7 @@ static bitfield cpu_flags[] =
   BITFIELD (CpuAVX512_VNNI),
   BITFIELD (CpuAVX512_BITALG),
   BITFIELD (CpuAVX512_BF16),
+  BITFIELD (CpuAVX512_VP2INTERSECT),
   BITFIELD (CpuMWAITX),
   BITFIELD (CpuCLZERO),
   BITFIELD (CpuOSPKE),
@@ -634,6 +641,7 @@ static bitfield opcode_modifiers[] =
   BITFIELD (No_ldSuf),
   BITFIELD (FWait),
   BITFIELD (IsString),
+  BITFIELD (RegMem),
   BITFIELD (BNDPrefixOk),
   BITFIELD (NoTrackPrefixOk),
   BITFIELD (IsLockable),
@@ -697,12 +705,10 @@ static bitfield operand_types[] =
   BITFIELD (Control),
   BITFIELD (Debug),
   BITFIELD (Test),
-  BITFIELD (SReg2),
-  BITFIELD (SReg3),
+  BITFIELD (SReg),
   BITFIELD (Acc),
   BITFIELD (JumpAbsolute),
   BITFIELD (EsSeg),
-  BITFIELD (RegMem),
   BITFIELD (Byte),
   BITFIELD (Word),
   BITFIELD (Dword),
@@ -714,7 +720,6 @@ static bitfield operand_types[] =
   BITFIELD (Zmmword),
   BITFIELD (Unspecified),
   BITFIELD (Anysize),
-  BITFIELD (Vec_Imm4),
   BITFIELD (RegBND),
 #ifdef OTUnused
   BITFIELD (OTUnused),
@@ -1102,6 +1107,8 @@ process_i386_opcode_modifier (FILE *table, char *mod, char **opnd, int lineno)
 
   if (strcmp (mod, "0"))
     {
+      unsigned int have_w = 0, bwlq_suf = 0xf;
+
       last = mod + strlen (mod);
       for (next = mod; next && next < last; )
        {
@@ -1115,8 +1122,30 @@ process_i386_opcode_modifier (FILE *table, char *mod, char **opnd, int lineno)
                          lineno);
              if (strcasecmp(str, "IsString") == 0)
                active_isstring = 1;
+
+             if (strcasecmp(str, "W") == 0)
+               have_w = 1;
+
+             if (strcasecmp(str, "No_bSuf") == 0)
+               bwlq_suf &= ~1;
+             if (strcasecmp(str, "No_wSuf") == 0)
+               bwlq_suf &= ~2;
+             if (strcasecmp(str, "No_lSuf") == 0)
+               bwlq_suf &= ~4;
+             if (strcasecmp(str, "No_qSuf") == 0)
+               bwlq_suf &= ~8;
            }
        }
+
+      if (have_w && !bwlq_suf)
+       fail ("%s: %d: stray W modifier\n", filename, lineno);
+      if (have_w && !(bwlq_suf & 1))
+       fprintf (stderr, "%s: %d: W modifier without Byte operand(s)\n",
+                filename, lineno);
+      if (have_w && !(bwlq_suf & ~1))
+       fprintf (stderr,
+                "%s: %d: W modifier without Word/Dword/Qword operand(s)\n",
+                filename, lineno);
     }
   output_opcode_modifier (table, modifiers, ARRAY_SIZE (modifiers));
 }
@@ -1664,9 +1693,13 @@ main (int argc, char **argv)
 
   /* Check the unused bitfield in i386_cpu_flags.  */
 #ifdef CpuUnused
+  static_assert (ARRAY_SIZE (cpu_flags) == CpuMax + 2);
+
   if ((cpumax - 1) != CpuMax)
     fail (_("CpuMax != %d!\n"), cpumax);
 #else
+  static_assert (ARRAY_SIZE (cpu_flags) == CpuMax + 1);
+
   if (cpumax != CpuMax)
     fail (_("CpuMax != %d!\n"), cpumax);
 
@@ -1675,8 +1708,14 @@ main (int argc, char **argv)
     fail (_("%d unused bits in i386_cpu_flags.\n"), c);
 #endif
 
+  static_assert (ARRAY_SIZE (opcode_modifiers) == Opcode_Modifier_Num);
+
   /* Check the unused bitfield in i386_operand_type.  */
-#ifndef OTUnused
+#ifdef OTUnused
+  static_assert (ARRAY_SIZE (operand_types) == OTNum + 1);
+#else
+  static_assert (ARRAY_SIZE (operand_types) == OTNum);
+
   c = OTNumOfBits - OTMax - 1;
   if (c)
     fail (_("%d unused bits in i386_operand_type.\n"), c);
This page took 0.03718 seconds and 4 git commands to generate.