ref: fe2a918f1ec286a8d360d77643f1aae3e83a6848
parent: 8fdfb3f17b5a6bb6cfe3da6bf2f00145217912f8
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Feb 4 16:57:22 EST 2017
[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.
--- a/cc1/expr.c
+++ b/cc1/expr.c
@@ -408,42 +408,8 @@
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");
@@ -450,8 +416,10 @@
return constnode(zero);
}
switch (np->op) {
+ case ONEG:
case OOR:
case OAND:
+ return node(ONEG, inttype, np, NULL);
case OEQ:
case ONE:
case OLT:
@@ -458,7 +426,9 @@
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));
}