scc

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

commit fc93bb35a8cebade80d9f0b920bb93b2b78aa81d
parent f2c0749ff6ad1041feb2cdb8ac164fd37b6f2e8c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 10 Feb 2015 18:05:06 +0100

Rename emit() to code()

The idea in some moment is to store the code in an array,
so code is a better name for this function, because we
don't want to emit code, we want to create code in our
vector of code.

Diffstat:
Mcc2/cc2.h | 2+-
Mcc2/cgen.c | 38+++++++++++++++++++-------------------
Mcc2/code.c | 2+-
3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -115,4 +115,4 @@ extern void generate(Symbol *fun); extern void genstack(Symbol *fun); extern void apply(Node *list[], void (*fun)(Node *)); extern Symbol *parse(void); -extern void emit(char op, ...); +extern void code(char op, ...); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -74,11 +74,11 @@ move(Node *np) sym = np->u.sym; switch (tp->size) { case 1: - emit(LDFX, reg, IX, sym->u.v.off); + code(LDFX, reg, IX, sym->u.v.off); break; case 2: - emit(LDFX, lower[reg], IX, sym->u.v.off); - emit(LDFX, upper[reg], IX, sym->u.v.off+1); + code(LDFX, lower[reg], IX, sym->u.v.off); + code(LDFX, upper[reg], IX, sym->u.v.off+1); break; case 4: case 8: @@ -146,10 +146,10 @@ cgen(Node *np) rp = np->right; } else if (lp->u.reg != A) { /* TODO: Move A to variable */ - emit(PUSH, AF); - emit(LD, A, lp->u.reg); + code(PUSH, AF); + code(LD, A, lp->u.reg); } - emit(ADD, A, rp->u.reg); + code(ADD, A, rp->u.reg); break; case 2: if (rp->u.reg == HL || rp->u.reg == IY) { @@ -158,11 +158,11 @@ cgen(Node *np) rp = np->right; } else if (lp->u.reg != HL && lp->u.reg != IY) { /* TODO: Move HL to variable */ - emit(PUSH, HL); - emit(LD, H, upper[lp->u.reg]); - emit(LD, L, lower[lp->u.reg]); + code(PUSH, HL); + code(LD, H, upper[lp->u.reg]); + code(LD, L, lower[lp->u.reg]); } - emit(ADD, lp->u.reg, rp->u.reg); + code(ADD, lp->u.reg, rp->u.reg); break; case 4: case 8: @@ -180,21 +180,21 @@ generate(Symbol *fun) extern char odebug; char frame = fun->u.f.locals != 0 || odebug; - emit(ADDR, fun->name); + code(ADDR, fun->name); if (frame) { - emit(PUSH, IX); - emit(LD, IX, SP); - emit(LDI, HL, -fun->u.f.locals); - emit(ADD, HL, SP); - emit(LD, SP, HL); + code(PUSH, IX); + code(LD, IX, SP); + code(LDI, HL, -fun->u.f.locals); + code(ADD, HL, SP); + code(LD, SP, HL); } apply(fun->u.f.body, cgen); if (frame) { - emit(LD, SP, IX); - emit(POP, IX); - emit(RET); + code(LD, SP, IX); + code(POP, IX); + code(RET); } } diff --git a/cc2/code.c b/cc2/code.c @@ -23,7 +23,7 @@ static char *regnames[] = { }; void -emit(char op, ...) +code(char op, ...) { va_list va; uint8_t reg1, reg2;