diff --git a/src/cmd/5g/galign.c b/src/cmd/5g/galign.c index 0708042179..1fbf633f90 100644 --- a/src/cmd/5g/galign.c +++ b/src/cmd/5g/galign.c @@ -27,6 +27,7 @@ void betypeinit(void) { widthptr = 4; + widthint = 4; zprog.link = P; zprog.as = AGOK; diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c index 89d35450e0..ce3a3eba9a 100644 --- a/src/cmd/6g/cgen.c +++ b/src/cmd/6g/cgen.c @@ -309,7 +309,7 @@ cgen(Node *n, Node *res) case OLEN: if(istype(nl->type, TMAP) || istype(nl->type, TCHAN)) { - // map and chan have len in the first 32-bit word. + // map and chan have len in the first int-sized word. // a zero pointer means zero length regalloc(&n1, types[tptr], res); cgen(nl, &n1); @@ -320,7 +320,7 @@ cgen(Node *n, Node *res) n2 = n1; n2.op = OINDREG; - n2.type = types[TINT32]; + n2.type = types[simtype[TINT]]; gmove(&n2, &n1); patch(p1, pc); @@ -333,7 +333,7 @@ cgen(Node *n, Node *res) // both slice and string have len one pointer into the struct. // a zero pointer means zero length igen(nl, &n1, res); - n1.type = types[TUINT32]; + n1.type = types[simtype[TUINT]]; n1.xoffset += Array_nel; gmove(&n1, res); regfree(&n1); @@ -344,7 +344,7 @@ cgen(Node *n, Node *res) case OCAP: if(istype(nl->type, TCHAN)) { - // chan has cap in the second 32-bit word. + // chan has cap in the second int-sized word. // a zero pointer means zero length regalloc(&n1, types[tptr], res); cgen(nl, &n1); @@ -355,8 +355,8 @@ cgen(Node *n, Node *res) n2 = n1; n2.op = OINDREG; - n2.xoffset = 4; - n2.type = types[TINT32]; + n2.xoffset = widthint; + n2.type = types[simtype[TINT]]; gmove(&n2, &n1); patch(p1, pc); @@ -367,7 +367,7 @@ cgen(Node *n, Node *res) } if(isslice(nl->type)) { igen(nl, &n1, res); - n1.type = types[TUINT32]; + n1.type = types[simtype[TUINT]]; n1.xoffset += Array_cap; gmove(&n1, res); regfree(&n1); @@ -596,7 +596,7 @@ agen(Node *n, Node *res) nlen.type = types[tptr]; nlen.xoffset += Array_array; gmove(&nlen, &n3); - nlen.type = types[TUINT32]; + nlen.type = types[simtype[TUINT]]; nlen.xoffset += Array_nel-Array_array; } } @@ -621,7 +621,7 @@ agen(Node *n, Node *res) nlen.type = types[tptr]; nlen.xoffset += Array_array; gmove(&nlen, &n3); - nlen.type = types[TUINT32]; + nlen.type = types[simtype[TUINT]]; nlen.xoffset += Array_nel-Array_array; } } @@ -656,9 +656,9 @@ agen(Node *n, Node *res) v = mpgetfix(nr->val.u.xval); if(isslice(nl->type) || nl->type->etype == TSTRING) { if(!debug['B'] && !n->bounded) { - nodconst(&n2, types[TUINT32], v); - gins(optoas(OCMP, types[TUINT32]), &nlen, &n2); - p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1); + nodconst(&n2, types[simtype[TUINT]], v); + gins(optoas(OCMP, types[simtype[TUINT]]), &nlen, &n2); + p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1); ginscall(panicindex, -1); patch(p1, pc); } @@ -683,7 +683,7 @@ agen(Node *n, Node *res) if(!debug['B'] && !n->bounded) { // check bounds - t = types[TUINT32]; + t = types[simtype[TUINT]]; if(is64(nr->type)) t = types[TUINT64]; if(isconst(nl, CTSTR)) { @@ -1350,7 +1350,7 @@ componentgen(Node *nr, Node *nl) gmove(&nodr, &nodl); nodl.xoffset += Array_nel-Array_array; - nodl.type = types[TUINT32]; + nodl.type = types[simtype[TUINT]]; if(nr != N) { nodr.xoffset += Array_nel-Array_array; @@ -1360,7 +1360,7 @@ componentgen(Node *nr, Node *nl) gmove(&nodr, &nodl); nodl.xoffset += Array_cap-Array_nel; - nodl.type = types[TUINT32]; + nodl.type = types[simtype[TUINT]]; if(nr != N) { nodr.xoffset += Array_cap-Array_nel; @@ -1383,7 +1383,7 @@ componentgen(Node *nr, Node *nl) gmove(&nodr, &nodl); nodl.xoffset += Array_nel-Array_array; - nodl.type = types[TUINT32]; + nodl.type = types[simtype[TUINT]]; if(nr != N) { nodr.xoffset += Array_nel-Array_array; diff --git a/src/cmd/6g/galign.c b/src/cmd/6g/galign.c index b03ac1ed67..a5d10eb575 100644 --- a/src/cmd/6g/galign.c +++ b/src/cmd/6g/galign.c @@ -27,6 +27,7 @@ void betypeinit(void) { widthptr = 8; + widthint = 4; zprog.link = P; zprog.as = AGOK; diff --git a/src/cmd/6g/gg.h b/src/cmd/6g/gg.h index 4073e228c6..4cca99d5b9 100644 --- a/src/cmd/6g/gg.h +++ b/src/cmd/6g/gg.h @@ -21,7 +21,7 @@ struct Addr Sym* gotype; Sym* sym; Node* node; - int width; + int64 width; uchar type; uchar index; uchar etype; diff --git a/src/cmd/6g/gobj.c b/src/cmd/6g/gobj.c index 8c9208374a..07ee32d6a2 100644 --- a/src/cmd/6g/gobj.c +++ b/src/cmd/6g/gobj.c @@ -312,8 +312,8 @@ datastring(char *s, int len, Addr *a) a->type = D_EXTERN; a->sym = sym; a->node = sym->def; - a->offset = widthptr+4; // skip header - a->etype = TINT32; + a->offset = widthptr+widthint; // skip header + a->etype = simtype[TINT]; } /* @@ -324,7 +324,7 @@ void datagostring(Strlit *sval, Addr *a) { Sym *sym; - + sym = stringsym(sval->s, sval->len); a->type = D_EXTERN; a->sym = sym; @@ -386,10 +386,10 @@ gdatastring(Node *nam, Strlit *sval) p->to.type = D_ADDR; //print("%P\n", p); - nodconst(&nod1, types[TINT32], sval->len); + nodconst(&nod1, types[TINT], sval->len); p = gins(ADATA, nam, &nod1); - p->from.scale = types[TINT32]->width; - p->from.offset += types[tptr]->width; + p->from.scale = widthint; + p->from.offset += widthptr; } int @@ -408,7 +408,7 @@ dstringptr(Sym *s, int off, char *str) datastring(str, strlen(str)+1, &p->to); p->to.index = p->to.type; p->to.type = D_ADDR; - p->to.etype = TINT32; + p->to.etype = simtype[TINT]; off += widthptr; return off; @@ -432,7 +432,7 @@ dgostrlitptr(Sym *s, int off, Strlit *lit) datagostring(lit, &p->to); p->to.index = p->to.type; p->to.type = D_ADDR; - p->to.etype = TINT32; + p->to.etype = simtype[TINT]; off += widthptr; return off; diff --git a/src/cmd/6g/gsubr.c b/src/cmd/6g/gsubr.c index ea64b8821d..638ba4add6 100644 --- a/src/cmd/6g/gsubr.c +++ b/src/cmd/6g/gsubr.c @@ -1247,9 +1247,9 @@ naddr(Node *n, Addr *a, int canemitcode) naddr(n->left, a, canemitcode); if(a->type == D_CONST && a->offset == 0) break; // len(nil) - a->etype = TUINT32; + a->etype = simtype[TUINT]; a->offset += Array_nel; - a->width = 4; + a->width = widthint; if(a->offset >= unmappedzero && a->offset-Array_nel < unmappedzero) checkoffset(a, canemitcode); break; @@ -1259,9 +1259,9 @@ naddr(Node *n, Addr *a, int canemitcode) naddr(n->left, a, canemitcode); if(a->type == D_CONST && a->offset == 0) break; // cap(nil) - a->etype = TUINT32; + a->etype = simtype[TUINT]; a->offset += Array_cap; - a->width = 4; + a->width = widthint; if(a->offset >= unmappedzero && a->offset-Array_cap < unmappedzero) checkoffset(a, canemitcode); break; @@ -2086,12 +2086,12 @@ oindex: if(!debug['B'] && !n->bounded) { // check bounds n4.op = OXXX; - t = types[TUINT32]; + t = types[simtype[TUINT]]; if(o & ODynam) { if(o & OAddable) { n2 = *l; n2.xoffset += Array_nel; - n2.type = types[TUINT32]; + n2.type = types[simtype[TUINT]]; if(is64(r->type)) { t = types[TUINT64]; regalloc(&n4, t, N); @@ -2102,7 +2102,7 @@ oindex: n2 = *reg; n2.xoffset = Array_nel; n2.op = OINDREG; - n2.type = types[TUINT32]; + n2.type = types[simtype[TUINT]]; if(is64(r->type)) { t = types[TUINT64]; regalloc(&n4, t, N); @@ -2180,8 +2180,8 @@ oindex_const: n1.type = types[tptr]; n1.xoffset = Array_nel; nodconst(&n2, types[TUINT64], v); - gins(optoas(OCMP, types[TUINT32]), &n1, &n2); - p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1); + gins(optoas(OCMP, types[simtype[TUINT]]), &n1, &n2); + p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1); ginscall(panicindex, -1); patch(p1, pc); } @@ -2223,9 +2223,9 @@ oindex_const_sudo: if(!debug['B'] && !n->bounded) { a->offset += Array_nel; nodconst(&n2, types[TUINT64], v); - p1 = gins(optoas(OCMP, types[TUINT32]), N, &n2); + p1 = gins(optoas(OCMP, types[simtype[TUINT]]), N, &n2); p1->from = *a; - p1 = gbranch(optoas(OGT, types[TUINT32]), T, +1); + p1 = gbranch(optoas(OGT, types[simtype[TUINT]]), T, +1); ginscall(panicindex, -1); patch(p1, pc); a->offset -= Array_nel; diff --git a/src/cmd/6g/reg.c b/src/cmd/6g/reg.c index a139b1caa3..3352895e75 100644 --- a/src/cmd/6g/reg.c +++ b/src/cmd/6g/reg.c @@ -945,7 +945,8 @@ Bits mkvar(Reg *r, Adr *a) { Var *v; - int i, t, n, et, z, w, flag; + int i, t, n, et, z, flag; + int64 w; uint32 regu; int32 o; Bits bit; @@ -998,7 +999,7 @@ mkvar(Reg *r, Adr *a) o = a->offset; w = a->width; if(w < 0) - fatal("bad width %d for %D", w, a); + fatal("bad width %lld for %D", w, a); flag = 0; for(i=0; iwidth); - Array_cap = rnd(Array_nel+types[TUINT32]->width, types[TUINT32]->width); - sizeof_Array = rnd(Array_cap+types[TUINT32]->width, widthptr); + Array_nel = rnd(Array_array+widthptr, widthint); + Array_cap = rnd(Array_nel+widthint, widthint); + sizeof_Array = rnd(Array_cap+widthint, widthptr); // string is same as slice wo the cap - sizeof_String = rnd(Array_nel+types[TUINT32]->width, widthptr); + sizeof_String = rnd(Array_nel+widthint, widthptr); dowidth(types[TSTRING]); dowidth(idealstring); diff --git a/src/cmd/gc/gen.c b/src/cmd/gc/gen.c index 9b667775eb..7801415677 100644 --- a/src/cmd/gc/gen.c +++ b/src/cmd/gc/gen.c @@ -763,7 +763,7 @@ cgen_eface(Node *n, Node *res) * generate: * res = s[lo, hi]; * n->left is s - * n->list is (cap(s)-lo(TUINT32), hi-lo(TUINT32)[, lo*width(TUINTPTR)]) + * n->list is (cap(s)-lo(TUINT), hi-lo(TUINT)[, lo*width(TUINTPTR)]) * caller (cgen) guarantees res is an addable ONAME. */ void @@ -780,14 +780,14 @@ cgen_slice(Node *n, Node *res) // dst.len = hi [ - lo ] dst = *res; dst.xoffset += Array_nel; - dst.type = types[TUINT32]; + dst.type = types[simtype[TUINT]]; cgen(len, &dst); if(n->op != OSLICESTR) { // dst.cap = cap [ - lo ] dst = *res; dst.xoffset += Array_cap; - dst.type = types[TUINT32]; + dst.type = types[simtype[TUINT]]; cgen(cap, &dst); } diff --git a/src/cmd/gc/go.h b/src/cmd/gc/go.h index 37ed4fa0da..89b91f6665 100644 --- a/src/cmd/gc/go.h +++ b/src/cmd/gc/go.h @@ -905,6 +905,7 @@ EXTERN int hasdefer; // flag that curfn has defer statetment EXTERN Node* curfn; EXTERN int widthptr; +EXTERN int widthint; EXTERN Node* typesw; EXTERN Node* nblank; diff --git a/src/cmd/gc/obj.c b/src/cmd/gc/obj.c index 8094671cb2..6f7098dd4e 100644 --- a/src/cmd/gc/obj.c +++ b/src/cmd/gc/obj.c @@ -302,8 +302,8 @@ stringsym(char *s, int len) off = 0; // string header - off = dsymptr(sym, off, sym, widthptr+4); - off = duint32(sym, off, len); + off = dsymptr(sym, off, sym, widthptr+widthint); + off = duintxx(sym, off, len, widthint); // string data for(n=0; nlink) { @@ -780,13 +780,13 @@ ok: // two slice headers: in and out. ot = rnd(ot, widthptr); - ot = dsymptr(s, ot, s, ot+2*(widthptr+2*4)); + ot = dsymptr(s, ot, s, ot+2*(widthptr+2*widthint)); n = t->thistuple + t->intuple; - ot = duint32(s, ot, n); - ot = duint32(s, ot, n); - ot = dsymptr(s, ot, s, ot+1*(widthptr+2*4)+n*widthptr); - ot = duint32(s, ot, t->outtuple); - ot = duint32(s, ot, t->outtuple); + ot = duintxx(s, ot, n, widthint); + ot = duintxx(s, ot, n, widthint); + ot = dsymptr(s, ot, s, ot+1*(widthptr+2*widthint)+n*widthptr); + ot = duintxx(s, ot, t->outtuple, widthint); + ot = duintxx(s, ot, t->outtuple, widthint); // slice data for(t1=getthisx(t)->type; t1; t1=t1->down, n++) @@ -808,9 +808,9 @@ ok: // ../../pkg/runtime/type.go:/InterfaceType ot = dcommontype(s, ot, t); xt = ot - 2*widthptr; - ot = dsymptr(s, ot, s, ot+widthptr+2*4); - ot = duint32(s, ot, n); - ot = duint32(s, ot, n); + ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); + ot = duintxx(s, ot, n, widthint); + ot = duintxx(s, ot, n, widthint); for(a=m; a; a=a->link) { // ../../pkg/runtime/type.go:/imethod ot = dgostringptr(s, ot, a->name); @@ -853,9 +853,9 @@ ok: } ot = dcommontype(s, ot, t); xt = ot - 2*widthptr; - ot = dsymptr(s, ot, s, ot+widthptr+2*4); - ot = duint32(s, ot, n); - ot = duint32(s, ot, n); + ot = dsymptr(s, ot, s, ot+widthptr+2*widthint); + ot = duintxx(s, ot, n, widthint); + ot = duintxx(s, ot, n, widthint); for(t1=t->type; t1!=T; t1=t1->down) { // ../../pkg/runtime/type.go:/structField if(t1->sym && !t1->embedded) { diff --git a/src/cmd/gc/runtime.go b/src/cmd/gc/runtime.go index 7ab24a0440..28c6b44bc6 100644 --- a/src/cmd/gc/runtime.go +++ b/src/cmd/gc/runtime.go @@ -46,8 +46,6 @@ func appendstr(typ *byte, x []byte, y string) []byte func cmpstring(string, string) int func eqstring(string, string) bool -func slicestring(string, int, int) string -func slicestring1(string, int) string func intstring(int64) string func slicebytetostring([]byte) string func slicerunetostring([]rune) string @@ -55,7 +53,7 @@ func stringtoslicebyte(string) []byte func stringtoslicerune(string) []rune func stringiter(string, int) int func stringiter2(string, int) (retk int, retv rune) -func copy(to any, fr any, wid uint32) int +func copy(to any, fr any, wid uintptr) int func slicestringcopy(to any, fr any) int // interface conversions @@ -109,7 +107,7 @@ func selectnbsend(chanType *byte, hchan chan<- any, elem any) bool func selectnbrecv(chanType *byte, elem *any, hchan <-chan any) bool func selectnbrecv2(chanType *byte, elem *any, received *bool, hchan <-chan any) bool -func newselect(size int) (sel *byte) +func newselect(size int32) (sel *byte) func selectsend(sel *byte, hchan chan<- any, elem *any) (selected bool) func selectrecv(sel *byte, hchan <-chan any, elem *any) (selected bool) func selectrecv2(sel *byte, hchan <-chan any, elem *any, received *bool) (selected bool) diff --git a/src/cmd/gc/sinit.c b/src/cmd/gc/sinit.c index 1ee1696fee..8e943e45a1 100644 --- a/src/cmd/gc/sinit.c +++ b/src/cmd/gc/sinit.c @@ -300,9 +300,9 @@ staticcopy(Node *l, Node *r, NodeList **out) n1.xoffset = l->xoffset + Array_array; gdata(&n1, nod(OADDR, a, N), widthptr); n1.xoffset = l->xoffset + Array_nel; - gdata(&n1, r->right, 4); + gdata(&n1, r->right, widthint); n1.xoffset = l->xoffset + Array_cap; - gdata(&n1, r->right, 4); + gdata(&n1, r->right, widthint); return 1; } // fall through @@ -403,9 +403,9 @@ staticassign(Node *l, Node *r, NodeList **out) n1.xoffset = l->xoffset + Array_array; gdata(&n1, nod(OADDR, a, N), widthptr); n1.xoffset = l->xoffset + Array_nel; - gdata(&n1, r->right, 4); + gdata(&n1, r->right, widthint); n1.xoffset = l->xoffset + Array_cap; - gdata(&n1, r->right, 4); + gdata(&n1, r->right, widthint); // Fall through to init underlying array. l = a; } @@ -1232,11 +1232,11 @@ slice: gdata(&nam, nl, types[tptr]->width); nam.xoffset += Array_nel-Array_array; - nodconst(&nod1, types[TINT32], nr->type->bound); - gdata(&nam, &nod1, types[TINT32]->width); + nodconst(&nod1, types[TINT], nr->type->bound); + gdata(&nam, &nod1, widthint); nam.xoffset += Array_cap-Array_nel; - gdata(&nam, &nod1, types[TINT32]->width); + gdata(&nam, &nod1, widthint); goto yes; diff --git a/src/cmd/gc/walk.c b/src/cmd/gc/walk.c index c6b7e4278f..9e6d57c860 100644 --- a/src/cmd/gc/walk.c +++ b/src/cmd/gc/walk.c @@ -2496,7 +2496,7 @@ sliceany(Node* n, NodeList **init) chk1 = N; chk2 = N; - bt = types[TUINT32]; + bt = types[simtype[TUINT]]; if(hb != N && hb->type->width > 4) bt = types[TUINT64]; if(lb != N && lb->type->width > 4) @@ -2546,18 +2546,18 @@ sliceany(Node* n, NodeList **init) n->right = N; n->list = nil; if(lb == N) - bound = conv(bound, types[TUINT32]); + bound = conv(bound, types[simtype[TUINT]]); else - bound = nod(OSUB, conv(bound, types[TUINT32]), conv(lb, types[TUINT32])); + bound = nod(OSUB, conv(bound, types[simtype[TUINT]]), conv(lb, types[simtype[TUINT]])); typecheck(&bound, Erv); walkexpr(&bound, init); n->list = list(n->list, bound); // len = hi [ - lo] if(lb == N) - hb = conv(hb, types[TUINT32]); + hb = conv(hb, types[simtype[TUINT]]); else - hb = nod(OSUB, conv(hb, types[TUINT32]), conv(lb, types[TUINT32])); + hb = nod(OSUB, conv(hb, types[simtype[TUINT]]), conv(lb, types[simtype[TUINT]])); typecheck(&hb, Erv); walkexpr(&hb, init); n->list = list(n->list, hb);