ref: 05bdb414f7c5f42f335679f0c3461c391e0ed20c
parent: 4d656cc381de1f2573bfc90a74a878a00f95148d
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Mar 17 02:38:22 EDT 2015
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.
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
@@ -147,4 +147,4 @@
/* optm.c */
extern void optimize(void);
-extern Node *imm(TINT i, Type *tp);
+extern Node *imm(TINT i);
--- a/cc2/cgen.c
+++ b/cc2/cgen.c
@@ -375,7 +375,7 @@
code(PUSH, NULL, ®_IX);
code(MOV, ®_IX, ®_SP);
if (size > 6) {
- code(MOV, ®_HL, imm(-size, &l_int16));
+ code(MOV, ®_HL, imm(-size));
code(ADD, ®_HL, ®_SP);
code(MOV, ®_SP, ®_HL);
} else {
--- a/cc2/parser.c
+++ b/cc2/parser.c
@@ -25,11 +25,11 @@
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,
@@ -36,7 +36,7 @@
.flags = SIGNF | INTF
};
-Type l_int16 = {
+static Type l_int16 = {
.letter = L_INT16,
.size = 2,
.align = 2,
@@ -44,7 +44,7 @@
};
-Type l_int32 = {
+static Type l_int32 = {
.letter = L_INT32,
.size = 4,
.align = 4,
@@ -52,7 +52,7 @@
};
-Type l_int64 = {
+static Type l_int64 = {
.letter = L_INT64,
.size = 8,
.align = 8,
@@ -60,7 +60,7 @@
};
-Type l_uint8 = {
+static Type l_uint8 = {
.letter = L_UINT8,
.size = 1,
.align = 2,
@@ -67,7 +67,7 @@
.flags = INTF
};
-Type l_uint16 = {
+static Type l_uint16 = {
.letter = L_UINT16,
.size = 2,
.align = 2,
@@ -74,7 +74,7 @@
.flags = INTF
};
-Type l_uint32 = {
+static Type l_uint32 = {
.letter = L_UINT32,
.size = 4,
.align = 4,
@@ -81,7 +81,7 @@
.flags = INTF
};
-Type l_uint64 = {
+static Type l_uint64 = {
.letter = L_UINT64,
.size = 8,
.align = 8,
@@ -227,14 +227,13 @@
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 @@
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