scc

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

commit 54e5f131aa340b2ad1ff8bf2cc23024029fa8b50
parent 1fb38e3bfef9e594f46b257c63ed0acb6c9a1cba
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 17 Mar 2015 14:42:51 +0000

Inver switch order in moveto()

This new order will be better if we want to mark the register as used,
because the work done depends of the size.

Diffstat:
Mcc2/cgen.c | 27+++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -1,5 +1,4 @@ -#include <assert.h> #include <stdarg.h> #include <inttypes.h> #include <stdlib.h> @@ -126,31 +125,31 @@ allocreg(Node *np) static void moveto(Node *np, uint8_t reg) { - Symbol *sym; + Symbol *sym = np->sym; + char op = np->op; - switch (np->op) { - case CONST: - switch (np->type.size) { - case 1: - case 2: + switch (np->type.size) { + case 1: + switch (op) { + case CONST: code(LDI, regs[reg], np); break; + case AUTO: + code(LDL, regs[reg], np); + break; default: abort(); } break; - case AUTO: - sym = np->sym; - switch (np->type.size) { - case 1: + case 2: + switch (op) { + case CONST: code(LDL, regs[reg], np); break; - case 2: + case AUTO: code(LDL, regs[lower[reg]], np); code(LDH, regs[upper[reg]], np); break; - case 4: - case 8: default: abort(); }