Automatic date update in version.in
[deliverable/binutils-gdb.git] / opcodes / i386-gen.c
index 6e457a8cc9770bce1e5af4293288b0a2bebc2ce0..0c7ea10e2324461070f9bca0c025b3e1dabc12e2 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;
 
@@ -440,10 +444,8 @@ static initializer operand_type_init[] =
     "FloatReg" },
   { "OPERAND_TYPE_FLOATACC",
     "FloatAcc" },
-  { "OPERAND_TYPE_SREG2",
-    "SReg2" },
-  { "OPERAND_TYPE_SREG3",
-    "SReg3" },
+  { "OPERAND_TYPE_SREG",
+    "SReg" },
   { "OPERAND_TYPE_JUMPABSOLUTE",
     "JumpAbsolute" },
   { "OPERAND_TYPE_REGMMX",
@@ -639,6 +641,7 @@ static bitfield opcode_modifiers[] =
   BITFIELD (No_ldSuf),
   BITFIELD (FWait),
   BITFIELD (IsString),
+  BITFIELD (RegMem),
   BITFIELD (BNDPrefixOk),
   BITFIELD (NoTrackPrefixOk),
   BITFIELD (IsLockable),
@@ -702,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),
@@ -1668,9 +1669,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);
 
@@ -1679,8 +1684,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.023601 seconds and 4 git commands to generate.