[hackers] [scc] Add skeleton for qbe backend || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 31 Mar 2016 12:26:33 +0200 (CEST)

commit fcc35769bdb9d890ed1316fb68649138007c2a34
Author: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
AuthorDate: Thu Mar 31 08:56:56 2016 +0200
Commit: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
CommitDate: Thu Mar 31 12:22:48 2016 +0200

    Add skeleton for qbe backend
    
    This is the first step to have a qbe backend, and it was pretty easy
    because the data configuration is the same that amd64 target,
    because in fact qbe is a amd64 backend.

diff --git a/Makefile b/Makefile
index cc3c349..a5a88aa 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -4,7 +4,7 @@
 include config.mk
 
 DIRS = lib cc1 cc2 driver/$(DRIVER)
-ARCHS = z80 i386-sysv amd64-sysv
+ARCHS = z80 i386-sysv amd64-sysv qbe
 
 all:
         for i in $(DIRS) ; \
diff --git a/cc1/arch/qbe/arch.c b/cc1/arch/qbe/arch.c
new file mode 100644
index 0000000..ea043b4
--- /dev/null
+++ b/cc1/arch/qbe/arch.c
_AT_@ -0,0 +1,243 @@
+
+#include <stdio.h>
+
+#include "arch.h"
+#include "../../../inc/cc.h"
+#include "../../cc1.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,
+ .defined = 1,
+ },
+ { /* 2 = booltype */
+ .op = INT,
+ .letter = L_BOOL,
+ .defined = 1,
+ .size = 1,
+ .integer = 1,
+ .arith = 1,
+ .align = 1,
+ .n.rank = RANK_BOOL,
+ .printed = 1
+ },
+ { /* 3 = schartype */
+ .op = INT,
+ .letter = L_INT8,
+ .defined = 1,
+ .size = 1,
+ .integer = 1,
+ .arith = 1,
+ .align = 1,
+ .sign = 1,
+ .n.rank = RANK_SCHAR,
+ .printed = 1
+ },
+ { /* 4 = uchartype */
+ .op = INT,
+ .letter = L_UINT8,
+ .defined = 1,
+ .size = 1,
+ .integer = 1,
+ .arith = 1,
+ .align = 1,
+ .n.rank = RANK_UCHAR,
+ .printed = 1
+ },
+ { /* 5 = chartype */
+ .op = INT,
+ .letter = L_INT8,
+ .defined = 1,
+ .size = 1,
+ .integer = 1,
+ .arith = 1,
+ .align = 1,
+ .sign = 1,
+ .n.rank = RANK_CHAR,
+ .printed = 1
+ },
+ { /* 6 = ushortype */
+ .op = INT,
+ .letter = L_UINT16,
+ .defined = 1,
+ .size = 2,
+ .integer = 1,
+ .arith = 1,
+ .align = 2,
+ .n.rank = RANK_USHORT,
+ .printed = 1
+ },
+ { /* 7 = shortype */
+ .op = INT,
+ .letter = L_INT16,
+ .defined = 1,
+ .size = 2,
+ .integer = 1,
+ .arith = 1,
+ .align = 2,
+ .sign = 1,
+ .n.rank = RANK_SHORT,
+ .printed = 1
+ },
+ { /* 8 = uinttype */
+ .op = INT,
+ .letter = L_UINT32,
+ .defined = 1,
+ .size = 4,
+ .integer = 1,
+ .arith = 1,
+ .align = 4,
+ .n.rank = RANK_UINT,
+ .printed = 1
+ },
+ { /* 9 = inttype */
+ .op = INT,
+ .letter = L_INT32,
+ .defined = 1,
+ .size = 4,
+ .integer = 1,
+ .arith = 1,
+ .align = 4,
+ .sign = 1,
+ .n.rank = RANK_INT,
+ .printed = 1
+ },
+ { /* 10 = longtype */
+ .op = INT,
+ .letter = L_INT64,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .sign = 1,
+ .n.rank = RANK_LONG,
+ .printed = 1
+ },
+ { /* 11 = ulongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .n.rank = RANK_ULONG,
+ .printed = 1
+ },
+ { /* 12 = ullongtype */
+ .op = INT,
+ .letter = L_UINT64,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .n.rank = RANK_ULLONG,
+ .printed = 1
+ },
+ { /* 13 = llongtype */
+ .op = INT,
+ .letter = L_INT64,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .sign = 1,
+ .n.rank = RANK_LLONG,
+ .printed = 1
+ },
+ { /* 14 = floattype */
+ .op = FLOAT,
+ .letter = L_FLOAT,
+ .defined = 1,
+ .size = 4,
+ .arith = 1,
+ .align = 4,
+ .n.rank = RANK_FLOAT,
+ .printed = 1
+ },
+ { /* 15 = doubletype */
+ .op = FLOAT,
+ .letter = L_DOUBLE,
+ .defined = 1,
+ .size = 8,
+ .arith = 1,
+ .align = 8,
+ .n.rank = RANK_DOUBLE,
+ .printed = 1
+ },
+ { /* 16 = ldoubletype */
+ .op = FLOAT,
+ .letter = L_LDOUBLE,
+ .defined = 1,
+ .size = 16,
+ .arith = 1,
+ .align = 16,
+ .n.rank = RANK_LDOUBLE,
+ .printed = 1
+ },
+ { /* 17 = sizettype */
+ .op = INT,
+ .letter = L_UINT32,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .n.rank = RANK_UINT,
+ .printed = 1
+ },
+ { /* 18 = ellipsis */
+ .op = ELLIPSIS,
+ .letter = L_ELLIPSIS,
+ .defined = 1,
+ .printed = 1
+ },
+ { /* 19 = pdifftype */
+ .op = INT,
+ .letter = L_INT64,
+ .defined = 1,
+ .size = 8,
+ .integer = 1,
+ .arith = 1,
+ .align = 8,
+ .sign = 1,
+ .n.rank = RANK_LONG,
+ .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], *pdifftype = &types[19],
+ *ellipsistype = &types[18];
+
+static Symbol dummy0 = {.u.i = 0, .type = &types[9]},
+ dummy1 = {.u.i = 1, .type = &types[9]};
+Symbol *zero = &dummy0, *one = &dummy1;
diff --git a/cc1/arch/qbe/arch.h b/cc1/arch/qbe/arch.h
new file mode 100644
index 0000000..6d085d6
--- /dev/null
+++ b/cc1/arch/qbe/arch.h
_AT_@ -0,0 +1,23 @@
+
+#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
+
+#define TINT long long
+#define TUINT unsigned long long
+#define TFLOAT double
+#define TSIZE unsigned long
+
+#define L_ENUM L_INT32
diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
new file mode 100644
index 0000000..439e3b7
--- /dev/null
+++ b/cc2/arch/qbe/arch.h
_AT_@ -0,0 +1,6 @@
+
+#define TINT long long
+#define TUINT unsigned long long
+#define TFLOAT double
+#define TSIZE unsigned long
+
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
new file mode 100644
index 0000000..1101f84
--- /dev/null
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -0,0 +1,13 @@
+
+#include "arch.h"
+#include "../../cc2.h"
+
+void
+generate(void)
+{
+}
+
+void
+addressability(void)
+{
+}
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
new file mode 100644
index 0000000..8133d11
--- /dev/null
+++ b/cc2/arch/qbe/code.c
_AT_@ -0,0 +1,28 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "arch.h"
+#include "../../cc2.h"
+#include "../../../inc/sizes.h"
+
+
+void
+allocdata(Type *tp)
+{
+}
+
+void
+data(Node *np)
+{
+}
+
+void
+label(Symbol *sym)
+{
+}
+
+void
+writeout(void)
+{
+}
diff --git a/cc2/arch/qbe/types.c b/cc2/arch/qbe/types.c
new file mode 100644
index 0000000..a6fab5b
--- /dev/null
+++ b/cc2/arch/qbe/types.c
_AT_@ -0,0 +1,89 @@
+
+#include "arch.h"
+#include "../../cc2.h"
+
+
+Type int8type = {
+ .flags = SIGNF | INTF,
+ .size = 1,
+ .align = 1
+};
+
+Type int16type = {
+ .flags = SIGNF | INTF,
+ .size = 2,
+ .align = 2
+};
+
+Type int32type = {
+ .flags = SIGNF | INTF,
+ .size = 4,
+ .align = 4
+};
+
+Type int64type = {
+ .flags = SIGNF | INTF,
+ .size = 8,
+ .align = 8
+};
+
+Type uint8type = {
+ .flags = INTF,
+ .size = 1,
+ .align = 1
+};
+
+Type uint16type = {
+ .flags = INTF,
+ .size = 2,
+ .align = 2
+};
+
+Type uint32type = {
+ .flags = INTF,
+ .size = 4,
+ .align = 4
+};
+
+Type uint64type = {
+ .flags = INTF,
+ .size = 8,
+ .align = 2
+};
+
+Type ptrtype = {
+ .flags = INTF,
+ .size = 8,
+ .align = 8
+};
+
+Type booltype = {
+ .flags = INTF,
+ .size = 1,
+ .align = 1
+};
+
+Type float32type = {
+ .size = 4,
+ .align = 4
+};
+
+Type float64type = {
+ .size = 8,
+ .align = 8
+};
+
+Type float80type = {
+ .size = 16,
+ .align = 16
+};
+
+Type voidtype = {
+ .size = 0,
+ .align = 0
+};
+
+Type elipsistype = {
+ .size = 0,
+ .align = 0
+};
Received on Thu Mar 31 2016 - 12:26:33 CEST

This archive was generated by hypermail 2.3.0 : Thu Mar 31 2016 - 12:36:17 CEST