scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit a0862978b0a1d5c876db7839cc6905b749291640
parent 84977e24ad1f367840d132c50b89d090a275ecbc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  7 Aug 2015 17:28:17 +0200

Move storage IR representation to cc.h

Diffstat:
cc1/code.c | 11+++++------
inc/cc.h | 7+++++++
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/cc1/code.c b/cc1/code.c @@ -147,22 +147,21 @@ emit(unsigned op, void *arg) (*opcode[op])(op, arg); } -/* TODO: move these letters to cc.h */ static void emitvar(Symbol *sym) { char c; if (sym->flags & ISSTATIC) - c = (sym->flags & ISGLOBAL) ? 'Y' : 'T'; + c = (sym->flags & ISGLOBAL) ? L_PRIVATE : L_STATIC; else if (sym->flags & ISGLOBAL) - c = 'G'; + c = L_PUBLIC; else if (sym->flags & ISREGISTER) - c = 'R'; + c = L_REGISTER; else if (sym->flags & ISFIELD) - c = 'M'; + c = L_FIELD; else - c = 'A'; + c = L_AUTO; printf("%c%d", c, sym->id); } diff --git a/inc/cc.h b/inc/cc.h @@ -59,6 +59,13 @@ typedef unsigned bool; #define L_DOUBLE 'D' #define L_LDOUBLE 'H' +#define L_PUBLIC 'G' +#define L_PRIVATE 'Y' +#define L_STATIC 'T' +#define L_REGISTER 'R' +#define L_FIELD 'M' +#define L_AUTO 'A' + extern void die(const char *fmt, ...); extern void *xmalloc(size_t size); extern void *xcalloc(size_t nmemb, size_t size);