scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit ebdceee280c3dce288f83b845764e4c2807dd4f1
parent 7bb24c18c03aaf5ee073b8bb3bfaa615f4986800
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed, 25 May 2016 16:56:52 +0200

[cc2] Add architecture independent optimizer

We need this phase because it is not a good idea to transform
switches in the parser. Some of the code that is at this moment
in QBE optm_dep must come here.

Diffstat:
Mcc2/Makefile | 2+-
Mcc2/arch/amd64-sysv/optm.c | 2+-
Mcc2/arch/i386-sysv/optm.c | 2+-
Mcc2/arch/qbe/optm.c | 2+-
Mcc2/arch/z80/optm.c | 2+-
Mcc2/cc2.h | 2+-
Mcc2/main.c | 3++-
7 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/cc2/Makefile b/cc2/Makefile @@ -3,7 +3,7 @@ include ../config.mk -OBJS = main.o parser.o peep.o symbol.o node.o code.o\ +OBJS = main.o parser.o peep.o symbol.o node.o code.o optm.o\ arch/$(ARCH)/code.o arch/$(ARCH)/cgen.o \ arch/$(ARCH)/types.o arch/$(ARCH)/optm.o diff --git a/cc2/arch/amd64-sysv/optm.c b/cc2/arch/amd64-sysv/optm.c @@ -3,7 +3,7 @@ #include "../../cc2.h" Node * -optm(Node *np) +optm_dep(Node *np) { return np; } diff --git a/cc2/arch/i386-sysv/optm.c b/cc2/arch/i386-sysv/optm.c @@ -3,7 +3,7 @@ #include "../../cc2.h" Node * -optm(Node *np) +optm_dep(Node *np) { return np; } diff --git a/cc2/arch/qbe/optm.c b/cc2/arch/qbe/optm.c @@ -5,7 +5,7 @@ #include "../../cc2.h" Node * -optm(Node *np) +optm_dep(Node *np) { int op = np->op; Node *p, *dst, *next = np->next; diff --git a/cc2/arch/z80/optm.c b/cc2/arch/z80/optm.c @@ -3,7 +3,7 @@ #include "../../cc2.h" Node * -optm(Node *np) +optm_dep(Node *np) { return np; } diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -191,7 +191,7 @@ extern void error(unsigned nerror, ...); extern void parse(void); /* optm.c */ -extern Node *optm(Node *np); +extern Node *optm_dep(Node *np), *optm_ind(Node *np); /* cgen.c */ extern Node *sethi(Node *np); diff --git a/cc2/main.c b/cc2/main.c @@ -38,7 +38,8 @@ main(void) while (moreinput()) { parse(); - apply(optm); + apply(optm_ind); + apply(optm_dep); apply(sethi); apply(cgen); peephole();