shithub: scc

Download patch

ref: 8b00f72b25f932c65f7b3f54ca5f94742d0d00be
parent: 275a2ef9b9df16b5b5d7811fe0748bf0a3842743
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Sep 25 13:28:58 EDT 2015

Remove arch/z80/type.c

This file was needed in order to have the array types, but this array
does not depend of the arch because it is parametrized with the definitions
of arch.h

--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -1,7 +1,7 @@
 include ../config.mk
 
 OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \
-	code.o stmt.o cpp.o fold.o arch/$(ARCH)/types.o
+	code.o stmt.o cpp.o fold.o
 
 all: cc1
 
--- a/cc1/arch/z80/arch.h
+++ b/cc1/arch/z80/arch.h
@@ -1,7 +1,37 @@
 
-#define TINT    long long
-#define TUINT   unsigned long long
-#define TFLOAT  double
+#define TINT        long long
+#define TUINT       unsigned long long
+#define TFLOAT      double
 
+#define RANK_BOOL    0
+#define RANK_SCHAR   1
+#define RANK_UCHAR   2
+#define RANK_CHAR    3
+#define RANK_SHORT   4
+#define RANK_USHORT  5
+#define RANK_INT     6
+#define RANK_UINT    7
+#define RANK_LONG    8
+#define RANK_ULONG   9
+#define RANK_LLONG   10
+#define RANK_ULLONG  11
+#define RANK_FLOAT   12
+#define RANK_DOUBLE  13
+#define RANK_LDOUBLE 15
+
+#define L_SCHAR     L_INT8
+#define L_UCHAR     L_UINT8
+#define L_CHAR      L_UINT8
+#define L_SHORT     L_INT16
+#define L_USHORT    L_UINT16
 #define L_INT       L_INT16
-#define L_ENUM      L_INT
\ No newline at end of file
+#define L_UINT      L_UINT16
+#define L_LONG      L_INT32
+#define L_ULONG     L_UINT32
+#define L_LLONG     L_INT64
+#define L_ULLONG    L_UINT64
+#define L_BOOL      'B'
+#define L_FLOAT     'J'
+#define L_DOUBLE    'D'
+#define L_LDOUBLE   'H'
+#define L_ENUM      L_INT
--- a/cc1/arch/z80/types.c
+++ /dev/null
@@ -1,223 +1,0 @@
-
-#include <stdio.h>
-
-#include "../../../inc/cc.h"
-#include "../../cc1.h"
-#include "arch.h"
-
-#define RANK_BOOL    0
-#define RANK_SCHAR   1
-#define RANK_UCHAR   2
-#define RANK_CHAR    3
-#define RANK_SHORT   4
-#define RANK_USHORT  5
-#define RANK_INT     6
-#define RANK_UINT    7
-#define RANK_LONG    8
-#define RANK_ULONG   9
-#define RANK_LLONG   10
-#define RANK_ULLONG  11
-#define RANK_FLOAT   12
-#define RANK_DOUBLE  13
-#define RANK_LDOUBLE 15
-
-#define L_SCHAR     L_INT8
-#define L_UCHAR     L_UINT8
-#define L_CHAR      L_UINT8
-#define L_SHORT     L_INT16
-#define L_USHORT    L_UINT16
-#define L_UINT      L_UINT16
-#define L_LONG      L_INT32
-#define L_ULONG     L_UINT32
-#define L_LLONG     L_INT64
-#define L_ULLONG    L_UINT64
-#define L_BOOL      'B'
-#define L_FLOAT     'J'
-#define L_DOUBLE    'D'
-#define L_LDOUBLE   'H'
-
-/*
- * 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,
-		.printed = 1
-	},
-	{       /* 1 = pvoidtype */
-		.op = PTR,
-		.letter = L_POINTER,
-		.size = 2,
-		.align = 2,
-		.printed = 1
-	},
-	{      /* 2 = booltype */
-		.op = INT,
-		.letter = L_BOOL,
-		.defined = 1,
-		.size = 1,
-		.align = 1,
-		.n.rank = RANK_BOOL,
-		.printed = 1
-	},
-	{       /* 3 = schartype */
-		.op = INT,
-		.letter = L_SCHAR,
-		.defined = 1,
-		.size = 1,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_SCHAR,
-		.printed = 1
-	},
-	{      /* 4 = uchartype */
-		.op = INT,
-		.letter = L_UCHAR,
-		.defined = 1,
-		.size = 1,
-		.align = 1,
-		.n.rank = RANK_UCHAR,
-		.printed = 1
-	},
-	{      /* 5 = chartype */
-		.op = INT,
-		.letter = L_CHAR,
-		.defined = 1,
-		.size = 1,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_CHAR,
-		.printed = 1
-	},
-	{       /* 6 = ushortype */
-		.op = INT,
-		.letter = L_USHORT,
-		.defined = 1,
-		.size = 2,
-		.align = 1,
-		.n.rank = RANK_USHORT,
-		.printed = 1
-	},
-	{       /* 7 = shortype */
-		.op = INT,
-		.letter = L_SHORT,
-		.defined = 1,
-		.size = 2,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_SHORT,
-		.printed = 1
-	},
-	{       /* 8 = uinttype */
-		.op = INT,
-		.letter = L_UINT,
-		.defined = 1,
-		.size = 2,
-		.align = 1,
-		.n.rank = RANK_UINT,
-		.printed = 1
-	},
-	{       /* 9 = inttype */
-		.op = INT,
-		.letter = L_INT,
-		.defined = 1,
-		.size = 2,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_INT,
-		.printed = 1
-	},
-	{      /* 10 = longtype */
-		.op = INT,
-		.letter = L_LONG,
-		.defined = 1,
-		.size = 4,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_LONG,
-		.printed = 1
-	},
-	{       /* 11 = ulongtype */
-		.op = INT,
-		.letter = L_ULONG,
-		.defined = 1,
-		.size = 4,
-		.align = 1,
-		.n.rank = RANK_ULONG,
-		.printed = 1
-	},
-	{	/* 12 = ullongtype */
-		.op = INT,
-		.letter = L_ULLONG,
-		.defined = 1,
-		.size = 8,
-		.align = 1,
-		.n.rank = RANK_ULLONG,
-		.printed = 1
-	},
-	{       /* 13 = llongtype */
-		.op = INT,
-		.letter = L_LLONG,
-		.defined = 1,
-		.size = 8,
-		.align = 1,
-		.sign = 1,
-		.n.rank = RANK_LLONG,
-		.printed = 1
-	},
-	{       /* 14 = floattype */
-		.op = FLOAT,
-		.letter = L_FLOAT,
-		.defined = 1,
-		.size = 4,
-		.align = 1,
-		.n.rank = RANK_FLOAT,
-		.printed = 1
-	},
-	{       /* 15 = doubletype */
-		.op = FLOAT,
-		.letter = L_DOUBLE,
-		.defined = 1,
-		.size = 8,
-		.align = 1,
-		.n.rank = RANK_DOUBLE,
-		.printed = 1
-	},
-	{       /* 16 = ldoubletype */
-		.op = FLOAT,
-		.letter = L_LDOUBLE,
-		.defined = 1,
-		.size = 16,
-		.align = 1,
-		.n.rank = RANK_LDOUBLE,
-		.printed = 1
-	},
-	{       /* 17 = sizettype */
-		.op = INT,
-		.letter = L_UINT,
-		.defined = 1,
-		.size = 2,
-		.align = 1,
-		.n.rank = RANK_UINT,
-		.printed = 1
-	}
-};
-
-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];
-
-static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
-              dummy1 = {.u.i = 1, .type = &types[9]};
-Symbol *zero = &dummy0, *one = &dummy1;
--- a/cc1/types.c
+++ b/cc1/types.c
@@ -16,7 +16,7 @@
  * TUINT and TFLOAT are smaller than any of the constants in this
  * array. Ignore them if you know that the target types are correct
  */
-struct limits limits[][4] = {
+static struct limits limits[][4] = {
 	{
 		{	/* 0 = unsigned 1 byte */
 			.min.u = 0,
@@ -71,6 +71,192 @@
 		}
 	}
 };
+
+/*
+ * 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,
+		.printed = 1
+	},
+	{       /* 1 = pvoidtype */
+		.op = PTR,
+		.letter = L_POINTER,
+		.size = 2,
+		.align = 2,
+		.printed = 1
+	},
+	{      /* 2 = booltype */
+		.op = INT,
+		.letter = L_BOOL,
+		.defined = 1,
+		.size = 1,
+		.align = 1,
+		.n.rank = RANK_BOOL,
+		.printed = 1
+	},
+	{       /* 3 = schartype */
+		.op = INT,
+		.letter = L_SCHAR,
+		.defined = 1,
+		.size = 1,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_SCHAR,
+		.printed = 1
+	},
+	{      /* 4 = uchartype */
+		.op = INT,
+		.letter = L_UCHAR,
+		.defined = 1,
+		.size = 1,
+		.align = 1,
+		.n.rank = RANK_UCHAR,
+		.printed = 1
+	},
+	{      /* 5 = chartype */
+		.op = INT,
+		.letter = L_CHAR,
+		.defined = 1,
+		.size = 1,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_CHAR,
+		.printed = 1
+	},
+	{       /* 6 = ushortype */
+		.op = INT,
+		.letter = L_USHORT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.n.rank = RANK_USHORT,
+		.printed = 1
+	},
+	{       /* 7 = shortype */
+		.op = INT,
+		.letter = L_SHORT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_SHORT,
+		.printed = 1
+	},
+	{       /* 8 = uinttype */
+		.op = INT,
+		.letter = L_UINT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.n.rank = RANK_UINT,
+		.printed = 1
+	},
+	{       /* 9 = inttype */
+		.op = INT,
+		.letter = L_INT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_INT,
+		.printed = 1
+	},
+	{      /* 10 = longtype */
+		.op = INT,
+		.letter = L_LONG,
+		.defined = 1,
+		.size = 4,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_LONG,
+		.printed = 1
+	},
+	{       /* 11 = ulongtype */
+		.op = INT,
+		.letter = L_ULONG,
+		.defined = 1,
+		.size = 4,
+		.align = 1,
+		.n.rank = RANK_ULONG,
+		.printed = 1
+	},
+	{	/* 12 = ullongtype */
+		.op = INT,
+		.letter = L_ULLONG,
+		.defined = 1,
+		.size = 8,
+		.align = 1,
+		.n.rank = RANK_ULLONG,
+		.printed = 1
+	},
+	{       /* 13 = llongtype */
+		.op = INT,
+		.letter = L_LLONG,
+		.defined = 1,
+		.size = 8,
+		.align = 1,
+		.sign = 1,
+		.n.rank = RANK_LLONG,
+		.printed = 1
+	},
+	{       /* 14 = floattype */
+		.op = FLOAT,
+		.letter = L_FLOAT,
+		.defined = 1,
+		.size = 4,
+		.align = 1,
+		.n.rank = RANK_FLOAT,
+		.printed = 1
+	},
+	{       /* 15 = doubletype */
+		.op = FLOAT,
+		.letter = L_DOUBLE,
+		.defined = 1,
+		.size = 8,
+		.align = 1,
+		.n.rank = RANK_DOUBLE,
+		.printed = 1
+	},
+	{       /* 16 = ldoubletype */
+		.op = FLOAT,
+		.letter = L_LDOUBLE,
+		.defined = 1,
+		.size = 16,
+		.align = 1,
+		.n.rank = RANK_LDOUBLE,
+		.printed = 1
+	},
+	{       /* 17 = sizettype */
+		.op = INT,
+		.letter = L_UINT,
+		.defined = 1,
+		.size = 2,
+		.align = 1,
+		.n.rank = RANK_UINT,
+		.printed = 1
+	}
+};
+
+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];
+
+static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
+              dummy1 = {.u.i = 1, .type = &types[9]};
+Symbol *zero = &dummy0, *one = &dummy1;
 
 struct limits *
 getlimits(Type *tp)