ref: 5d1501e35338badd9a2958f1c1c68ad52ea2b020
parent: 0d6910bbeed636179cca0f472e72b31d81bd834c
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Aug 14 05:51:52 EDT 2018
[cc1] Remove gendep.sh This generation of dependencies was too complex, and it doesn't make sense anymore. If you don't want all the targets you only has to modify the Makefiles.
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -1,8 +1,5 @@
.POSIX:
-# Makefile is only used as a template for makefile.
-# If you modify Makefile remember to run make dep
-
PROJECTDIR = ..
include $(PROJECTDIR)/rules.mk
@@ -13,16 +10,11 @@
OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \
code.o stmt.o cpp.o fold.o init.o builtin.o
-HDR = cc1.h \
- $(PROJECTDIR)/inc/scc.h \
- $(PROJECTDIR)/inc/$(STD)/cstd.h \
- $(PROJECTDIR)/inc/sysincludes.h
-
all:
cp cc1-* $(PROJECTDIR)/rootdir/libexec/scc/
dep:
- ./gendep.sh $(TARGETS)
+ $(PROJECTDIR)/mkdep.sh
clean:
rm -f *.o
@@ -30,4 +22,54 @@
rm -f cc1-*
distclean: clean
- rm -f makefile
+
+include target/amd64-sysv/arch.mk
+include target/arm64-sysv/arch.mk
+include target/i386-sysv/arch.mk
+include target/z80-scc/arch.mk
+
+cpp.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+decl.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+expr.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+init.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+lex.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+stmt.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+symbol.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+types.c: $(PROJECTDIR)/inc/$(STD)/cstd.h
+
+#deps
+builtin.o: ./../inc/scc.h
+builtin.o: ./cc1.h
+code.o: ./../inc/scc.h
+code.o: ./cc1.h
+cpp.o: ./../inc/scc.h
+cpp.o: ./cc1.h
+decl.o: ./../inc/scc.h
+decl.o: ./cc1.h
+error.o: ./../inc/scc.h
+error.o: ./cc1.h
+expr.o: ./../inc/scc.h
+expr.o: ./cc1.h
+fold.o: ./../inc/scc.h
+fold.o: ./cc1.h
+init.o: ./../inc/scc.h
+init.o: ./cc1.h
+lex.o: ./../inc/scc.h
+lex.o: ./cc1.h
+main.o: ./../inc/arg.h
+main.o: ./../inc/scc.h
+main.o: ./cc1.h
+stmt.o: ./../inc/scc.h
+stmt.o: ./cc1.h
+symbol.o: ./../inc/scc.h
+symbol.o: ./cc1.h
+target/amd64-sysv/arch.o: ./target/amd64-sysv/../../../inc/scc.h
+target/amd64-sysv/arch.o: ./target/amd64-sysv/../../cc1.h
+target/arm64-sysv/arch.o: ./target/arm64-sysv/../../../inc/scc.h
+target/arm64-sysv/arch.o: ./target/arm64-sysv/../../cc1.h
+target/i386-sysv/arch.o: ./target/i386-sysv/../../../inc/scc.h
+target/i386-sysv/arch.o: ./target/i386-sysv/../../cc1.h
+target/z80-scc/arch.o: ./target/z80-scc/../../../inc/scc.h
+target/z80-scc/arch.o: ./target/z80-scc/../../cc1.h
+types.o: ./../inc/scc.h
+types.o: ./cc1.h
--- a/cc1/gendep.sh
+++ /dev/null
@@ -1,27 +1,0 @@
-#!/bin/sh
-
-set -e
-
-rm -f makefile
-trap "rm -f $$.mk" 0 2 3
-
-re='\([^-]*\)-\([^-]*\)-\([^-]*\)-\([^-]*\)'
-
-echo $@ |
-tr ' ' '\n' |
-sed "s/$re/\1-\2/" |
-sort -u |
-(cat Makefile
-echo
-while read i
-do
- cat <<EOF
-all: cc1-$i
-OBJ-$i= \$(OBJ) target/$i/arch.o
-\$(OBJ-$i): \$(HDR)
-cc1-$i: \$(OBJ-$i) \$(LIBDIR)/libscc.a
- \$(CC) \$(SCC_LDFLAGS) \$(OBJ-$i) -lscc -o \$@
-
-EOF
- echo
-done) > $$.mk && mv $$.mk makefile
--- /dev/null
+++ b/cc1/target/amd64-sysv/arch.mk
@@ -1,0 +1,6 @@
+all: cc1-amd64-sysv
+
+OBJ-amd64-sysv= $(OBJ) target/amd64-sysv/arch.o
+
+cc1-amd64-sysv: $(OBJ-amd64-sysv) $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) $(OBJ-amd64-sysv) -lscc -o $@
--- a/cc1/target/arm64-sysv/arch.c
+++ b/cc1/target/arm64-sysv/arch.c
@@ -1,0 +1,220 @@
+static char sccsid[] = "@(#) ./cc1/arch/arm64-sysv/arch.c";
+
+#include "../../../inc/scc.h"
+#include "../../cc1.h"
+
+#define RANK_BOOL 0
+#define RANK_SCHAR 1
+#define RANK_UCHAR 1
+#define RANK_CHAR 1
+#define RANK_SHORT 2
+#define RANK_USHORT 2
+#define RANK_INT 3
+#define RANK_UINT 3
+#define RANK_LONG 4
+#define RANK_ULONG 4
+#define RANK_LLONG 5
+#define RANK_ULLONG 5
+#define RANK_FLOAT 6
+#define RANK_DOUBLE 7
+#define RANK_LDOUBLE 8
+
+/*
+ * Initializaion of type pointers were done with
+ * a C99 initilizator '... = &(Type) {...', but
+ * c compiler in Plan9 gives error with this
+ * syntax, so I have switched it to this ugly form
+ * I hope I will change it again in the future
+ */
+
+static Type types[] = {
+ { /* 0 = voidtype */
+ .op = VOID,
+ .letter = L_VOID,
+ },
+ { /* 1 = pvoidtype */
+ .op = PTR,
+ .letter = L_POINTER,
+ .prop = TDEFINED,
+ .type = &types[5], /* chartype */
+ .size = 8,
+ .align = 8,
+ },
+ { /* 2 = booltype */
+ .op = INT,
+ .letter = L_BOOL,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_BOOL,
+ },
+ { /* 3 = schartype */
+ .op = INT,
+ .letter = L_INT8,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_SCHAR,
+ },
+ { /* 4 = uchartype */
+ .op = INT,
+ .letter = L_UINT8,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_UCHAR,
+ },
+ { /* 5 = chartype */
+ .op = INT,
+ .letter = L_INT8,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 1,
+ .align = 1,
+ .n.rank = RANK_CHAR,
+ },
+ { /* 6 = ushortype */
+ .op = INT,
+ .letter = L_UINT16,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 2,
+ .align = 2,
+ .n.rank = RANK_USHORT,
+ },
+ { /* 7 = shortype */
+ .op = INT,
+ .letter = L_INT16,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 2,
+ .align = 2,
+ .n.rank = RANK_SHORT,
+ },
+ { /* 8 = uinttype */
+ .op = INT,
+ .letter = L_UINT32,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_UINT,
+ },
+ { /* 9 = inttype */
+ .op = INT,
+ .letter = L_INT32,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_INT,
+ },
+ { /* 10 = longtype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LONG,
+ },
+ { /* 11 = ulongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_ULONG,
+ },
+ { /* 12 = ullongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_ULLONG,
+ },
+ { /* 13 = llongtype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LLONG,
+ },
+ { /* 14 = floattype */
+ .op = FLOAT,
+ .letter = L_FLOAT,
+ .prop = TDEFINED | TARITH,
+ .size = 4,
+ .align = 4,
+ .n.rank = RANK_FLOAT,
+ },
+ { /* 15 = doubletype */
+ .op = FLOAT,
+ .letter = L_DOUBLE,
+ .prop = TDEFINED | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_DOUBLE,
+ },
+ { /* 16 = ldoubletype */
+ .op = FLOAT,
+ .letter = L_LDOUBLE,
+ .prop = TDEFINED | TARITH,
+ .size = 16,
+ .align = 16,
+ .n.rank = RANK_LDOUBLE,
+ },
+ { /* 17 = sizettype */
+ .op = INT,
+ .letter = L_UINT64,
+ .prop = TDEFINED | TINTEGER | TARITH,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_UINT,
+ },
+ { /* 18 = ellipsis */
+ .op = ELLIPSIS,
+ .letter = L_ELLIPSIS,
+ .prop = TDEFINED,
+ },
+ { /* 19 = pdifftype */
+ .op = INT,
+ .letter = L_INT64,
+ .prop = TDEFINED | TINTEGER | TARITH | TSIGNED,
+ .size = 8,
+ .align = 8,
+ .n.rank = RANK_LONG,
+ },
+ { /* 20 = va_type */
+ .op = STRUCT,
+ .letter = L_VA_ARG,
+ .prop = TDEFINED,
+ .size = 24,
+ .align = 8,
+ },
+};
+
+Type *voidtype = &types[0], *pvoidtype = &types[1],
+ *booltype = &types[2], *schartype = &types[3],
+ *uchartype = &types[4], *chartype = &types[5],
+ *ushortype = &types[6], *shortype = &types[7],
+ *uinttype = &types[8], *inttype = &types[9],
+ *longtype = &types[10], *ulongtype = &types[11],
+ *ullongtype = &types[12], *llongtype = &types[13],
+ *floattype = &types[14], *doubletype = &types[15],
+ *ldoubletype = &types[16],
+ *sizettype = &types[17], *pdifftype = &types[19],
+ *ellipsistype = &types[18], *va_type = &types[20],
+ *va_list_type;
+
+static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
+ dummy1 = {.u.i = 1, .type = &types[9]};
+Symbol *zero = &dummy0, *one = &dummy1;
+
+void
+iarch(void)
+{
+ va_list_type = mktype(va_type, ARY, 1, NULL);
+}
+
+int
+valid_va_list(Type *tp)
+{
+ return tp->op == PTR && eqtype(tp->type, va_type, 1);
+}
--- /dev/null
+++ b/cc1/target/arm64-sysv/arch.mk
@@ -1,0 +1,6 @@
+all: cc1-arm64-sysv
+
+OBJ-arm64-sysv= $(OBJ) target/arm64-sysv/arch.o
+
+cc1-arm64-sysv: $(OBJ-arm64-sysv) $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) $(OBJ-arm64-sysv) -lscc -o $@
--- /dev/null
+++ b/cc1/target/i386-sysv/arch.mk
@@ -1,0 +1,7 @@
+
+all: cc1-i386-sysv
+
+OBJ-i386-sysv= $(OBJ) target/i386-sysv/arch.o
+
+cc1-i386-sysv: $(OBJ-i386-sysv) $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) $(OBJ-i386-sysv) -lscc -o $@
--- /dev/null
+++ b/cc1/target/z80-scc/arch.mk
@@ -1,0 +1,7 @@
+
+all: cc1-z80-scc
+
+OBJ-z80-scc= $(OBJ) target/z80-scc/arch.o
+
+cc1-z80-scc: $(OBJ-z80-scc) $(LIBDIR)/libscc.a
+ $(CC) $(SCC_LDFLAGS) $(OBJ-z80-scc) -lscc -o $@