scc

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

commit 125b59ccfb603cfc41c009ef1b5724dd98cc4efa
parent 71ca53670b19bf2bfcf6fa63824095fb9780b771
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 22 Apr 2016 15:43:13 +0200

[cc2] Remove rtype field from Type

We are going ot have only one rtype at the same time,
because it is the return type of the current function,
so it is a bit stupid to waste 2/4/8 bytes of every symbol
for this.

Diffstat:
Mcc2/arch/qbe/code.c | 2+-
Mcc2/cc2.h | 2+-
Mcc2/node.c | 1+
Mcc2/parser.c | 2+-
4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c @@ -276,7 +276,7 @@ writeout(void) if (curfun->kind == SGLOB) fputs("export ", stdout); - printf("function %s %s(", size2asm(&curfun->rtype), symname(curfun)); + printf("function %s %s(", size2asm(&rtype), symname(curfun)); /* declare formal parameters */ for (sep = "", p = locals; p; p = p->next, sep = ",") { diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -132,7 +132,6 @@ struct type { struct symbol { Type type; - Type rtype; unsigned short id; unsigned short numid; char *name; @@ -217,6 +216,7 @@ extern void pushctx(void); extern void freesym(Symbol *sym); /* globals */ +extern Type rtype; extern Symbol *curfun; extern Symbol *locals; extern Inst *pc, *prog; diff --git a/cc2/node.c b/cc2/node.c @@ -10,6 +10,7 @@ #define NNODES 32 Symbol *curfun; +Type rtype; struct arena { Node *mem; diff --git a/cc2/parser.c b/cc2/parser.c @@ -537,7 +537,7 @@ vardecl(void) sym->name = name; sym->type = *tp; if (tp->flags & FUNF) - sym->rtype = *rp; + rtype = *rp; sym->kind = sclass; if (ininit)