[hackers] [scc/qbe] [cc2-qbe] Convert bool() into void || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 12 Aug 2016 11:17:59 +0200 (CEST)

commit 72e5cb42ece0bd4ad683ee463496d8cbf5458df9
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jul 18 18:22:09 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jul 18 18:22:09 2016 +0200

    [cc2-qbe] Convert bool() into void
    
    Bool() is used for control flow code, and it is a
    non sense to return some value there, because we
    already have rhs() for that.

diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 3a97a63..5144fd8 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -177,36 +177,35 @@ lhs(Node *np, Node *new)
         }
 }
 
-static Node *
-bool(Node *np, Node *new, Symbol *true, Symbol *false)
+static void
+bool(Node *np, Symbol *true, Symbol *false)
 {
         Node *l = np->left, *r = np->right;
- Node *ifyes, *ifno;
+ Node ret, *ifyes, *ifno;
         Symbol *label;
 
         switch (np->op) {
         case OAND:
                 label = newlabel();
- bool(l, new, label, true);
+ bool(l, label, true);
                 setlabel(label);
- bool(r, new, true, false);
+ bool(r, true, false);
                 break;
         case OOR:
                 label = newlabel();
- bool(l, new, true, label);
+ bool(l, true, label);
                 setlabel(label);
- bool(r, new, true, false);
+ bool(r, true, false);
                 break;
         default:
                 ifyes = label2node(true);
                 ifno = label2node(false);
- rhs(l, new);
- code(ASBRANCH, new, ifyes, ifno);
+ rhs(l, &ret);
+ code(ASBRANCH, &ret, ifyes, ifno);
                 deltree(ifyes);
                 deltree(ifno);
                 break;
         }
- return new;
 }
 
 static Node *
_AT_@ -259,7 +258,7 @@ rhs(Node *np, Node *ret)
         case OOR:
                 true = newlabel();
                 false = newlabel();
- bool(np, ret, true, false);
+ bool(np, true, false);
                 setlabel(true);
                 setlabel(false);
                 return ret;
_AT_@ -336,7 +335,7 @@ cgen(Node *np)
                         next->label = newlabel();
                 ifyes = label2node(np->u.sym);
                 ifno = label2node(next->label);
- bool(np->left, &n, ifyes->u.sym, ifno->u.sym);
+ bool(np->left, ifyes->u.sym, ifno->u.sym);
                 code(ASBRANCH, &n, ifyes, ifno);
                 setlabel(ifyes->u.sym);
                 setlabel(ifno->u.sym);
Received on Fri Aug 12 2016 - 11:17:59 CEST

This archive was generated by hypermail 2.3.0 : Fri Aug 12 2016 - 11:24:18 CEST