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)
if(nl != N && isfloat[n->type->etype] && isfloat[nl->type->etype])
goto flt;
switch(n->op) {
default:
dump("cgen", n);
......@@ -252,6 +251,7 @@ cgen(Node *n, Node *res)
cgen(nl, res);
break;
}
mgen(nl, &n1, res);
gmove(&n1, res);
mfree(&n1);
......@@ -886,7 +886,7 @@ bgen(Node *n, int true, Prog *to)
regfree(&n1);
break;
}
if(isinter(nl->type)) {
// front end shold only leave cmp to literal nil
if((a != OEQ && a != ONE) || nr->op != OLITERAL) {
......@@ -1010,6 +1010,7 @@ stkof(Node *n)
/*
* block copy:
* memmove(&res, &n, w);
* NB: character copy assumed little endian architecture
*/
void
sgen(Node *n, Node *res, int32 w)
......@@ -1136,8 +1137,42 @@ sgen(Node *n, Node *res, int32 w)
q--;
}
if (c != 0)
fatal("sgen: character copy not implemented");
if (c != 0) {
// 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(&src);
......
This diff is collapsed.
......@@ -514,7 +514,7 @@ splitclean(void)
void
gmove(Node *f, Node *t)
{
int a, ft, tt;
int a, ft, tt, fa, ta;
Type *cvt;
Node r1, r2, flo, fhi, tlo, thi, con;
Prog *p1;
......@@ -526,9 +526,9 @@ gmove(Node *f, Node *t)
tt = simsimtype(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.
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;
// convert constant to desired type
......@@ -538,10 +538,6 @@ gmove(Node *f, Node *t)
convconst(&con, t->type, &f->val);
break;
case TFLOAT32:
convconst(&con, types[TFLOAT64], &f->val);
break;
case TINT16:
case TINT8:
convconst(&con, types[TINT32], &f->val);
......@@ -752,8 +748,10 @@ gmove(Node *f, Node *t)
case CASE(TFLOAT32, TUINT8):
case CASE(TFLOAT32, TUINT16):
case CASE(TFLOAT32, TUINT32):
fa = AMOVF;
a = AMOVFW;
break;
ta = AMOVW;
goto fltconv;
case CASE(TFLOAT64, TINT8):
case CASE(TFLOAT64, TINT16):
......@@ -761,14 +759,14 @@ gmove(Node *f, Node *t)
case CASE(TFLOAT64, TUINT8):
case CASE(TFLOAT64, TUINT16):
case CASE(TFLOAT64, TUINT32):
fa = AMOVD;
a = AMOVDW;
break;
ta = AMOVW;
goto fltconv;
case CASE(TFLOAT32, TINT64):
case CASE(TFLOAT32, TUINT64):
case CASE(TFLOAT64, TINT64):
case CASE(TFLOAT64, TUINT64):
fatal("gmove TFLOAT, INT64 not implemented");
fatal("gmove TFLOAT, UINT64 not implemented");
return;
/*
......@@ -780,8 +778,10 @@ gmove(Node *f, Node *t)
case CASE(TUINT8, TFLOAT32):
case CASE(TUINT16, TFLOAT32):
case CASE(TUINT32, TFLOAT32):
fa = AMOVW;
a = AMOVWF;
break;
ta = AMOVF;
goto fltconv;
case CASE(TINT8, TFLOAT64):
case CASE(TINT16, TFLOAT64):
......@@ -789,14 +789,14 @@ gmove(Node *f, Node *t)
case CASE(TUINT8, TFLOAT64):
case CASE(TUINT16, TFLOAT64):
case CASE(TUINT32, TFLOAT64):
fa = AMOVW;
a = AMOVWD;
break;
ta = AMOVW;
goto fltconv;;
case CASE(TINT64, TFLOAT32):
case CASE(TINT64, TFLOAT64):
case CASE(TUINT64, TFLOAT32):
case CASE(TUINT64, TFLOAT64):
fatal("gmove INT64, TFLOAT not implemented");
fatal("gmove UINT64, TFLOAT not implemented");
return;
......@@ -812,12 +812,20 @@ gmove(Node *f, Node *t)
break;
case CASE(TFLOAT32, TFLOAT64):
a = AMOVFD;
break;
regalloc(&r1, types[TFLOAT64], t);
gins(AMOVF, f, &r1);
gins(AMOVFD, &r1, &r1);
gins(AMOVD, &r1, t);
regfree(&r1);
return;
case CASE(TFLOAT64, TFLOAT32):
a = AMOVDF;
break;
regalloc(&r1, types[TFLOAT64], t);
gins(AMOVD, f, &r1);
gins(AMOVDF, &r1, &r1);
gins(AMOVF, &r1, t);
regfree(&r1);
return;
}
gins(a, f, t);
......@@ -835,7 +843,7 @@ rdst:
hard:
// requires register intermediate
regalloc(&r1, cvt, N);
regalloc(&r1, cvt, t);
gmove(f, &r1);
gmove(&r1, t);
regfree(&r1);
......@@ -851,6 +859,16 @@ trunc64:
splitclean();
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:
// should not happen
fatal("gmove %N -> %N", f, t);
......
......@@ -21,7 +21,7 @@ chmod +x $GOBIN/quietgcc
# 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/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
# pkg/hash
# pkg/math
......
......@@ -9,7 +9,6 @@ bugs/bug169.go
bugs/bug190.go
bugs/bug193.go
bugs/bug196.go
bugs/bug198.go
chan/perm.go
char_lit.go
cmp1.go
......@@ -38,6 +37,8 @@ fixedbugs/bug006.go
fixedbugs/bug007.go
fixedbugs/bug008.go
fixedbugs/bug009.go
fixedbugs/bug010.go
fixedbugs/bug011.go
fixedbugs/bug012.go
fixedbugs/bug013.go
fixedbugs/bug014.go
......@@ -62,6 +63,7 @@ fixedbugs/bug039.go
fixedbugs/bug040.go
fixedbugs/bug045.go
fixedbugs/bug046.go
fixedbugs/bug047.go
fixedbugs/bug048.go
fixedbugs/bug049.go
fixedbugs/bug050.go
......@@ -193,6 +195,7 @@ fixedbugs/bug192.go
fixedbugs/bug194.go
fixedbugs/bug195.go
fixedbugs/bug197.go
fixedbugs/bug198.go
fixedbugs/bug199.go
fixedbugs/bug200.go
fixedbugs/bug201.go
......@@ -201,7 +204,11 @@ fixedbugs/bug203.go
fixedbugs/bug204.go
fixedbugs/bug205.go
fixedbugs/bug206.go
fixedbugs/bug208.go
fixedbugs/bug209.go
float_lit.go
for.go
func.go
func1.go
func2.go
func3.go
......@@ -247,6 +254,7 @@ ken/ptrvar.go
ken/rob1.go
ken/rob2.go
ken/robfor.go
ken/robfunc.go
ken/robif.go
ken/shift.go
ken/simpbool.go
......@@ -259,10 +267,12 @@ method.go
method1.go
method2.go
method3.go
named.go
named1.go
nil.go
parentype.go
printbig.go
rename.go
rename1.go
sieve.go
sigchld.go
......@@ -271,4 +281,5 @@ string_lit.go
switch.go
switch1.go
test0.go
typeswitch.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