summaryrefslogtreecommitdiff
path: root/opcodes
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2018-07-19 08:28:29 +0200
committerJan Beulich <jbeulich@suse.com>2018-07-19 08:28:29 +0200
commitc30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab (patch)
tree6f5a4a23c2d56878e002fe9b566dc9dc81f06503 /opcodes
parente387da76fc6ee61f6bc30edfa1210be173e96db4 (diff)
downloadbinutils-gdb-c30be56ebf7989e36f5c7d4a703cb00f7d4ca2ab.tar.gz
x86: pre-process opcodes table before parsing
Instead of expanding macro-like constructs in i386-gen, have the C pre- processor do this for us. Besides being a prerequisite for the next template folding steps, this also paves the way for removing various hidden dependencies between #define-s in i386-opc.h and plain literal numbers used in i386-opc.tbl. The #undef of None is solely to leave the generated i386-tbl.h entirely unchanged.
Diffstat (limited to 'opcodes')
-rw-r--r--opcodes/ChangeLog12
-rw-r--r--opcodes/Makefile.am6
-rw-r--r--opcodes/Makefile.in6
-rw-r--r--opcodes/i386-gen.c29
-rw-r--r--opcodes/i386-opc.tbl6
5 files changed, 49 insertions, 10 deletions
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index ee3afb5dc44..10c0771af69 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,15 @@
+2018-07-19 Jan Beulich <jbeulich@suse.com>
+
+ * Makefile.am: Change dependencies and rule for
+ $(srcdir)/i386-init.h.
+ * Makefile.in: Re-generate.
+ * i386-gen.c (process_i386_opcodes): New local variable
+ "marker". Drop opening of input file. Recognize marker and line
+ number directives.
+ * i386-opc.tbl (OPCODE_I386_H): Define.
+ (i386-opc.h): Include it.
+ (None): Undefine.
+
2018-07-18 H.J. Lu <hongjiu.lu@intel.com>
PR gas/23418
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index 11d3f76ac30..a571f2b158a 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -544,8 +544,10 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcdir)/../include/opcode/i386.h \
$(srcdir)/i386-tbl.h: $(srcdir)/i386-init.h
@echo $@
-$(srcdir)/i386-init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl
- ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
+$(srcdir)/i386-init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \
+ < $(srcdir)/i386-opc.tbl \
+ | ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
i386-opc.lo: $(srcdir)/i386-tbl.h
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 1ddd0a6c081..31f7bf5c625 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -1514,8 +1514,10 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcdir)/../include/opcode/i386.h \
$(srcdir)/i386-tbl.h: $(srcdir)/i386-init.h
@echo $@
-$(srcdir)/i386-init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl
- ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
+$(srcdir)/i386-init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h
+ $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \
+ < $(srcdir)/i386-opc.tbl \
+ | ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir)
i386-opc.lo: $(srcdir)/i386-tbl.h
diff --git a/opcodes/i386-gen.c b/opcodes/i386-gen.c
index 9b5314cfbc7..860d318087b 100644
--- a/opcodes/i386-gen.c
+++ b/opcodes/i386-gen.c
@@ -1262,14 +1262,10 @@ process_i386_opcodes (FILE *table)
htab_t opcode_hash_table;
struct opcode_hash_entry **opcode_array;
unsigned int opcode_array_size = 1024;
- int lineno = 0;
+ int lineno = 0, marker = 0;
filename = "i386-opc.tbl";
- fp = fopen (filename, "r");
-
- if (fp == NULL)
- fail (_("can't find i386-opc.tbl for reading, errno = %s\n"),
- xstrerror (errno));
+ fp = stdin;
i = 0;
opcode_array = (struct opcode_hash_entry **)
@@ -1303,11 +1299,32 @@ process_i386_opcodes (FILE *table)
switch (p[0])
{
case '#':
+ if (!strcmp("### MARKER ###", buf))
+ marker = 1;
+ else
+ {
+ /* Since we ignore all included files (we only care about their
+ #define-s here), we don't need to monitor filenames. The final
+ line number directive is going to refer to the main source file
+ again. */
+ char *end;
+ unsigned long ln;
+
+ p = remove_leading_whitespaces (p + 1);
+ if (!strncmp(p, "line", 4))
+ p += 4;
+ ln = strtoul (p, &end, 10);
+ if (ln > 1 && ln < INT_MAX
+ && *remove_leading_whitespaces (end) == '"')
+ lineno = ln - 1;
+ }
/* Ignore comments. */
case '\0':
continue;
break;
default:
+ if (!marker)
+ continue;
break;
}
diff --git a/opcodes/i386-opc.tbl b/opcodes/i386-opc.tbl
index a7fb06b5961..eb1bdf0f611 100644
--- a/opcodes/i386-opc.tbl
+++ b/opcodes/i386-opc.tbl
@@ -18,6 +18,12 @@
// Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
// 02110-1301, USA.
+#define OPCODE_I386_H
+#include "i386-opc.h"
+#undef None
+
+### MARKER ###
+
// Move instructions.
// We put the 64bit displacement first and we only mark constants
// larger than 32bit as Disp64.