commit 125b59ccfb603cfc41c009ef1b5724dd98cc4efa
Author:     Roberto E. Vargas Caballero <[email protected]>
AuthorDate: Fri Apr 22 15:43:13 2016 +0200
Commit:     Roberto E. Vargas Caballero <[email protected]>
CommitDate: Fri Apr 22 15:43:13 2016 +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.

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index c0c87e5..c117945 100644
--- 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
index faf2e92..5bd31e4 100644
--- 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
index 2d1a1ff..147a76a 100644
--- 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
index a288da4..c85b281 100644
--- 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)

Reply via email to