Commit 6d0983ae authored by Kai Backman's avatar Kai Backman

64bit and float code generation. fmt compiles but

reflect is broken so fmt doesn't work.

go/test: passes 83% (285/342)

R=rsc
APPROVED=rsc
DELTA=415  (240 added, 29 deleted, 146 changed)
OCL=35576
CL=35588
parent 64145109
...@@ -182,7 +182,6 @@ cgen(Node *n, Node *res) ...@@ -182,7 +182,6 @@ cgen(Node *n, Node *res)
if(nl != N && isfloat[n->type->etype] && isfloat[nl->type->etype]) if(nl != N && isfloat[n->type->etype] && isfloat[nl->type->etype])
goto flt; goto flt;
switch(n->op) { switch(n->op) {
default: default:
dump("cgen", n); dump("cgen", n);
...@@ -252,6 +251,7 @@ cgen(Node *n, Node *res) ...@@ -252,6 +251,7 @@ cgen(Node *n, Node *res)
cgen(nl, res); cgen(nl, res);
break; break;
} }
mgen(nl, &n1, res); mgen(nl, &n1, res);
gmove(&n1, res); gmove(&n1, res);
mfree(&n1); mfree(&n1);
...@@ -1010,6 +1010,7 @@ stkof(Node *n) ...@@ -1010,6 +1010,7 @@ stkof(Node *n)
/* /*
* block copy: * block copy:
* memmove(&res, &n, w); * memmove(&res, &n, w);
* NB: character copy assumed little endian architecture
*/ */
void void
sgen(Node *n, Node *res, int32 w) sgen(Node *n, Node *res, int32 w)
...@@ -1136,8 +1137,42 @@ sgen(Node *n, Node *res, int32 w) ...@@ -1136,8 +1137,42 @@ sgen(Node *n, Node *res, int32 w)
q--; q--;
} }
if (c != 0) if (c != 0) {
fatal("sgen: character copy not implemented"); // MOVW (src), tmp
p = gins(AMOVW, &src, &tmp);
p->from.type = D_OREG;
// MOVW tmp>>((4-c)*8),src
p = gins(AMOVW, N, &src);
p->from.type = D_SHIFT;
p->from.offset = SHIFT_LR | ((4-c)*8)<<7 | tmp.val.u.reg;
// MOVW src<<((4-c)*8),src
p = gins(AMOVW, N, &src);
p->from.type = D_SHIFT;
p->from.offset = SHIFT_LL | ((4-c)*8)<<7 | tmp.val.u.reg;
// MOVW (dst), tmp
p = gins(AMOVW, &dst, &tmp);
p->from.type = D_OREG;
// MOVW tmp<<(c*8),tmp
p = gins(AMOVW, N, &tmp);
p->from.type = D_SHIFT;
p->from.offset = SHIFT_LL | (c*8)<<7 | tmp.val.u.reg;
// MOVW tmp>>(c*8),tmp
p = gins(AMOVW, N, &tmp);
p->from.type = D_SHIFT;
p->from.offset = SHIFT_LR | (c*8)<<7 | tmp.val.u.reg;
// ORR src, tmp
gins(AORR, &src, &tmp);
// MOVW tmp, (dst)
p = gins(AMOVW, &tmp, &dst);
p->to.type = D_OREG;
}
} }
regfree(&dst); regfree(&dst);
regfree(&src); regfree(&src);
......
This diff is collapsed.
...@@ -514,7 +514,7 @@ splitclean(void) ...@@ -514,7 +514,7 @@ splitclean(void)
void void
gmove(Node *f, Node *t) gmove(Node *f, Node *t)
{ {
int a, ft, tt; int a, ft, tt, fa, ta;
Type *cvt; Type *cvt;
Node r1, r2, flo, fhi, tlo, thi, con; Node r1, r2, flo, fhi, tlo, thi, con;
Prog *p1; Prog *p1;
...@@ -526,9 +526,9 @@ gmove(Node *f, Node *t) ...@@ -526,9 +526,9 @@ gmove(Node *f, Node *t)
tt = simsimtype(t->type); tt = simsimtype(t->type);
cvt = t->type; cvt = t->type;
// cannot have two integer memory operands; // cannot have two memory operands;
// except 64-bit, which always copies via registers anyway. // except 64-bit, which always copies via registers anyway.
if(isint[ft] && isint[tt] && !is64(f->type) && !is64(t->type) && ismem(f) && ismem(t)) if(!is64(f->type) && !is64(t->type) && ismem(f) && ismem(t))
goto hard; goto hard;
// convert constant to desired type // convert constant to desired type
...@@ -538,10 +538,6 @@ gmove(Node *f, Node *t) ...@@ -538,10 +538,6 @@ gmove(Node *f, Node *t)
convconst(&con, t->type, &f->val); convconst(&con, t->type, &f->val);
break; break;
case TFLOAT32:
convconst(&con, types[TFLOAT64], &f->val);
break;
case TINT16: case TINT16:
case TINT8: case TINT8:
convconst(&con, types[TINT32], &f->val); convconst(&con, types[TINT32], &f->val);
...@@ -752,8 +748,10 @@ gmove(Node *f, Node *t) ...@@ -752,8 +748,10 @@ gmove(Node *f, Node *t)
case CASE(TFLOAT32, TUINT8): case CASE(TFLOAT32, TUINT8):
case CASE(TFLOAT32, TUINT16): case CASE(TFLOAT32, TUINT16):
case CASE(TFLOAT32, TUINT32): case CASE(TFLOAT32, TUINT32):
fa = AMOVF;
a = AMOVFW; a = AMOVFW;
break; ta = AMOVW;
goto fltconv;
case CASE(TFLOAT64, TINT8): case CASE(TFLOAT64, TINT8):
case CASE(TFLOAT64, TINT16): case CASE(TFLOAT64, TINT16):
...@@ -761,14 +759,14 @@ gmove(Node *f, Node *t) ...@@ -761,14 +759,14 @@ gmove(Node *f, Node *t)
case CASE(TFLOAT64, TUINT8): case CASE(TFLOAT64, TUINT8):
case CASE(TFLOAT64, TUINT16): case CASE(TFLOAT64, TUINT16):
case CASE(TFLOAT64, TUINT32): case CASE(TFLOAT64, TUINT32):
fa = AMOVD;
a = AMOVDW; a = AMOVDW;
break; ta = AMOVW;
goto fltconv;
case CASE(TFLOAT32, TINT64):
case CASE(TFLOAT32, TUINT64): case CASE(TFLOAT32, TUINT64):
case CASE(TFLOAT64, TINT64):
case CASE(TFLOAT64, TUINT64): case CASE(TFLOAT64, TUINT64):
fatal("gmove TFLOAT, INT64 not implemented"); fatal("gmove TFLOAT, UINT64 not implemented");
return; return;
/* /*
...@@ -780,8 +778,10 @@ gmove(Node *f, Node *t) ...@@ -780,8 +778,10 @@ gmove(Node *f, Node *t)
case CASE(TUINT8, TFLOAT32): case CASE(TUINT8, TFLOAT32):
case CASE(TUINT16, TFLOAT32): case CASE(TUINT16, TFLOAT32):
case CASE(TUINT32, TFLOAT32): case CASE(TUINT32, TFLOAT32):
fa = AMOVW;
a = AMOVWF; a = AMOVWF;
break; ta = AMOVF;
goto fltconv;
case CASE(TINT8, TFLOAT64): case CASE(TINT8, TFLOAT64):
case CASE(TINT16, TFLOAT64): case CASE(TINT16, TFLOAT64):
...@@ -789,14 +789,14 @@ gmove(Node *f, Node *t) ...@@ -789,14 +789,14 @@ gmove(Node *f, Node *t)
case CASE(TUINT8, TFLOAT64): case CASE(TUINT8, TFLOAT64):
case CASE(TUINT16, TFLOAT64): case CASE(TUINT16, TFLOAT64):
case CASE(TUINT32, TFLOAT64): case CASE(TUINT32, TFLOAT64):
fa = AMOVW;
a = AMOVWD; a = AMOVWD;
break; ta = AMOVW;
goto fltconv;;
case CASE(TINT64, TFLOAT32):
case CASE(TINT64, TFLOAT64):
case CASE(TUINT64, TFLOAT32): case CASE(TUINT64, TFLOAT32):
case CASE(TUINT64, TFLOAT64): case CASE(TUINT64, TFLOAT64):
fatal("gmove INT64, TFLOAT not implemented"); fatal("gmove UINT64, TFLOAT not implemented");
return; return;
...@@ -812,12 +812,20 @@ gmove(Node *f, Node *t) ...@@ -812,12 +812,20 @@ gmove(Node *f, Node *t)
break; break;
case CASE(TFLOAT32, TFLOAT64): case CASE(TFLOAT32, TFLOAT64):
a = AMOVFD; regalloc(&r1, types[TFLOAT64], t);
break; gins(AMOVF, f, &r1);
gins(AMOVFD, &r1, &r1);
gins(AMOVD, &r1, t);
regfree(&r1);
return;
case CASE(TFLOAT64, TFLOAT32): case CASE(TFLOAT64, TFLOAT32):
a = AMOVDF; regalloc(&r1, types[TFLOAT64], t);
break; gins(AMOVD, f, &r1);
gins(AMOVDF, &r1, &r1);
gins(AMOVF, &r1, t);
regfree(&r1);
return;
} }
gins(a, f, t); gins(a, f, t);
...@@ -835,7 +843,7 @@ rdst: ...@@ -835,7 +843,7 @@ rdst:
hard: hard:
// requires register intermediate // requires register intermediate
regalloc(&r1, cvt, N); regalloc(&r1, cvt, t);
gmove(f, &r1); gmove(f, &r1);
gmove(&r1, t); gmove(&r1, t);
regfree(&r1); regfree(&r1);
...@@ -851,6 +859,16 @@ trunc64: ...@@ -851,6 +859,16 @@ trunc64:
splitclean(); splitclean();
return; return;
fltconv:
regalloc(&r1, types[ft], f);
regalloc(&r2, types[tt], t);
gins(fa, f, &r1);
gins(a, &r1, &r2);
gins(ta, &r2, t);
regfree(&r1);
regfree(&r2);
return;
fatal: fatal:
// should not happen // should not happen
fatal("gmove %N -> %N", f, t); fatal("gmove %N -> %N", f, t);
......
...@@ -21,7 +21,7 @@ chmod +x $GOBIN/quietgcc ...@@ -21,7 +21,7 @@ chmod +x $GOBIN/quietgcc
# TODO(kaib): converge with normal build # TODO(kaib): converge with normal build
#for i in lib9 libbio libmach libregexp cmd pkg cmd/ebnflint cmd/godoc cmd/gofmt #for i in lib9 libbio libmach libregexp cmd pkg cmd/ebnflint cmd/godoc cmd/gofmt
for i in lib9 libbio libmach libregexp cmd pkg/runtime pkg/sync pkg/once pkg/syscall pkg/os pkg/unicode pkg/utf8 pkg/bytes pkg/strings pkg/io pkg/malloc pkg/time for i in lib9 libbio libmach libregexp cmd pkg/runtime pkg/sync pkg/once pkg/syscall pkg/os pkg/unicode pkg/utf8 pkg/bytes pkg/strings pkg/io pkg/malloc pkg/time pkg/math pkg/strconv pkg/reflect pkg/fmt pkg/bufio
#for i in lib9 libbio libmach libregexp cmd pkg/runtime pkg/sync pkg/once pkg/malloc pkg/sort pkg/unicode #for i in lib9 libbio libmach libregexp cmd pkg/runtime pkg/sync pkg/once pkg/malloc pkg/sort pkg/unicode
# pkg/hash # pkg/hash
# pkg/math # pkg/math
......
...@@ -9,7 +9,6 @@ bugs/bug169.go ...@@ -9,7 +9,6 @@ bugs/bug169.go
bugs/bug190.go bugs/bug190.go
bugs/bug193.go bugs/bug193.go
bugs/bug196.go bugs/bug196.go
bugs/bug198.go
chan/perm.go chan/perm.go
char_lit.go char_lit.go
cmp1.go cmp1.go
...@@ -38,6 +37,8 @@ fixedbugs/bug006.go ...@@ -38,6 +37,8 @@ fixedbugs/bug006.go
fixedbugs/bug007.go fixedbugs/bug007.go
fixedbugs/bug008.go fixedbugs/bug008.go
fixedbugs/bug009.go fixedbugs/bug009.go
fixedbugs/bug010.go
fixedbugs/bug011.go
fixedbugs/bug012.go fixedbugs/bug012.go
fixedbugs/bug013.go fixedbugs/bug013.go
fixedbugs/bug014.go fixedbugs/bug014.go
...@@ -62,6 +63,7 @@ fixedbugs/bug039.go ...@@ -62,6 +63,7 @@ fixedbugs/bug039.go
fixedbugs/bug040.go fixedbugs/bug040.go
fixedbugs/bug045.go fixedbugs/bug045.go
fixedbugs/bug046.go fixedbugs/bug046.go
fixedbugs/bug047.go
fixedbugs/bug048.go fixedbugs/bug048.go
fixedbugs/bug049.go fixedbugs/bug049.go
fixedbugs/bug050.go fixedbugs/bug050.go
...@@ -193,6 +195,7 @@ fixedbugs/bug192.go ...@@ -193,6 +195,7 @@ fixedbugs/bug192.go
fixedbugs/bug194.go fixedbugs/bug194.go
fixedbugs/bug195.go fixedbugs/bug195.go
fixedbugs/bug197.go fixedbugs/bug197.go
fixedbugs/bug198.go
fixedbugs/bug199.go fixedbugs/bug199.go
fixedbugs/bug200.go fixedbugs/bug200.go
fixedbugs/bug201.go fixedbugs/bug201.go
...@@ -201,7 +204,11 @@ fixedbugs/bug203.go ...@@ -201,7 +204,11 @@ fixedbugs/bug203.go
fixedbugs/bug204.go fixedbugs/bug204.go
fixedbugs/bug205.go fixedbugs/bug205.go
fixedbugs/bug206.go fixedbugs/bug206.go
fixedbugs/bug208.go
fixedbugs/bug209.go
float_lit.go
for.go for.go
func.go
func1.go func1.go
func2.go func2.go
func3.go func3.go
...@@ -247,6 +254,7 @@ ken/ptrvar.go ...@@ -247,6 +254,7 @@ ken/ptrvar.go
ken/rob1.go ken/rob1.go
ken/rob2.go ken/rob2.go
ken/robfor.go ken/robfor.go
ken/robfunc.go
ken/robif.go ken/robif.go
ken/shift.go ken/shift.go
ken/simpbool.go ken/simpbool.go
...@@ -259,10 +267,12 @@ method.go ...@@ -259,10 +267,12 @@ method.go
method1.go method1.go
method2.go method2.go
method3.go method3.go
named.go
named1.go named1.go
nil.go nil.go
parentype.go parentype.go
printbig.go printbig.go
rename.go
rename1.go rename1.go
sieve.go sieve.go
sigchld.go sigchld.go
...@@ -271,4 +281,5 @@ string_lit.go ...@@ -271,4 +281,5 @@ string_lit.go
switch.go switch.go
switch1.go switch1.go
test0.go test0.go
typeswitch.go
varinit.go varinit.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