scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit f264d340ebf98ea1b194567fbf7d79318c8e718f
parent 5188dbbcd9fa156fd5b06a6d8d21c9e4b148c3af
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue,  6 Feb 2018 17:37:38 +0100

[cc2-z80] Add basic code for cgen()

Diffstat:
Mcc2/target/z80-scc/arch.h | 4++++
Mcc2/target/z80-scc/cgen.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)

diff --git a/cc2/target/z80-scc/arch.h b/cc2/target/z80-scc/arch.h @@ -0,0 +1,4 @@ +enum asmop { + ASJMP = 0, + ASRET, +}; diff --git a/cc2/target/z80-scc/cgen.c b/cc2/target/z80-scc/cgen.c @@ -4,9 +4,57 @@ static char sccsid[] = "@(#) ./cc2/arch/z80/cgen.c"; #include "../../../inc/scc.h" #include "../../cc2.h" +static void +swtch(Node *idx) +{ +} + +static Node * +lhs(Node *np, Node *ret) +{ +} + +static Node * +rhs(Node *np, Node *ret) +{ +} + +static void +bool(Node *np, Symbol *true, Symbol *false) +{ +} + Node * cgen(Node *np) { + Node aux, *p, *next; + + setlabel(np->label); + switch (np->op) { + case OJMP: + label2node(&aux, np->u.sym); + code(ASJMP, NULL, &aux, NULL); + break; + case OBRANCH: + next = np->next; + if (!next->label) + next->label = newlabel(); + bool(np->left, np->u.sym, next->label); + break; + case ORET: + p = np->left; + if (p) + p = rhs(np->left, &aux); + code(ASRET, NULL, p, NULL); + break; + case OBSWITCH: + swtch(rhs(np->left, &aux)); + break; + default: + rhs(np, &aux); + break; + } + return NULL; } /*