#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;
"FloatReg" },
{ "OPERAND_TYPE_FLOATACC",
"FloatAcc" },
- { "OPERAND_TYPE_SREG2",
- "SReg2" },
- { "OPERAND_TYPE_SREG3",
- "SReg3" },
+ { "OPERAND_TYPE_SREG",
+ "SReg" },
{ "OPERAND_TYPE_JUMPABSOLUTE",
"JumpAbsolute" },
{ "OPERAND_TYPE_REGMMX",
BITFIELD (No_ldSuf),
BITFIELD (FWait),
BITFIELD (IsString),
+ BITFIELD (RegMem),
BITFIELD (BNDPrefixOk),
BITFIELD (NoTrackPrefixOk),
BITFIELD (IsLockable),
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),
if (strcmp (mod, "0"))
{
+ unsigned int have_w = 0, bwlq_suf = 0xf;
+
last = mod + strlen (mod);
for (next = mod; next && next < last; )
{
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));
}
/* 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);
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);