[hackers] [scc] [cc2-qbe] Add type in function parameters || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 2 Jun 2016 14:51:17 +0200 (CEST)

commit dd20c9cb3f57b3af3bc1f6ecc088fdb214fdd4f8
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jun 2 14:50:07 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Jun 2 14:50:07 2016 +0200

    [cc2-qbe] Add type in function parameters
    
    This was the last point missed in function calls, and after this point
    we can generate beatiful programs that will do something interesting.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 769f67c..472b81a 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -266,7 +266,9 @@ call(Node *np)
 
         for (q = pars; q < &pars[n]; ++q) {
                 op = (q == &pars[n-1]) ? ASPARE : ASPAR;
- code(op, NULL, *q, NULL);
+ p = newnode(OTMP);
+ p->type = (*q)->type;
+ code(op, NULL, *q, tmpnode(p));
         }
         code(ASCALL, NULL, NULL, NULL);
 
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 5c6a220..5ec388e 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -133,8 +133,8 @@ static struct opdata {
         [ASCALLL] = {.fun = call, .letter = 'l'},
         [ASCALLD] = {.fun = call, .letter = 'd'},
         [ASCALL] = {.fun = ecall},
- [ASPAR] = {.fun = param, .txt = "\t\t%s,\n"},
- [ASPARE] = {.fun = param, .txt = "\t\t%s\n"},
+ [ASPAR] = {.fun = param, .txt = "\t\t%s %s,\n"},
+ [ASPARE] = {.fun = param, .txt = "\t\t%s %s\n"},
 };
 
 static char buff[ADDR_LEN];
_AT_@ -421,7 +421,10 @@ call(void)
 static void
 param(void)
 {
- printf(optbl[pc->op].txt, addr2txt(&pc->from1));
+ Symbol *sym = pc->from2.u.sym;
+
+ printf(optbl[pc->op].txt,
+ size2asm(&sym->type), addr2txt(&pc->from1));
 }
 
 static void
Received on Thu Jun 02 2016 - 14:51:17 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 02 2016 - 15:00:19 CEST