scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 8103e1e7a587d39c421d71d1b9e834d275389270
parent 1d54f6ac08d20e3dc4f9756875346f2d2ee90747
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 19 Dec 2017 08:27:42 +0000

[as] Keep relative order of instruction with same verb

The order is important, because there are several ways to
implement an instruction, but not always they have the same
performance, so the table has to be built with an order
that ensure the correct seletion of instructions. The order
in sort of lines that are equal is unspecified, so we have
to add a workaround to ensure that the order is not
modified. This workaround basically insert a new field
that is the Number of record which can be used later
to enure the correct order.

Diffstat:
Mas/target/amd64/target.mk | 3++-
Mas/target/gen.awk | 15+++++++--------
Mas/target/i386/target.mk | 3++-
Mas/target/z80/target.mk | 3++-
4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/as/target/amd64/target.mk b/as/target/amd64/target.mk @@ -7,7 +7,8 @@ target/amd64/instbl.c: target/gen.awk target/x86/x86.dat target/x86/rules.dat set -e ;\ rm -f $@;\ trap "rm -f $$$$.c" 0 2 3; \ - sort -k1 target/x86/x86.dat | \ + awk '!/^$$/ {print $$1,NR,$$2,$$3,$$4,$$5,$$6}' target/x86/x86.dat | \ + sort -k1 -k2n | \ awk -v cpu=BITS64 -v family=x86 \ -f target/gen.awk > $$$$.c && mv $$$$.c $@ diff --git a/as/target/gen.awk b/as/target/gen.awk @@ -1,6 +1,5 @@ BEGIN { - FS = "\t" printf "#include \"../../../inc/scc.h\"\n"\ "#include \"../../as.h\"\n"\ "#include \"../" family "/proc.h\"\n" @@ -11,11 +10,11 @@ BEGIN { regex[++nregs] = $1 value[nregs] = $2 } - close "target/rules.awk" + close("target/rules.awk") } {sub(/#.*/,"")} -$6 !~ cpu {next} +$7 !~ cpu {next} /^$/ {next} @@ -25,11 +24,11 @@ $6 !~ cpu {next} opnames[nop++] = $1 } opcount[$1]++ - opargs[nvar] = $2 - opsize[nvar] = $3 - opbytes[nvar] = ($4 == "none") ? "" : $4 - opformat[nvar++] = $5 - formats[$5] = 1 + opargs[nvar] = $3 + opsize[nvar] = $4 + opbytes[nvar] = ($5 == "none") ? "" : $5 + opformat[nvar++] = $6 + formats[$6] = 1 } END { diff --git a/as/target/i386/target.mk b/as/target/i386/target.mk @@ -7,7 +7,8 @@ target/i386/instbl.c: target/gen.awk target/x86/x86.dat set -e ;\ rm -f $@;\ trap "rm -f $$$$.c" 0 2 3; \ - sort -k1 target/x86/x86.dat | \ + awk '!/^$$/ {print $$1,NR,$$2,$$3,$$4,$$5,$$6}' target/x86/x86.dat | \ + sort -k1 -k2n | \ awk -v cpu=BITS32 -v family=x86 \ -f target/gen.awk > $$$$.c && mv $$$$.c $@ diff --git a/as/target/z80/target.mk b/as/target/z80/target.mk @@ -7,7 +7,8 @@ target/z80/instbl.c: target/gen.awk target/x80/x80.dat target/x80/rules.dat set -e ;\ rm -f $@;\ trap "rm -f $$$$.c" 0 2 3; \ - sort -k1 target/x80/x80.dat | \ + awk '!/^$$/ {print $$1,NR,$$2,$$3,$$4,$$5,$$6}' target/x80/x80.dat | \ + sort -k1 -k2n | \ awk -v cpu=Z80 -v family=x80 \ -f target/gen.awk > $$$$.c && mv $$$$.c $@