scc

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

commit 05bdb414f7c5f42f335679f0c3461c391e0ed20c
parent 4d656cc381de1f2573bfc90a74a878a00f95148d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 17 Mar 2015 06:38:22 +0000

Remove type parameter from imm()

At this point we only support integer constant, so it is a bit
stupid this additional parameter. In some moment we will have
to include other types, but for sure we will have to create
new functions.

Diffstat:
cc2/cc2.h | 2+-
cc2/cgen.c | 2+-
cc2/parser.c | 26+++++++++++++-------------
3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/cc2/cc2.h b/cc2/cc2.h @@ -147,4 +147,4 @@ extern void writeout(void); /* optm.c */ extern void optimize(void); -extern Node *imm(TINT i, Type *tp); +extern Node *imm(TINT i); diff --git a/cc2/cgen.c b/cc2/cgen.c @@ -375,7 +375,7 @@ generate(void) code(PUSH, NULL, &reg_IX); code(MOV, &reg_IX, &reg_SP); if (size > 6) { - code(MOV, &reg_HL, imm(-size, &l_int16)); + code(MOV, &reg_HL, imm(-size)); code(ADD, &reg_HL, &reg_SP); code(MOV, &reg_SP, &reg_HL); } else { diff --git a/cc2/parser.c b/cc2/parser.c @@ -25,18 +25,18 @@ static Node *listexp[NR_EXPRESSIONS], **listp; static Node nodepool[NR_NODEPOOL], *newp; -Type Funct = { +static Type Funct = { .letter = L_FUNCTION, }; -Type l_int8 = { +static Type l_int8 = { .letter = L_INT8, .size = 1, .align = 2, .flags = SIGNF | INTF }; -Type l_int16 = { +static Type l_int16 = { .letter = L_INT16, .size = 2, .align = 2, @@ -44,7 +44,7 @@ Type l_int16 = { }; -Type l_int32 = { +static Type l_int32 = { .letter = L_INT32, .size = 4, .align = 4, @@ -52,7 +52,7 @@ Type l_int32 = { }; -Type l_int64 = { +static Type l_int64 = { .letter = L_INT64, .size = 8, .align = 8, @@ -60,28 +60,28 @@ Type l_int64 = { }; -Type l_uint8 = { +static Type l_uint8 = { .letter = L_UINT8, .size = 1, .align = 2, .flags = INTF }; -Type l_uint16 = { +static Type l_uint16 = { .letter = L_UINT16, .size = 2, .align = 2, .flags = INTF }; -Type l_uint32 = { +static Type l_uint32 = { .letter = L_UINT32, .size = 4, .align = 4, .flags = INTF }; -Type l_uint64 = { +static Type l_uint64 = { .letter = L_UINT64, .size = 8, .align = 8, @@ -227,14 +227,13 @@ newnode(void) return newp++; } - Node * -imm(TINT i, Type *tp) +imm(TINT i) { Node *np = newnode(); np->op = CONST; - np->type = *tp; + np->type = l_int16; /* TODO: assign the integer to something */ np->left = np->right = NULL; } @@ -327,7 +326,8 @@ paramvar(char *token) static void immediate(char *token) { - push(imm(atoi(token+2), gettype(token+1))); + /* TODO: check type of immediate */ + push(imm(atoi(token+2))); } static void