aboutsummaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2019-07-17 09:15:49 +0200
committerJan Beulich <jbeulich@suse.com>2019-07-17 09:15:49 +0200
commit1d942ae90810156b9875ea3e11754ab447c748db (patch)
treef8d77767f8a3400f8b0d5aa132f1bd93262764ee /opcodes
parentbd7918379d2688898dfb29851f2019d2a7a70959 (diff)
downloadfsf-binutils-gdb-1d942ae90810156b9875ea3e11754ab447c748db.zip
fsf-binutils-gdb-1d942ae90810156b9875ea3e11754ab447c748db.tar.gz
fsf-binutils-gdb-1d942ae90810156b9875ea3e11754ab447c748db.tar.bz2
x86: drop stale Mem enumerator
This was supposed to also be removed by c48dadc9a8 ('x86: drop "mem" operand type attribute'). It's odd enough that this hasn't caused build issues, considering the careful use of OTunused (apparently to avoid "missing initializer" warnings). To avoid such happening again introduce compile time consistency checks.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog8
-rw-r--r--opcodes/i386-gen.c16
-rw-r--r--opcodes/i386-opc.h4
3 files changed, 24 insertions, 4 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index c8af99f..254bc09 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,11 @@
+2019-07-17 Jan Beulich <jbeulich@suse.com>
+
+ * i386-gen.c (static_assert): Define.
+ (main): Use it.
+ * i386-opc.h (Opcode_Modifier_Max): Rename to ...
+ (Opcode_Modifier_Num): ... this.
+ (Mem): Delete.
+
2019-07-16 Jan Beulich <jbeulich@suse.com>
* i386-gen.c (operand_types): Move RegMem ...
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index f9201bb..0c7ea10 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -30,6 +30,10 @@
#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;
@@ -1665,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);
@@ -1676,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);
diff --git a/opcodes/i386-opc.h b/opcodes/i386-opc.h
index 4c38e9e..4246d0b 100644
--- a/opcodes/i386-opc.h
+++ b/opcodes/i386-opc.h
@@ -626,7 +626,7 @@ enum
/* Intel64. */
Intel64,
/* The last bitfield in i386_opcode_modifier. */
- Opcode_Modifier_Max
+ Opcode_Modifier_Num
};
typedef struct i386_opcode_modifier
@@ -757,8 +757,6 @@ enum
JumpAbsolute,
/* String insn operand with fixed es segment */
EsSeg,
- /* Memory. */
- Mem,
/* BYTE size. */
Byte,
/* WORD size. 2 byte */