shithub: scc

Download patch

ref: d861d0e37084374769dd70f61f1f6c1185bedacb
parent: e389dc2387eb8f243a3361263f5ac1d85e95b7ec
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Sep 9 03:12:14 EDT 2017

[as] Autogenerate list of formats

We already have that information, so it is better to take it from
the dat files.

--- a/as/Makefile
+++ b/as/Makefile
@@ -10,7 +10,6 @@
 all:
 
 $(OBJ): $(HDR)
-ins.o: ins.h
 
 as: $(OBJ)
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
--- a/as/ins.c
+++ b/as/ins.c
@@ -1,7 +1,6 @@
 
 #include "../inc/scc.h"
 #include "as.h"
-#include "ins.h"
 
 void
 direct(Op *op, Arg *args)
--- a/as/ins.h
+++ /dev/null
@@ -1,2 +1,0 @@
-
-Format direct, defb, defw, defd, defq;
--- a/as/target/x86/gen.awk
+++ b/as/target/x86/gen.awk
@@ -3,7 +3,6 @@
 	FS = "\t"
 	printf "#include \"../../../inc/scc.h\"\n"\
 	       "#include \"../../as.h\"\n"\
-	       "#include \"../../ins.h\"\n"\
 	       "#include \"../x86/args.h\"\n"\
 	       "#include \"ins.h\"\n\n"
 	nop = 0; nvar = 0
@@ -20,8 +19,12 @@
 	opsize[nvar] = $3
 	opbytes[nvar] = ($4 == "none") ? "" : $4
 	opformat[nvar++] = $5
+	formats[$5] = 1
 }
 END	{
+	for (i in formats)
+		printf "Format %s;\n", i
+
 	printf "int nr_ins = %d;\n\n", nop
 	print "struct ins instab[] = {"
 	for (i = 0; i < nop; i++) {