Commit 5afce0ca authored by Kai Backman's avatar Kai Backman

64 bit cmp and some sgen tweaks

go/test: passes 75% (256/339)

R=rsc
APPROVED=rsc
DELTA=142  (53 added, 4 deleted, 85 changed)
OCL=35367
CL=35375
parent d58b5fca
...@@ -880,6 +880,25 @@ bgen(Node *n, int true, Prog *to) ...@@ -880,6 +880,25 @@ bgen(Node *n, int true, Prog *to)
break; break;
} }
if(is64(nr->type)) {
if(!nl->addable) {
tempalloc(&n1, nl->type);
cgen(nl, &n1);
nl = &n1;
}
if(!nr->addable) {
tempalloc(&n2, nr->type);
cgen(nr, &n2);
nr = &n2;
}
cmp64(nl, nr, a, to);
if(nr == &n2)
tempfree(&n2);
if(nl == &n1)
tempfree(&n1);
break;
}
a = optoas(a, nr->type); a = optoas(a, nr->type);
if(nr->ullman >= UINF) { if(nr->ullman >= UINF) {
...@@ -988,18 +1007,21 @@ sgen(Node *n, Node *res, int32 w) ...@@ -988,18 +1007,21 @@ sgen(Node *n, Node *res, int32 w)
if(osrc % 4 != 0 || odst %4 != 0) if(osrc % 4 != 0 || odst %4 != 0)
fatal("sgen: non word(4) aligned offset src %d or dst %d", osrc, odst); fatal("sgen: non word(4) aligned offset src %d or dst %d", osrc, odst);
regalloc(&dst, types[tptr], N); regalloc(&dst, types[tptr], res);
regalloc(&src, types[tptr], N);
regalloc(&tmp, types[TUINT32], N);
if(n->ullman >= res->ullman) { if(n->ullman >= res->ullman) {
agen(n, &src); agen(n, &dst);
regalloc(&src, types[tptr], N);
gins(AMOVW, &dst, &src);
agen(res, &dst); agen(res, &dst);
} else { } else {
agen(res, &dst); agen(res, &dst);
regalloc(&src, types[tptr], N);
agen(n, &src); agen(n, &src);
} }
regalloc(&tmp, types[TUINT32], N);
c = w % 4; // bytes c = w % 4; // bytes
q = w / 4; // quads q = w / 4; // quads
......
...@@ -458,86 +458,84 @@ cgen64(Node *n, Node *res) ...@@ -458,86 +458,84 @@ cgen64(Node *n, Node *res)
void void
cmp64(Node *nl, Node *nr, int op, Prog *to) cmp64(Node *nl, Node *nr, int op, Prog *to)
{ {
fatal("cmp64 not implemented"); Node lo1, hi1, lo2, hi2, r1, r2;
// Node lo1, hi1, lo2, hi2, rr; Prog *br;
// Prog *br; Type *t;
// Type *t;
split64(nl, &lo1, &hi1);
// split64(nl, &lo1, &hi1); split64(nr, &lo2, &hi2);
// split64(nr, &lo2, &hi2);
// compare most significant word;
// // compare most significant word; // if they differ, we're done.
// // if they differ, we're done. t = hi1.type;
// t = hi1.type; regalloc(&r1, types[TINT32], N);
// if(nl->op == OLITERAL || nr->op == OLITERAL) regalloc(&r2, types[TINT32], N);
// gins(ACMPL, &hi1, &hi2); gins(AMOVW, &hi1, &r1);
// else { gins(AMOVW, &hi2, &r2);
// regalloc(&rr, types[TINT32], N); gcmp(ACMP, &r1, &r2);
// gins(AMOVL, &hi1, &rr); regfree(&r1);
// gins(ACMPL, &rr, &hi2); regfree(&r2);
// regfree(&rr);
// } br = P;
// br = P; switch(op) {
// switch(op) { default:
// default: fatal("cmp64 %O %T", op, t);
// fatal("cmp64 %O %T", op, t); case OEQ:
// case OEQ: // cmp hi
// // cmp hi // bne L
// // jne L // cmp lo
// // cmp lo // beq to
// // jeq to // L:
// // L: br = gbranch(ABNE, T);
// br = gbranch(AJNE, T); break;
// break; case ONE:
// case ONE: // cmp hi
// // cmp hi // bne to
// // jne to // cmp lo
// // cmp lo // bne to
// // jne to patch(gbranch(ABNE, T), to);
// patch(gbranch(AJNE, T), to); break;
// break; case OGE:
// case OGE: case OGT:
// case OGT: // cmp hi
// // cmp hi // bgt to
// // jgt to // blt L
// // jlt L // cmp lo
// // cmp lo // bge to (or bgt to)
// // jge to (or jgt to) // L:
// // L: patch(gbranch(optoas(OGT, t), T), to);
// patch(gbranch(optoas(OGT, t), T), to); br = gbranch(optoas(OLT, t), T);
// br = gbranch(optoas(OLT, t), T); break;
// break; case OLE:
// case OLE: case OLT:
// case OLT: // cmp hi
// // cmp hi // blt to
// // jlt to // bgt L
// // jgt L // cmp lo
// // cmp lo // ble to (or jlt to)
// // jle to (or jlt to) // L:
// // L: patch(gbranch(optoas(OLT, t), T), to);
// patch(gbranch(optoas(OLT, t), T), to); br = gbranch(optoas(OGT, t), T);
// br = gbranch(optoas(OGT, t), T); break;
// break; }
// }
// compare least significant word
// // compare least significant word t = lo1.type;
// t = lo1.type; regalloc(&r1, types[TINT32], N);
// if(nl->op == OLITERAL || nr->op == OLITERAL) regalloc(&r2, types[TINT32], N);
// gins(ACMPL, &lo1, &lo2); gins(AMOVW, &lo1, &r1);
// else { gins(AMOVW, &lo2, &r2);
// regalloc(&rr, types[TINT32], N); gcmp(ACMP, &r1, &r2);
// gins(AMOVL, &lo1, &rr); regfree(&r1);
// gins(ACMPL, &rr, &lo2); regfree(&r2);
// regfree(&rr);
// } // jump again
patch(gbranch(optoas(op, t), T), to);
// // jump again
// patch(gbranch(optoas(op, t), T), to); // point first branch down here if appropriate
if(br != P)
// // point first branch down here if appropriate patch(br, pc);
// if(br != P)
// patch(br, pc); splitclean();
splitclean();
// splitclean();
// splitclean();
} }
...@@ -202,7 +202,19 @@ afunclit(Addr *a) ...@@ -202,7 +202,19 @@ afunclit(Addr *a)
void void
regalloc(Node *n, Type *t, Node *o) regalloc(Node *n, Type *t, Node *o)
{ {
int i, et; int i, et, fixfree, floatfree;
if(debug['r']) {
fixfree = 0;
for(i=REGALLOC_R0; i<=REGALLOC_RMAX; i++)
if(reg[i] == 0)
fixfree++;
floatfree = 0;
for(i=REGALLOC_F0; i<=REGALLOC_FMAX; i++)
if(reg[i] == 0)
floatfree++;
print("regalloc fix %d float %d\n", fixfree, floatfree);
}
if(t == T) if(t == T)
fatal("regalloc: t nil"); fatal("regalloc: t nil");
...@@ -259,7 +271,19 @@ out: ...@@ -259,7 +271,19 @@ out:
void void
regfree(Node *n) regfree(Node *n)
{ {
int i; int i, fixfree, floatfree;
if(debug['r']) {
fixfree = 0;
for(i=REGALLOC_R0; i<=REGALLOC_RMAX; i++)
if(reg[i] == 0)
fixfree++;
floatfree = 0;
for(i=REGALLOC_F0; i<=REGALLOC_FMAX; i++)
if(reg[i] == 0)
floatfree++;
print("regalloc fix %d float %d\n", fixfree, floatfree);
}
if(n->op != OREGISTER && n->op != OINDREG) if(n->op != OREGISTER && n->op != OINDREG)
fatal("regfree: not a register"); fatal("regfree: not a register");
...@@ -1098,7 +1122,7 @@ optoas(int op, Type *t) ...@@ -1098,7 +1122,7 @@ optoas(int op, Type *t)
a = AGOK; a = AGOK;
switch(CASE(op, simtype[t->etype])) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry %O-%T", op, t); fatal("optoas: no entry %O-%T etype %T simtype %T", op, t, types[t->etype], types[simtype[t->etype]]);
break; break;
/* case CASE(OADDR, TPTR32): /* case CASE(OADDR, TPTR32):
......
64bit.go 64bit.go
assign.go assign.go
bigalg.go
blank1.go blank1.go
bugs/bug136.go bugs/bug136.go
bugs/bug162.go bugs/bug162.go
...@@ -34,6 +35,7 @@ fixedbugs/bug005.go ...@@ -34,6 +35,7 @@ fixedbugs/bug005.go
fixedbugs/bug007.go fixedbugs/bug007.go
fixedbugs/bug008.go fixedbugs/bug008.go
fixedbugs/bug009.go fixedbugs/bug009.go
fixedbugs/bug012.go
fixedbugs/bug013.go fixedbugs/bug013.go
fixedbugs/bug014.go fixedbugs/bug014.go
fixedbugs/bug015.go fixedbugs/bug015.go
...@@ -86,6 +88,7 @@ fixedbugs/bug080.go ...@@ -86,6 +88,7 @@ fixedbugs/bug080.go
fixedbugs/bug081.go fixedbugs/bug081.go
fixedbugs/bug082.go fixedbugs/bug082.go
fixedbugs/bug083.go fixedbugs/bug083.go
fixedbugs/bug084.go
fixedbugs/bug085.go fixedbugs/bug085.go
fixedbugs/bug086.go fixedbugs/bug086.go
fixedbugs/bug087.go fixedbugs/bug087.go
...@@ -204,6 +207,7 @@ indirect.go ...@@ -204,6 +207,7 @@ indirect.go
indirect1.go indirect1.go
initcomma.go initcomma.go
initializerr.go initializerr.go
intcvt.go
interface/convert.go interface/convert.go
interface/convert1.go interface/convert1.go
interface/convert2.go interface/convert2.go
...@@ -219,6 +223,7 @@ iota.go ...@@ -219,6 +223,7 @@ iota.go
ken/complit.go ken/complit.go
ken/embed.go ken/embed.go
ken/for.go ken/for.go
ken/interbasic.go
ken/interfun.go ken/interfun.go
ken/intervar.go ken/intervar.go
ken/label.go ken/label.go
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment