[hackers] [scc] [cc2] Add architecture independent optimizer || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 26 May 2016 19:08:31 +0200 (CEST)

commit ebdceee280c3dce288f83b845764e4c2807dd4f1
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed May 25 16:56:52 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed May 25 16:56:52 2016 +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.

diff --git a/cc2/Makefile b/cc2/Makefile
index 5bf33eb..62e58d0 100644
--- a/cc2/Makefile
+++ b/cc2/Makefile
_AT_@ -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
index 2500fff..6764c1d 100644
--- a/cc2/arch/amd64-sysv/optm.c
+++ b/cc2/arch/amd64-sysv/optm.c
_AT_@ -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
index 2500fff..6764c1d 100644
--- a/cc2/arch/i386-sysv/optm.c
+++ b/cc2/arch/i386-sysv/optm.c
_AT_@ -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
index ed96e58..8cbaee4 100644
--- a/cc2/arch/qbe/optm.c
+++ b/cc2/arch/qbe/optm.c
_AT_@ -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
index 2500fff..6764c1d 100644
--- a/cc2/arch/z80/optm.c
+++ b/cc2/arch/z80/optm.c
_AT_@ -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
index 98ad094..4a44b55 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
_AT_@ -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
index 98791be..cc51c2e 100644
--- a/cc2/main.c
+++ b/cc2/main.c
_AT_@ -38,7 +38,8 @@ main(void)
 
         while (moreinput()) {
                 parse();
- apply(optm);
+ apply(optm_ind);
+ apply(optm_dep);
                 apply(sethi);
                 apply(cgen);
                 peephole();
Received on Thu May 26 2016 - 19:08:31 CEST

This archive was generated by hypermail 2.3.0 : Thu May 26 2016 - 19:12:14 CEST