[hackers] [scc] [cc2-qbe] Improve generation of or/and || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 3 Oct 2016 13:42:42 +0200 (CEST)

commit 6c048208cdea11ad20bb09c24363cf7065bdc217
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Oct 3 13:39:43 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Oct 3 13:39:43 2016 +0200

    [cc2-qbe] Improve generation of or/and
    
    Cgen() was calling rhs() to generate the code of the conditions
    in branches, but it is better to call to log(), because it
    already handles the case of having an expression.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 39ee9ec..425fd74 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -602,34 +602,30 @@ rhs(Node *np, Node *ret)
 Node *
 cgen(Node *np)
 {
- Node ret, aux1, aux2, *p, *next, ifyes, ifno;
+ Node aux, *p, *next;
 
         setlabel(np->label);
         switch (np->op) {
         case OJMP:
- label2node(&ifyes, np->u.sym);
- code(ASJMP, NULL, &ifyes, NULL);
+ label2node(&aux, np->u.sym);
+ code(ASJMP, NULL, &aux, NULL);
                 break;
         case OBRANCH:
                 next = np->next;
                 if (!next->label)
                         next->label = newlabel();
-
- label2node(&ifyes, np->u.sym);
- label2node(&ifno, next->label);
- rhs(np->left, &ret);
- code(ASBRANCH, &ret, &ifyes, &ifno);
+ bool(np->left, np->u.sym, next->label);
                 break;
         case ORET:
- p = (np->left) ? rhs(np->left, &ret) : NULL;
+ p = (np->left) ? rhs(np->left, &aux) : NULL;
                 code(ASRET, NULL, p, NULL);
                 break;
         case OBSWITCH:
- p = rhs(np->left, &ret);
+ p = rhs(np->left, &aux);
                 swtch_if(p);
                 break;
         default:
- rhs(np, &ret);
+ rhs(np, &aux);
                 break;
         }
         return NULL;
Received on Mon Oct 03 2016 - 13:42:42 CEST

This archive was generated by hypermail 2.3.0 : Mon Oct 03 2016 - 13:48:15 CEST