Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions sys/src/cmd/1c/cgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,14 @@ lcgen(Node *n, int result, Node *nn)
}

void
bcgen(Node *n, int True)
bcgen(Node *n, int cond)
{

boolgen(n, True, D_NONE, Z, Z);
boolgen(n, cond, D_NONE, Z, Z);
}

void
boolgen(Node *n, int True, int result, Node *nn, Node *post)
boolgen(Node *n, int cond, int result, Node *nn, Node *post)
{
Prog *p1, *p2;
Node *l, *r;
Expand Down Expand Up @@ -985,7 +985,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)

case OCONST:
fp = vconst(n);
if(!True)
if(!cond)
fp = !fp;
gbranch(OGOTO);
if(fp) {
Expand All @@ -996,7 +996,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case ONOT:
boolgen(l, !True, result, nn, post);
boolgen(l, !cond, result, nn, post);
break;

case OCOND:
Expand All @@ -1006,15 +1006,15 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)

inargs++;
doinc(r->left, PRE);
boolgen(r->left, True, result, nn, r->left);
boolgen(r->left, cond, result, nn, r->left);
if(result != D_NONE) {
doinc(r->left, POST);
gbranch(OGOTO);
patch(p1, pc);
p1 = p;

doinc(r->right, PRE);
boolgen(r->right, !True, result, nn, r->right);
boolgen(r->right, !cond, result, nn, r->right);
doinc(r->right, POST);
patch(p1, pc);
inargs--;
Expand All @@ -1026,7 +1026,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
p1 = p;

doinc(r->right, PRE);
boolgen(r->right, !True, result, nn, r->right);
boolgen(r->right, !cond, result, nn, r->right);
patch(p2, pc);
p2 = p;
if(doinc(post, POST|TEST)) {
Expand All @@ -1043,16 +1043,16 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case OANDAND:
if(!True)
if(!cond)
goto caseor;

caseand:
doinc(l, PRE);
boolgen(l, True, D_NONE, Z, l);
boolgen(l, cond, D_NONE, Z, l);
p1 = p;
inargs++;
doinc(r, PRE);
boolgen(r, !True, D_NONE, Z, r);
boolgen(r, !cond, D_NONE, Z, r);
p2 = p;
patch(p1, pc);
gbranch(OGOTO);
Expand All @@ -1061,16 +1061,16 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case OOROR:
if(!True)
if(!cond)
goto caseand;

caseor:
doinc(l, PRE);
boolgen(l, !True, D_NONE, Z, l);
boolgen(l, !cond, D_NONE, Z, l);
p1 = p;
inargs++;
doinc(r, PRE);
boolgen(r, !True, D_NONE, Z, r);
boolgen(r, !cond, D_NONE, Z, r);
p2 = p;
gbranch(OGOTO);
patch(p1, pc);
Expand All @@ -1082,10 +1082,10 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
case ONE:
if(vconst(l) == 0) {
if(n->op == ONE) {
boolgen(r, True, result, nn, post);
boolgen(r, cond, result, nn, post);
break;
}
boolgen(r, !True, result, nn, post);
boolgen(r, !cond, result, nn, post);
break;
}

Expand Down Expand Up @@ -1143,7 +1143,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
regfree(rg);

genbool:
if(True)
if(cond)
o = comrel[relindex(o)];
if(doinc(post, POST|TEST)) {
lg = regalloc(types[TSHORT], D_NONE);
Expand Down
34 changes: 17 additions & 17 deletions sys/src/cmd/2c/cgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,14 +953,14 @@ lcgen(Node *n, int result, Node *nn)
}

void
bcgen(Node *n, int True)
bcgen(Node *n, int cond)
{

boolgen(n, True, D_NONE, Z, Z);
boolgen(n, cond, D_NONE, Z, Z);
}

void
boolgen(Node *n, int True, int result, Node *nn, Node *post)
boolgen(Node *n, int cond, int result, Node *nn, Node *post)
{
Prog *p1, *p2;
Node *l, *r;
Expand Down Expand Up @@ -993,7 +993,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)

case OCONST:
fp = vconst(n);
if(!True)
if(!cond)
fp = !fp;
gbranch(OGOTO);
if(fp) {
Expand All @@ -1004,7 +1004,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case ONOT:
boolgen(l, !True, result, nn, post);
boolgen(l, !cond, result, nn, post);
break;

case OCOND:
Expand All @@ -1014,15 +1014,15 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)

inargs++;
doinc(r->left, PRE);
boolgen(r->left, True, result, nn, r->left);
boolgen(r->left, cond, result, nn, r->left);
if(result != D_NONE) {
doinc(r->left, POST);
gbranch(OGOTO);
patch(p1, pc);
p1 = p;

doinc(r->right, PRE);
boolgen(r->right, !True, result, nn, r->right);
boolgen(r->right, !cond, result, nn, r->right);
doinc(r->right, POST);
patch(p1, pc);
inargs--;
Expand All @@ -1034,7 +1034,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
p1 = p;

doinc(r->right, PRE);
boolgen(r->right, !True, result, nn, r->right);
boolgen(r->right, !cond, result, nn, r->right);
patch(p2, pc);
p2 = p;
if(doinc(post, POST|TEST)) {
Expand All @@ -1051,16 +1051,16 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case OANDAND:
if(!True)
if(!cond)
goto caseor;

caseand:
doinc(l, PRE);
boolgen(l, True, D_NONE, Z, l);
boolgen(l, cond, D_NONE, Z, l);
p1 = p;
inargs++;
doinc(r, PRE);
boolgen(r, !True, D_NONE, Z, r);
boolgen(r, !cond, D_NONE, Z, r);
p2 = p;
patch(p1, pc);
gbranch(OGOTO);
Expand All @@ -1069,16 +1069,16 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
goto com;

case OOROR:
if(!True)
if(!cond)
goto caseand;

caseor:
doinc(l, PRE);
boolgen(l, !True, D_NONE, Z, l);
boolgen(l, !cond, D_NONE, Z, l);
p1 = p;
inargs++;
doinc(r, PRE);
boolgen(r, !True, D_NONE, Z, r);
boolgen(r, !cond, D_NONE, Z, r);
p2 = p;
gbranch(OGOTO);
patch(p1, pc);
Expand All @@ -1090,10 +1090,10 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
case ONE:
if(vconst(l) == 0) {
if(n->op == ONE) {
boolgen(r, True, result, nn, post);
boolgen(r, cond, result, nn, post);
break;
}
boolgen(r, !True, result, nn, post);
boolgen(r, !cond, result, nn, post);
break;
}

Expand Down Expand Up @@ -1151,7 +1151,7 @@ boolgen(Node *n, int True, int result, Node *nn, Node *post)
regfree(rg);

genbool:
if(True)
if(cond)
o = comrel[relindex(o)];
if(doinc(post, POST|TEST)) {
lg = regalloc(types[TSHORT], D_NONE);
Expand Down
42 changes: 21 additions & 21 deletions sys/src/cmd/5c/cgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -722,17 +722,17 @@ lcgen(Node *n, Node *nn)
}

void
bcgen(Node *n, int true)
bcgen(Node *n, int cond)
{

if(n->type == T)
gbranch(OGOTO);
else
boolgen(n, true, Z);
boolgen(n, cond, Z);
}

void
boolgen(Node *n, int true, Node *nn)
boolgen(Node *n, int cond, Node *nn)
{
int o;
Prog *p1, *p2;
Expand All @@ -752,12 +752,12 @@ boolgen(Node *n, int true, Node *nn)
regalloc(&nod, n, nn);
cgen(n, &nod);
o = ONE;
if(true)
if(cond)
o = comrel[relindex(o)];
if(typefd[n->type->etype]){
regalloc(&nod1, n, Z);
gmove(nodfconst(0.0), &nod1);
gopcode(true ? o | BTRUE : o, &nod1, &nod, Z);
gopcode(cond ? o | BTRUE : o, &nod1, &nod, Z);
regfree(&nod1);
}else
gopcode(o, nodconst(0), &nod, Z);
Expand All @@ -766,7 +766,7 @@ boolgen(Node *n, int true, Node *nn)

case OCONST:
o = vconst(n);
if(!true)
if(!cond)
o = !o;
gbranch(OGOTO);
if(o) {
Expand All @@ -778,22 +778,22 @@ boolgen(Node *n, int true, Node *nn)

case OCOMMA:
cgen(l, Z);
boolgen(r, true, nn);
boolgen(r, cond, nn);
break;

case ONOT:
boolgen(l, !true, nn);
boolgen(l, !cond, nn);
break;

case OCOND:
bcgen(l, 1);
p1 = p;
bcgen(r->left, true);
bcgen(r->left, cond);
p2 = p;
gbranch(OGOTO);
patch(p1, pc);
p1 = p;
bcgen(r->right, !true);
bcgen(r->right, !cond);
patch(p2, pc);
p2 = p;
gbranch(OGOTO);
Expand All @@ -802,27 +802,27 @@ boolgen(Node *n, int true, Node *nn)
goto com;

case OANDAND:
if(!true)
if(!cond)
goto caseor;

caseand:
bcgen(l, true);
bcgen(l, cond);
p1 = p;
bcgen(r, !true);
bcgen(r, !cond);
p2 = p;
patch(p1, pc);
gbranch(OGOTO);
patch(p2, pc);
goto com;

case OOROR:
if(!true)
if(!cond)
goto caseand;

caseor:
bcgen(l, !true);
bcgen(l, !cond);
p1 = p;
bcgen(r, !true);
bcgen(r, !cond);
p2 = p;
gbranch(OGOTO);
patch(p1, pc);
Expand All @@ -840,7 +840,7 @@ boolgen(Node *n, int true, Node *nn)
case OLO:
case OLS:
o = n->op;
if(true)
if(cond)
o = comrel[relindex(o)];
if(l->complex >= FNX && r->complex >= FNX) {
regret(&nod, r);
Expand All @@ -850,21 +850,21 @@ boolgen(Node *n, int true, Node *nn)
regfree(&nod);
nod = *n;
nod.right = &nod1;
boolgen(&nod, true, nn);
boolgen(&nod, cond, nn);
break;
}
if(sconst(l)) {
regalloc(&nod, r, nn);
cgenrel(r, &nod, 1);
o = invrel[relindex(o)];
gopcode(true ? o | BTRUE : o, l, &nod, Z);
gopcode(cond ? o | BTRUE : o, l, &nod, Z);
regfree(&nod);
goto com;
}
if(sconst(r)) {
regalloc(&nod, l, nn);
cgenrel(l, &nod, 1);
gopcode(true ? o | BTRUE : o, r, &nod, Z);
gopcode(cond ? o | BTRUE : o, r, &nod, Z);
regfree(&nod);
goto com;
}
Expand All @@ -879,7 +879,7 @@ boolgen(Node *n, int true, Node *nn)
regalloc(&nod1, l, Z);
cgenrel(l, &nod1, 1);
}
gopcode(true ? o | BTRUE : o, &nod, &nod1, Z);
gopcode(cond ? o | BTRUE : o, &nod, &nod1, Z);
regfree(&nod);
regfree(&nod1);

Expand Down
Loading
Loading