[hackers] [scc] [cc2] Remove rtype field from Type || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 22 Apr 2016 15:44:14 +0200 (CEST)

commit 125b59ccfb603cfc41c009ef1b5724dd98cc4efa
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Apr 22 15:43:13 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
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
_AT_@ -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
_AT_@ -132,7 +132,6 @@ struct type {
 
 struct symbol {
         Type type;
- Type rtype;
         unsigned short id;
         unsigned short numid;
         char *name;
_AT_@ -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
_AT_@ -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
_AT_@ -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)
Received on Fri Apr 22 2016 - 15:44:14 CEST

This archive was generated by hypermail 2.3.0 : Fri Apr 22 2016 - 15:48:20 CEST