[hackers] [scc] [cc2] Move optm to target code || Roberto E. Vargas Caballero
commit 2c4ff80a5962f0f37abada47d2b3af2a5e58834f
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon May 9 10:30:15 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon May 9 12:56:16 2016 +0200
[cc2] Move optm to target code
All the independent optimizations are done in cc1, so there is no much room
for target independent optimizations in cc2. At this moment these target
independent optimizations were done mainly because qbe needs them, but
we there are some changes that qbe needs that are not going to be
useful for other targets (and in some cases even they are going to be
worse).
diff --git a/cc2/Makefile b/cc2/Makefile
index 3e1b26c..34695b6 100644
--- a/cc2/Makefile
+++ b/cc2/Makefile
_AT_@ -2,8 +2,9 @@
include ../config.mk
-OBJS = main.o parser.o optm.o peep.o symbol.o node.o code.o\
- arch/$(ARCH)/code.o arch/$(ARCH)/cgen.o arch/$(ARCH)/types.o
+OBJS = main.o parser.o peep.o symbol.o node.o code.o\
+ arch/$(ARCH)/code.o arch/$(ARCH)/cgen.o \
+ arch/$(ARCH)/types.o arch/$(ARCH)/optm.o
all: cc2
diff --git a/cc2/arch/amd64-sysv/optm.c b/cc2/arch/amd64-sysv/optm.c
new file mode 100644
index 0000000..3658917
--- /dev/null
+++ b/cc2/arch/amd64-sysv/optm.c
_AT_@ -0,0 +1,9 @@
+
+#include "arch.h"
+#include "../../cc2.h"
+
+Node *
+optm(Node *np)
+{
+ return np;
+}
diff --git a/cc2/arch/i386-sysv/optm.c b/cc2/arch/i386-sysv/optm.c
new file mode 100644
index 0000000..3658917
--- /dev/null
+++ b/cc2/arch/i386-sysv/optm.c
_AT_@ -0,0 +1,9 @@
+
+#include "arch.h"
+#include "../../cc2.h"
+
+Node *
+optm(Node *np)
+{
+ return np;
+}
diff --git a/cc2/arch/qbe/optm.c b/cc2/arch/qbe/optm.c
new file mode 100644
index 0000000..70ea0b0
--- /dev/null
+++ b/cc2/arch/qbe/optm.c
_AT_@ -0,0 +1,45 @@
+
+#include <stddef.h>
+
+#include "arch.h"
+#include "../../cc2.h"
+
+Node *
+optm(Node *np)
+{
+ Node *p, *dst, *next = np->next;
+ Symbol *sym, *osym;
+
+ switch (np->op) {
+ case ONOP:
+ if (next && next->op == ONOP) {
+ sym = np->u.sym;
+ osym = next->u.sym;
+ osym->id = sym->id;
+ osym->numid = sym->id;
+ osym->u.stmt = sym->u.stmt;
+ return NULL;
+ }
+ break;
+ case OJMP:
+ case OBRANCH:
+ for (;;) {
+ dst = np->u.sym->u.stmt;
+ if (dst->op != OJMP)
+ break;
+ np->u.sym = dst->u.sym;
+ }
+ for (p = np->next; p; p = p->next) {
+ if (p == dst)
+ return NULL;
+ if (p->op == ONOP ||
+ p->op == OBLOOP ||
+ p->op == OELOOP) {
+ continue;
+ }
+ break;
+ }
+ break;
+ }
+ return np;
+}
diff --git a/cc2/arch/z80/optm.c b/cc2/arch/z80/optm.c
new file mode 100644
index 0000000..3658917
--- /dev/null
+++ b/cc2/arch/z80/optm.c
_AT_@ -0,0 +1,9 @@
+
+#include "arch.h"
+#include "../../cc2.h"
+
+Node *
+optm(Node *np)
+{
+ return np;
+}
diff --git a/cc2/optm.c b/cc2/optm.c
deleted file mode 100644
index 1690bb2..0000000
--- a/cc2/optm.c
+++ /dev/null
_AT_@ -1,45 +0,0 @@
-
-#include <stddef.h>
-
-#include "arch.h"
-#include "cc2.h"
-
-Node *
-optm(Node *np)
-{
- Node *p, *dst, *next = np->next;
- Symbol *sym, *osym;
-
- switch (np->op) {
- case ONOP:
- if (next && next->op == ONOP) {
- sym = np->u.sym;
- osym = next->u.sym;
- osym->id = sym->id;
- osym->numid = sym->id;
- osym->u.stmt = sym->u.stmt;
- return NULL;
- }
- break;
- case OJMP:
- case OBRANCH:
- for (;;) {
- dst = np->u.sym->u.stmt;
- if (dst->op != OJMP)
- break;
- np->u.sym = dst->u.sym;
- }
- for (p = np->next; p; p = p->next) {
- if (p == dst)
- return NULL;
- if (p->op == ONOP ||
- p->op == OBLOOP ||
- p->op == OELOOP) {
- continue;
- }
- break;
- }
- break;
- }
- return np;
-}
Received on Mon May 09 2016 - 17:00:22 CEST
This archive was generated by hypermail 2.3.0
: Mon May 09 2016 - 17:12:18 CEST