scc

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

commit 1735d0307f5ae6d8d7c766439aca3e6145b4df42
parent 215dacdfe68ec6d875de8cf3045cddcfa53ad17d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Mon,  9 Dec 2024 09:36:49 +0100

cc2: Define ASLABEL globally

The generic code was using a hardcoded 0 assuming that all the
architectures were going to define ASLABEL like 0, that was
very fragile and prone to error.

Diffstat:
Msrc/cmd/scc-cc/cc2/cc2.h | 2++
Msrc/cmd/scc-cc/cc2/code.c | 2+-
Msrc/cmd/scc-cc/cc2/qbe/arch.h | 3+--
Msrc/cmd/scc-cc/cc2/qbe/cgen.c | 2+-
Msrc/cmd/scc-cc/cc2/qbe/code.c | 2+-
Msrc/cmd/scc-cc/cc2/z80-scc/arch.h | 2+-
Msrc/cmd/scc-cc/cc2/z80-scc/cgen.c | 2+-
Msrc/cmd/scc-cc/cc2/z80-scc/code.c | 2+-
8 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/cmd/scc-cc/cc2/cc2.h b/src/cmd/scc-cc/cc2/cc2.h @@ -1,3 +1,5 @@ +#define ASLABEL 0 + enum iflags { BBENTRY = 1, /* basic block entry */ }; diff --git a/src/cmd/scc-cc/cc2/code.c b/src/cmd/scc-cc/cc2/code.c @@ -171,7 +171,7 @@ setlabel(Symbol *sym) { if (!sym) return; - code(0, NULL, NULL, NULL); + code(ASLABEL, NULL, NULL, NULL); pc->label = sym; sym->u.inst = pc; } diff --git a/src/cmd/scc-cc/cc2/qbe/arch.h b/src/cmd/scc-cc/cc2/qbe/arch.h @@ -1,6 +1,5 @@ enum asmop { - ASLABEL = 0, - ASSTB, + ASSTB = ASLABEL + 1, ASSTH, ASSTW, ASSTL, diff --git a/src/cmd/scc-cc/cc2/qbe/cgen.c b/src/cmd/scc-cc/cc2/qbe/cgen.c @@ -4,8 +4,8 @@ #include <scc/cstd.h> #include <scc/scc.h> -#include "arch.h" #include "../cc2.h" +#include "arch.h" #define I1BYTES 0 #define I2BYTES 1 diff --git a/src/cmd/scc-cc/cc2/qbe/code.c b/src/cmd/scc-cc/cc2/qbe/code.c @@ -5,8 +5,8 @@ #include <scc/cstd.h> #include <scc/scc.h> -#include "arch.h" #include "../cc2.h" +#include "arch.h" #define ADDR_LEN (INTIDENTSIZ+64) diff --git a/src/cmd/scc-cc/cc2/z80-scc/arch.h b/src/cmd/scc-cc/cc2/z80-scc/arch.h @@ -1,5 +1,5 @@ enum asmop { - ASJMP = 0, + ASJMP = ASLABEL + 1, ASRET, ASBRANCH, }; diff --git a/src/cmd/scc-cc/cc2/z80-scc/cgen.c b/src/cmd/scc-cc/cc2/z80-scc/cgen.c @@ -2,8 +2,8 @@ #include <scc/scc.h> -#include "arch.h" #include "../cc2.h" +#include "arch.h" static void swtch(Node *idx) diff --git a/src/cmd/scc-cc/cc2/z80-scc/code.c b/src/cmd/scc-cc/cc2/z80-scc/code.c @@ -4,8 +4,8 @@ #include <scc/cstd.h> #include <scc/scc.h> -#include "arch.h" #include "../cc2.h" +#include "arch.h" enum segment { CODESEG,