[hackers] [scc] [cc1] Remove negate() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sat, 4 Feb 2017 21:58:35 +0100 (CET)

commit 7c9e9d8479731a93dbbd18a06877b32f282d113e
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Sat Feb 4 21:57:22 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Sat Feb 4 21:57:22 2017 +0100

    [cc1] Remove negate()
    
    This function remained from a time were cc1 had a different way
    (and wrong) of implementing negation. It is a non sense now.

diff --git a/cc1/expr.c b/cc1/expr.c
index 8442619..1d8925a 100644
--- a/cc1/expr.c
+++ b/cc1/expr.c
_AT_@ -408,57 +408,27 @@ negop(int op)
         return op;
 }
 
-Node *
-negate(Node *np)
-{
- int op = np->op;
-
- switch (np->op) {
- case OSYM:
- assert(np->flags&NCONST && np->type->prop&TINTEGER);
- np->sym = (np->sym->u.i) ? zero : one;
- break;
- case OOR:
- case OAND:
- if (np->op == ONEG) {
- Node *new = np->left;
- free(np);
- return new;
- }
- np = node(ONEG, inttype, np, NULL);
- break;
- case OEQ:
- case ONE:
- case OLT:
- case OGE:
- case OLE:
- case OGT:
- np->op = negop(op);
- break;
- default:
- abort();
- }
-
- return np;
-}
-
 static Node *
-exp2cond(Node *np, char neg)
+exp2cond(Node *np, int neg)
 {
         if (np->type->prop & TAGGREG) {
                 errorp("used struct/union type value where scalar is required");
                 return constnode(zero);
         }
         switch (np->op) {
+ case ONEG:
         case OOR:
         case OAND:
+ return node(ONEG, inttype, np, NULL);
         case OEQ:
         case ONE:
         case OLT:
         case OGE:
         case OLE:
         case OGT:
- return (neg) ? negate(np) : np;
+ if (neg)
+ np->op = negop(np->op);
+ return np;
         default:
                 return compare((neg) ? OEQ : ONE, np, constnode(zero));
         }
Received on Sat Feb 04 2017 - 21:58:35 CET

This archive was generated by hypermail 2.3.0 : Sat Feb 04 2017 - 22:00:25 CET