scc

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

commit 9b258f5adb6f13f217a6e551ac05d30574ecb168
parent 8a8c59a63e23fd40382411d44b636bb00171718a
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 31 Dec 2024 15:02:49 +0100

cc2: Remove stub implementations

The amd64 and i386 implementations are only stubs,
and due to lack of time it is likely that they are
going to remain as stubs for long time, so it is
better to remove them and have less code to maintain.
It is likely that many of the code that it is in target
directories will be refactored to be common.

Diffstat:
Mscripts/proto.all | 2--
Msrc/cmd/scc-cc/cc2/Makefile | 16----------------
Msrc/cmd/scc-cc/cc2/amd64-sysv/Makefile | 3---
Dsrc/cmd/scc-cc/cc2/amd64-sysv/arch.h | 0
Dsrc/cmd/scc-cc/cc2/amd64-sysv/cgen.c | 13-------------
Dsrc/cmd/scc-cc/cc2/amd64-sysv/code.c | 204-------------------------------------------------------------------------------
Dsrc/cmd/scc-cc/cc2/amd64-sysv/peep.c | 7-------
Msrc/cmd/scc-cc/cc2/i386-sysv/Makefile | 3---
Dsrc/cmd/scc-cc/cc2/i386-sysv/arch.h | 0
Dsrc/cmd/scc-cc/cc2/i386-sysv/cgen.c | 14--------------
Dsrc/cmd/scc-cc/cc2/i386-sysv/code.c | 203-------------------------------------------------------------------------------
Dsrc/cmd/scc-cc/cc2/i386-sysv/peep.c | 8--------
12 files changed, 0 insertions(+), 473 deletions(-)

diff --git a/scripts/proto.all b/scripts/proto.all @@ -187,8 +187,6 @@ f 755 libexec/scc/as-ppc f 755 libexec/scc/as-ppc64 f 755 libexec/scc/as-z80 f 755 libexec/scc/cc1 -f 755 libexec/scc/cc2-amd64-sysv -f 755 libexec/scc/cc2-i386-sysv f 755 libexec/scc/cc2-qbe_amd64-sysv f 755 libexec/scc/cc2-qbe_arm64-sysv f 755 libexec/scc/cc2-z80-scc diff --git a/src/cmd/scc-cc/cc2/Makefile b/src/cmd/scc-cc/cc2/Makefile @@ -25,14 +25,6 @@ OBJS =\ cfg.o\ $(QBE_OBJS)\ -AMD64_SYSV_OBJS =\ - amd64-sysv/builtin.o\ - $(OBJS) \ - -I386_SYSV_OBJS =\ - i386-sysv/builtin.o\ - $(OBJS) - QBE_AMD64_SYSV_OBJS=\ qbe_amd64-sysv/builtin.o\ $(QBE_OBJS)\ @@ -46,8 +38,6 @@ Z80_SCC_OBJS =\ $(OBJS) \ TARGET =\ - cc2-amd64-sysv\ - cc2-i386-sysv\ cc2-qbe_amd64-sysv\ cc2-qbe_arm64-sysv\ cc2-z80-scc\ @@ -67,12 +57,6 @@ error.h: cc2.h trap 'rm -f $$$$.h' EXIT INT QUIT TERM HUP;\ awk -f generror.awk cc2.h > $$$$.h && mv $$$$.h $@ -cc2-amd64-sysv: $(LIBSCC) $(AMD64_SYSV_OBJS) - $(CC) $(PROJ_LDFLAGS) $(AMD64_SYSV_OBJS) $(PROJ_LDLIBS) -o $@ - -cc2-i386-sysv: $(LIBSCC) $(I386_SYSV_OBJS) - $(CC) $(PROJ_LDFLAGS) $(I386_SYSV_OBJS) $(PROJ_LDLIBS) -o $@ - cc2-qbe_amd64-sysv: $(LIBSCC) $(QBE_AMD64_SYSV_OBJS) $(CC) $(PROJ_LDFLAGS) $(QBE_AMD64_SYSV_OBJS) $(PROJ_LDLIBS) -o $@ diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/Makefile b/src/cmd/scc-cc/cc2/amd64-sysv/Makefile @@ -5,9 +5,6 @@ include $(PROJECTDIR)/scripts/rules.mk OBJS =\ - cgen.o \ - code.o \ - peep.o \ types.o \ all: builtin.o diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/arch.h b/src/cmd/scc-cc/cc2/amd64-sysv/arch.h diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/cgen.c b/src/cmd/scc-cc/cc2/amd64-sysv/cgen.c @@ -1,13 +0,0 @@ -#include "arch.h" -#include <scc/scc.h> -#include "../cc2.h" - -void -genasm(void) -{ -} - -Node * -tsethi(Node *np) -{ -} diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/code.c b/src/cmd/scc-cc/cc2/amd64-sysv/code.c @@ -1,204 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include <scc/cstd.h> -#include <scc/scc.h> - -#include "arch.h" -#include "../cc2.h" - -enum segment { - CODESEG, - DATASEG, - BSSSEG, - NOSEG -}; - -static int curseg = NOSEG; - -static void -segment(int seg) -{ - static char *txt[] = { - [CODESEG] = "\t.text\n", - [DATASEG] = "\t.data\n", - [BSSSEG] = "\t.bss\n", - }; - - if (seg == curseg) - return; - fputs(txt[seg], stdout); - curseg = seg; -} - -static char * -symname(Symbol *sym) -{ - static char name[INTIDENTSIZ+1]; - - if (sym->name) { - switch (sym->kind) { - case SEXTRN: - case SGLOB: - case SPRIV: - return sym->name; - } - } - - sprintf(name, ".L%d", sym->numid); - - return name; -} - -static void -emitconst(Node *np) -{ - switch (np->type.size) { - case 1: - printf("%d", (int) np->u.i & 0xFF); - break; - case 2: - printf("%d", (int) np->u.i & 0xFFFF); - break; - case 4: - printf("%ld", (long) np->u.i & 0xFFFFFFFF); - break; - case 8: - printf("%lld", (long long) np->u.i & 0xFFFFFFFF); - break; - default: - abort(); - } -} - -static void -emittree(Node *np) -{ - if (!np) - return; - - switch (np->op) { - case OSTRING: - pprint(np->u.s); - free(np->u.s); - np->u.s = NULL; - break; - case OCONST: - emitconst(np); - break; - case OADDR: - emittree(np->left); - break; - case OMEM: - fputs(symname(np->u.sym), stdout); - break; - default: - emittree(np->left); - printf(" %c ", np->op); - emittree(np->right); - break; - } -} -static void -size2asm(Type *tp) -{ - char *s; - - if (tp->flags & STRF) { - s = "\t.ascii\t"; - } else { - switch (tp->size) { - case 1: - s = "\t.byte\t"; - break; - case 2: - s = "\t.short\t"; - break; - case 4: - s = "\t.long\t"; - break; - case 8: - s = "\t.quad\t"; - break; - default: - s = "\t.space\t%lu,"; - break; - } - } - printf(s, tp->size); -} - - -void -data(Node *np) -{ - size2asm(&np->type); - emittree(np); - putchar('\n'); -} - -static void -label(Symbol *sym) -{ - int seg; - char *name = symname(sym); - Type *tp = &sym->type; - - if (sym->type.flags & FUNF) - seg = CODESEG; - else if (sym->type.flags & INITF) - seg = DATASEG; - else - seg = BSSSEG; - segment(seg); - - switch (sym->kind) { - case SEXTRN: - printf("\t.extern\t%s\n", name); - case SLOCAL: - return; - case SGLOB: - printf("\t.global\t%s\n", name); - if (seg == BSSSEG) - printf("\t.comm\t%s,%lu\n", name, tp->size); - break; - } - if (sym->type.align != 1) - printf("\t.align\t%d\n", sym->type.align); - printf("%s:\n", name); -} - -void -defglobal(Symbol *sym) -{ - label(sym); - if (sym->kind == SEXTRN || (sym->type.flags & INITF)) - return; - size2asm(&sym->type); - puts("0"); -} - -void -deftype(Type *tp) -{ -} - -void -defvar(Symbol *sym) -{ -} - -void -defpar(Symbol *sym) -{ -} - -void -writeout(void) -{ -} - -void -endinit(void) -{ -} diff --git a/src/cmd/scc-cc/cc2/amd64-sysv/peep.c b/src/cmd/scc-cc/cc2/amd64-sysv/peep.c @@ -1,7 +0,0 @@ -#include <scc/scc.h> -#include "../cc2.h" - -void -peephole(void) -{ -} diff --git a/src/cmd/scc-cc/cc2/i386-sysv/Makefile b/src/cmd/scc-cc/cc2/i386-sysv/Makefile @@ -5,9 +5,6 @@ include $(PROJECTDIR)/scripts/rules.mk OBJS =\ - cgen.o \ - code.o \ - peep.o \ types.o \ all: builtin.o diff --git a/src/cmd/scc-cc/cc2/i386-sysv/arch.h b/src/cmd/scc-cc/cc2/i386-sysv/arch.h diff --git a/src/cmd/scc-cc/cc2/i386-sysv/cgen.c b/src/cmd/scc-cc/cc2/i386-sysv/cgen.c @@ -1,14 +0,0 @@ -#include <scc/scc.h> - -#include "arch.h" -#include "../cc2.h" - -void -genasm(void) -{ -} - -Node * -tsethi(Node *np) -{ -} diff --git a/src/cmd/scc-cc/cc2/i386-sysv/code.c b/src/cmd/scc-cc/cc2/i386-sysv/code.c @@ -1,203 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> - -#include <scc/cstd.h> -#include <scc/scc.h> - -#include "arch.h" -#include "../cc2.h" - -enum segment { - CODESEG, - DATASEG, - BSSSEG, - NOSEG -}; - -static int curseg = NOSEG; - -static void -segment(int seg) -{ - static char *txt[] = { - [CODESEG] = "\t.text\n", - [DATASEG] = "\t.data\n", - [BSSSEG] = "\t.bss\n", - }; - - if (seg == curseg) - return; - fputs(txt[seg], stdout); - curseg = seg; -} - -static char * -symname(Symbol *sym) -{ - static char name[INTIDENTSIZ+1]; - - if (sym->name) { - switch (sym->kind) { - case SEXTRN: - case SGLOB: - case SPRIV: - return sym->name; - } - } - - sprintf(name, ".L%d", sym->numid); - - return name; -} - -static void -emitconst(Node *np) -{ - switch (np->type.size) { - case 1: - printf("%d", (int) np->u.i & 0xFF); - break; - case 2: - printf("%d", (int) np->u.i & 0xFFFF); - break; - case 4: - printf("%ld", (long) np->u.i & 0xFFFFFFFF); - break; - case 8: - printf("%lld", (long long) np->u.i & 0xFFFFFFFF); - break; - default: - abort(); - } -} - -static void -emittree(Node *np) -{ - if (!np) - return; - - switch (np->op) { - case OSTRING: - pprint(np->u.s); - free(np->u.s); - np->u.s = NULL; - break; - case OCONST: - emitconst(np); - break; - case OADDR: - emittree(np->left); - break; - case OMEM: - fputs(symname(np->u.sym), stdout); - break; - default: - emittree(np->left); - printf(" %c ", np->op); - emittree(np->right); - break; - } -} -static void -size2asm(Type *tp) -{ - char *s; - - if (tp->flags & STRF) { - s = "\t.ascii\t"; - } else { - switch (tp->size) { - case 1: - s = "\t.byte\t"; - break; - case 2: - s = "\t.short\t"; - break; - case 4: - s = "\t.long\t"; - break; - case 8: - s = "\t.quad\t"; - break; - default: - s = "\t.space\t%lu,"; - break; - } - } - printf(s, tp->size); -} - -void -data(Node *np) -{ - size2asm(&np->type); - emittree(np); - putchar('\n'); -} - -static void -label(Symbol *sym) -{ - int seg; - char *name = symname(sym); - Type *tp = &sym->type; - - if (sym->type.flags & FUNF) - seg = CODESEG; - else if (sym->type.flags & INITF) - seg = DATASEG; - else - seg = BSSSEG; - segment(seg); - - switch (sym->kind) { - case SEXTRN: - printf("\t.extern\t%s\n", name); - case SLOCAL: - return; - case SGLOB: - printf("\t.global\t%s\n", name); - if (seg == BSSSEG) - printf("\t.comm\t%s,%lu\n", name, tp->size); - break; - } - if (sym->type.align != 1) - printf("\t.align\t%d\n", sym->type.align); - printf("%s:\n", name); -} - -void -defglobal(Symbol *sym) -{ - label(sym); - if (sym->kind == SEXTRN || (sym->type.flags & INITF)) - return; - size2asm(&sym->type); - puts("0"); -} - -void -deftype(Type *tp) -{ -} - -void -defpar(Symbol *sym) -{ -} - -void -defvar(Symbol *sym) -{ -} - -void -writeout(void) -{ -} - -void -endinit(void) -{ -} diff --git a/src/cmd/scc-cc/cc2/i386-sysv/peep.c b/src/cmd/scc-cc/cc2/i386-sysv/peep.c @@ -1,7 +0,0 @@ -#include <scc/scc.h> -#include "../cc2.h" - -void -peephole(void) -{ -} -\ No newline at end of file