betypeinit(void)
{
widthptr = 4;
+ widthint = 4;
zprog.link = P;
zprog.as = AGOK;
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);
n2 = n1;
n2.op = OINDREG;
- n2.type = types[TINT32];
+ n2.type = types[simtype[TINT]];
gmove(&n2, &n1);
patch(p1, pc);
// 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);
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);
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);
}
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);
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;
}
}
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;
}
}
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);
}
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)) {
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;
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;
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;
betypeinit(void)
{
widthptr = 8;
+ widthint = 4;
zprog.link = P;
zprog.as = AGOK;
Sym* gotype;
Sym* sym;
Node* node;
- int width;
+ int64 width;
uchar type;
uchar index;
uchar etype;
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];
}
/*
datagostring(Strlit *sval, Addr *a)
{
Sym *sym;
-
+
sym = stringsym(sval->s, sval->len);
a->type = D_EXTERN;
a->sym = sym;
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
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;
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;
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;
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;
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);
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);
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);
}
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;
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;
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; i<nvar; i++) {
betypeinit(void)
{
widthptr = 4;
+ widthint = 4;
zprog.link = P;
zprog.as = AGOK;
}
Array_array = rnd(0, widthptr);
- Array_nel = rnd(Array_array+widthptr, types[TUINT32]->width);
- 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);
* 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
// 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);
}
EXTERN Node* curfn;
EXTERN int widthptr;
+EXTERN int widthint;
EXTERN Node* typesw;
EXTERN Node* nblank;
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; n<len; n+=m) {
}
// slice header
- 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);
// methods
for(a=m; a; a=a->link) {
// 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++)
// ../../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);
}
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) {
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
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
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)
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
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;
}
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;
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)
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);