Otherwise the exported variable collides with the type Arch.
While we're here, remove arch.dumpit (now in portable code)
and add arch.defframe (forgotten originally, somehow).
Change-Id: I1b3a7dd7e96c5f632dba7cd6c1217b42a2004d72
Reviewed-on: https://go-review.googlesource.com/4644
Reviewed-by: Austin Clements <austin@google.com>
void
main(int argc, char **argv)
{
- arch.thechar = thechar;
- arch.thestring = thestring;
- arch.thelinkarch = thelinkarch;
- arch.typedefs = typedefs;
- arch.REGSP = REGSP;
- arch.REGCTXT = REGCTXT;
- arch.MAXWIDTH = MAXWIDTH;
- arch.anyregalloc = anyregalloc;
- arch.betypeinit = betypeinit;
- arch.bgen = bgen;
- arch.cgen = cgen;
- arch.cgen_call = cgen_call;
- arch.cgen_callinter = cgen_callinter;
- arch.cgen_ret = cgen_ret;
- arch.clearfat = clearfat;
- arch.dumpit = dumpit;
- arch.excise = excise;
- arch.expandchecks = expandchecks;
- arch.gclean = gclean;
- arch.ginit = ginit;
- arch.gins = gins;
- arch.ginscall = ginscall;
- arch.igen = igen;
- arch.linkarchinit = linkarchinit;
- arch.peep = peep;
- arch.proginfo = proginfo;
- arch.regalloc = regalloc;
- arch.regfree = regfree;
- arch.regtyp = regtyp;
- arch.sameaddr = sameaddr;
- arch.smallindir = smallindir;
- arch.stackaddr = stackaddr;
- arch.excludedregs = excludedregs;
- arch.RtoB = RtoB;
- arch.FtoB = RtoB;
- arch.BtoR = BtoR;
- arch.BtoF = BtoF;
- arch.optoas = optoas;
- arch.doregbits = doregbits;
- arch.regnames = regnames;
+ thearch.thechar = thechar;
+ thearch.thestring = thestring;
+ thearch.thelinkarch = thelinkarch;
+ thearch.typedefs = typedefs;
+ thearch.REGSP = REGSP;
+ thearch.REGCTXT = REGCTXT;
+ thearch.MAXWIDTH = MAXWIDTH;
+ thearch.anyregalloc = anyregalloc;
+ thearch.betypeinit = betypeinit;
+ thearch.bgen = bgen;
+ thearch.cgen = cgen;
+ thearch.cgen_call = cgen_call;
+ thearch.cgen_callinter = cgen_callinter;
+ thearch.cgen_ret = cgen_ret;
+ thearch.clearfat = clearfat;
+ thearch.defframe = defframe;
+ thearch.excise = excise;
+ thearch.expandchecks = expandchecks;
+ thearch.gclean = gclean;
+ thearch.ginit = ginit;
+ thearch.gins = gins;
+ thearch.ginscall = ginscall;
+ thearch.igen = igen;
+ thearch.linkarchinit = linkarchinit;
+ thearch.peep = peep;
+ thearch.proginfo = proginfo;
+ thearch.regalloc = regalloc;
+ thearch.regfree = regfree;
+ thearch.regtyp = regtyp;
+ thearch.sameaddr = sameaddr;
+ thearch.smallindir = smallindir;
+ thearch.stackaddr = stackaddr;
+ thearch.excludedregs = excludedregs;
+ thearch.RtoB = RtoB;
+ thearch.FtoB = RtoB;
+ thearch.BtoR = BtoR;
+ thearch.BtoF = BtoF;
+ thearch.optoas = optoas;
+ thearch.doregbits = doregbits;
+ thearch.regnames = regnames;
gcmain(argc, argv);
}
{
if(strcmp(getgoarch(), "amd64p32") == 0) {
thelinkarch = &linkamd64p32;
- arch.thelinkarch = thelinkarch;
+ thearch.thelinkarch = thelinkarch;
thestring = "amd64p32";
- arch.thestring = "amd64p32";
+ thearch.thestring = "amd64p32";
}
}
void
main(int argc, char **argv)
{
- arch.thechar = thechar;
- arch.thestring = thestring;
- arch.thelinkarch = thelinkarch;
- arch.typedefs = typedefs;
- arch.REGSP = REGSP;
- arch.REGCTXT = REGCTXT;
- arch.MAXWIDTH = MAXWIDTH;
- arch.anyregalloc = anyregalloc;
- arch.betypeinit = betypeinit;
- arch.bgen = bgen;
- arch.cgen = cgen;
- arch.cgen_call = cgen_call;
- arch.cgen_callinter = cgen_callinter;
- arch.cgen_ret = cgen_ret;
- arch.clearfat = clearfat;
- arch.dumpit = dumpit;
- arch.excise = excise;
- arch.expandchecks = expandchecks;
- arch.gclean = gclean;
- arch.ginit = ginit;
- arch.gins = gins;
- arch.ginscall = ginscall;
- arch.igen = igen;
- arch.linkarchinit = linkarchinit;
- arch.peep = peep;
- arch.proginfo = proginfo;
- arch.regalloc = regalloc;
- arch.regfree = regfree;
- arch.regtyp = regtyp;
- arch.sameaddr = sameaddr;
- arch.smallindir = smallindir;
- arch.stackaddr = stackaddr;
- arch.excludedregs = excludedregs;
- arch.RtoB = RtoB;
- arch.FtoB = FtoB;
- arch.BtoR = BtoR;
- arch.BtoF = BtoF;
- arch.optoas = optoas;
- arch.doregbits = doregbits;
- arch.regnames = regnames;
+ thearch.thechar = thechar;
+ thearch.thestring = thestring;
+ thearch.thelinkarch = thelinkarch;
+ thearch.typedefs = typedefs;
+ thearch.REGSP = REGSP;
+ thearch.REGCTXT = REGCTXT;
+ thearch.MAXWIDTH = MAXWIDTH;
+ thearch.anyregalloc = anyregalloc;
+ thearch.betypeinit = betypeinit;
+ thearch.bgen = bgen;
+ thearch.cgen = cgen;
+ thearch.cgen_call = cgen_call;
+ thearch.cgen_callinter = cgen_callinter;
+ thearch.cgen_ret = cgen_ret;
+ thearch.clearfat = clearfat;
+ thearch.defframe = defframe;
+ thearch.excise = excise;
+ thearch.expandchecks = expandchecks;
+ thearch.gclean = gclean;
+ thearch.ginit = ginit;
+ thearch.gins = gins;
+ thearch.ginscall = ginscall;
+ thearch.igen = igen;
+ thearch.linkarchinit = linkarchinit;
+ thearch.peep = peep;
+ thearch.proginfo = proginfo;
+ thearch.regalloc = regalloc;
+ thearch.regfree = regfree;
+ thearch.regtyp = regtyp;
+ thearch.sameaddr = sameaddr;
+ thearch.smallindir = smallindir;
+ thearch.stackaddr = stackaddr;
+ thearch.excludedregs = excludedregs;
+ thearch.RtoB = RtoB;
+ thearch.FtoB = FtoB;
+ thearch.BtoR = BtoR;
+ thearch.BtoF = BtoF;
+ thearch.optoas = optoas;
+ thearch.doregbits = doregbits;
+ thearch.regnames = regnames;
gcmain(argc, argv);
}
void
main(int argc, char **argv)
{
- arch.thechar = thechar;
- arch.thestring = thestring;
- arch.thelinkarch = thelinkarch;
- arch.typedefs = typedefs;
- arch.REGSP = REGSP;
- arch.REGCTXT = REGCTXT;
- arch.MAXWIDTH = MAXWIDTH;
- arch.anyregalloc = anyregalloc;
- arch.betypeinit = betypeinit;
- arch.bgen = bgen;
- arch.cgen = cgen;
- arch.cgen_call = cgen_call;
- arch.cgen_callinter = cgen_callinter;
- arch.cgen_ret = cgen_ret;
- arch.clearfat = clearfat;
- arch.dumpit = dumpit;
- arch.excise = excise;
- arch.expandchecks = expandchecks;
- arch.gclean = gclean;
- arch.ginit = ginit;
- arch.gins = gins;
- arch.ginscall = ginscall;
- arch.igen = igen;
- arch.linkarchinit = linkarchinit;
- arch.peep = peep;
- arch.proginfo = proginfo;
- arch.regalloc = regalloc;
- arch.regfree = regfree;
- arch.regtyp = regtyp;
- arch.sameaddr = sameaddr;
- arch.smallindir = smallindir;
- arch.stackaddr = stackaddr;
- arch.excludedregs = excludedregs;
- arch.RtoB = RtoB;
- arch.FtoB = FtoB;
- arch.BtoR = BtoR;
- arch.BtoF = BtoF;
- arch.optoas = optoas;
- arch.doregbits = doregbits;
- arch.regnames = regnames;
+ thearch.thechar = thechar;
+ thearch.thestring = thestring;
+ thearch.thelinkarch = thelinkarch;
+ thearch.typedefs = typedefs;
+ thearch.REGSP = REGSP;
+ thearch.REGCTXT = REGCTXT;
+ thearch.MAXWIDTH = MAXWIDTH;
+ thearch.anyregalloc = anyregalloc;
+ thearch.betypeinit = betypeinit;
+ thearch.bgen = bgen;
+ thearch.cgen = cgen;
+ thearch.cgen_call = cgen_call;
+ thearch.cgen_callinter = cgen_callinter;
+ thearch.cgen_ret = cgen_ret;
+ thearch.clearfat = clearfat;
+ thearch.defframe = defframe;
+ thearch.excise = excise;
+ thearch.expandchecks = expandchecks;
+ thearch.gclean = gclean;
+ thearch.ginit = ginit;
+ thearch.gins = gins;
+ thearch.ginscall = ginscall;
+ thearch.igen = igen;
+ thearch.linkarchinit = linkarchinit;
+ thearch.peep = peep;
+ thearch.proginfo = proginfo;
+ thearch.regalloc = regalloc;
+ thearch.regfree = regfree;
+ thearch.regtyp = regtyp;
+ thearch.sameaddr = sameaddr;
+ thearch.smallindir = smallindir;
+ thearch.stackaddr = stackaddr;
+ thearch.excludedregs = excludedregs;
+ thearch.RtoB = RtoB;
+ thearch.FtoB = FtoB;
+ thearch.BtoR = BtoR;
+ thearch.BtoF = BtoF;
+ thearch.optoas = optoas;
+ thearch.doregbits = doregbits;
+ thearch.regnames = regnames;
gcmain(argc, argv);
}
case ACALL:
if(REGEXT && v->type == TYPE_REG && v->reg <= REGEXT && v->reg > exregoffset)
return 2;
- if(REGARG >= 0 && v->type == TYPE_REG && v->reg == (uchar)REGARG)
+ if(REGARG >= 0 && v->type == TYPE_REG && v->reg == REGARG)
return 2;
if(v->type == p->from.type && v->reg == p->from.reg)
return 2;
return 3;
case ATEXT:
- if(REGARG >= 0 && v->type == TYPE_REG && v->reg == (uchar)REGARG)
+ if(REGARG >= 0 && v->type == TYPE_REG && v->reg == REGARG)
return 3;
return 0;
}
linkarchinit(void)
{
thestring = getgoarch();
- arch.thestring = thestring;
+ thearch.thestring = thestring;
if(strcmp(thestring, "ppc64le") == 0)
thelinkarch = &linkppc64le;
else
thelinkarch = &linkppc64;
- arch.thelinkarch = thelinkarch;
+ thearch.thelinkarch = thelinkarch;
}
vlong MAXWIDTH = 1LL<<50;
void
main(int argc, char **argv)
{
- arch.thechar = thechar;
- arch.thestring = thestring;
- arch.thelinkarch = thelinkarch;
- arch.typedefs = typedefs;
- arch.REGSP = REGSP;
- arch.REGCTXT = REGCTXT;
- arch.MAXWIDTH = MAXWIDTH;
- arch.anyregalloc = anyregalloc;
- arch.betypeinit = betypeinit;
- arch.bgen = bgen;
- arch.cgen = cgen;
- arch.cgen_call = cgen_call;
- arch.cgen_callinter = cgen_callinter;
- arch.cgen_ret = cgen_ret;
- arch.clearfat = clearfat;
- arch.dumpit = dumpit;
- arch.excise = excise;
- arch.expandchecks = expandchecks;
- arch.gclean = gclean;
- arch.ginit = ginit;
- arch.gins = gins;
- arch.ginscall = ginscall;
- arch.igen = igen;
- arch.linkarchinit = linkarchinit;
- arch.peep = peep;
- arch.proginfo = proginfo;
- arch.regalloc = regalloc;
- arch.regfree = regfree;
- arch.regtyp = regtyp;
- arch.sameaddr = sameaddr;
- arch.smallindir = smallindir;
- arch.stackaddr = stackaddr;
- arch.excludedregs = excludedregs;
- arch.RtoB = RtoB;
- arch.FtoB = RtoB;
- arch.BtoR = BtoR;
- arch.BtoF = BtoF;
- arch.optoas = optoas;
- arch.doregbits = doregbits;
- arch.regnames = regnames;
+ thearch.thechar = thechar;
+ thearch.thestring = thestring;
+ thearch.thelinkarch = thelinkarch;
+ thearch.typedefs = typedefs;
+ thearch.REGSP = REGSP;
+ thearch.REGCTXT = REGCTXT;
+ thearch.MAXWIDTH = MAXWIDTH;
+ thearch.anyregalloc = anyregalloc;
+ thearch.betypeinit = betypeinit;
+ thearch.bgen = bgen;
+ thearch.cgen = cgen;
+ thearch.cgen_call = cgen_call;
+ thearch.cgen_callinter = cgen_callinter;
+ thearch.cgen_ret = cgen_ret;
+ thearch.clearfat = clearfat;
+ thearch.defframe = defframe;
+ thearch.excise = excise;
+ thearch.expandchecks = expandchecks;
+ thearch.gclean = gclean;
+ thearch.ginit = ginit;
+ thearch.gins = gins;
+ thearch.ginscall = ginscall;
+ thearch.igen = igen;
+ thearch.linkarchinit = linkarchinit;
+ thearch.peep = peep;
+ thearch.proginfo = proginfo;
+ thearch.regalloc = regalloc;
+ thearch.regfree = regfree;
+ thearch.regtyp = regtyp;
+ thearch.sameaddr = sameaddr;
+ thearch.smallindir = smallindir;
+ thearch.stackaddr = stackaddr;
+ thearch.excludedregs = excludedregs;
+ thearch.RtoB = RtoB;
+ thearch.FtoB = RtoB;
+ thearch.BtoR = BtoR;
+ thearch.BtoF = BtoF;
+ thearch.optoas = optoas;
+ thearch.doregbits = doregbits;
+ thearch.regnames = regnames;
gcmain(argc, argv);
}
fatal("offmod: not TFIELD: %lT", f);
f->width = o;
o += widthptr;
- if(o >= arch.MAXWIDTH) {
+ if(o >= thearch.MAXWIDTH) {
yyerror("interface too large");
o = widthptr;
}
if(w == 0)
lastzero = o;
o += w;
- if(o >= arch.MAXWIDTH) {
+ if(o >= thearch.MAXWIDTH) {
yyerror("type %lT too large", errtype);
o = 8; // small but nonzero
}
dowidth(t->type);
if(t->type->width != 0) {
- cap = (arch.MAXWIDTH-1) / t->type->width;
+ cap = (thearch.MAXWIDTH-1) / t->type->width;
if(t->bound > cap)
yyerror("type %lT larger than address space", t);
}
simtype[TFUNC] = tptr;
simtype[TUNSAFEPTR] = tptr;
- /* pick up the backend arch.typedefs */
- for(i=0; arch.typedefs[i].name; i++) {
- s = lookup(arch.typedefs[i].name);
- s1 = pkglookup(arch.typedefs[i].name, builtinpkg);
+ /* pick up the backend thearch.typedefs */
+ for(i=0; thearch.typedefs[i].name; i++) {
+ s = lookup(thearch.typedefs[i].name);
+ s1 = pkglookup(thearch.typedefs[i].name, builtinpkg);
- etype = arch.typedefs[i].etype;
+ etype = thearch.typedefs[i].etype;
if(etype < 0 || etype >= nelem(types))
fatal("typeinit: %s bad etype", s->name);
- sameas = arch.typedefs[i].sameas;
+ sameas = thearch.typedefs[i].sameas;
if(sameas < 0 || sameas >= nelem(types))
fatal("typeinit: %s bad sameas", s->name);
simtype[etype] = sameas;
cv->xoffset = offset;
offset += cv->type->width;
- if(v->byval && v->type->width <= 2*widthptr && arch.thechar == '6') {
+ if(v->byval && v->type->width <= 2*widthptr && thearch.thechar == '6') {
// If it is a small variable captured by value, downgrade it to PAUTO.
// This optimization is currently enabled only for amd64, see:
// https://github.com/golang/go/issues/9865
subnode(&n1, &n2, f);
subnode(&n3, &n4, t);
- arch.cgen(&n1, &n3);
- arch.cgen(&n2, &n4);
+ thearch.cgen(&n1, &n3);
+ thearch.cgen(&n2, &n4);
break;
}
}
if(res->addable) {
subnode(&n1, &n2, res);
tempname(&tmp, n1.type);
- arch.cgen(n->left, &tmp);
- arch.cgen(n->right, &n2);
- arch.cgen(&tmp, &n1);
+ thearch.cgen(n->left, &tmp);
+ thearch.cgen(n->right, &n2);
+ thearch.cgen(&tmp, &n1);
return;
}
break;
}
subnode(&n1, &n2, nl);
if(n->op == OREAL) {
- arch.cgen(&n1, res);
+ thearch.cgen(&n1, res);
return;
}
- arch.cgen(&n2, res);
+ thearch.cgen(&n2, res);
return;
}
}
if(!res->addable) {
- arch.igen(res, &n1, N);
- arch.cgen(n, &n1);
- arch.regfree(&n1);
+ thearch.igen(res, &n1, N);
+ thearch.cgen(n, &n1);
+ thearch.regfree(&n1);
return;
}
if(n->addable) {
case OCALLFUNC:
case OCALLMETH:
case OCALLINTER:
- arch.igen(n, &n1, res);
+ thearch.igen(n, &n1, res);
complexmove(&n1, res);
- arch.regfree(&n1);
+ thearch.regfree(&n1);
return;
case OCONV:
if(nr != N) {
if(nl->ullman > nr->ullman && !nl->addable) {
tempname(&tnl, nl->type);
- arch.cgen(nl, &tnl);
+ thearch.cgen(nl, &tnl);
nl = &tnl;
}
if(!nr->addable) {
tempname(&tnr, nr->type);
- arch.cgen(nr, &tnr);
+ thearch.cgen(nr, &tnr);
nr = &tnr;
}
}
if(!nl->addable) {
tempname(&tnl, nl->type);
- arch.cgen(nl, &tnl);
+ thearch.cgen(nl, &tnl);
nl = &tnl;
}
if(nr != N) {
if(nl->ullman > nr->ullman && !nl->addable) {
tempname(&tnl, nl->type);
- arch.cgen(nl, &tnl);
+ thearch.cgen(nl, &tnl);
nl = &tnl;
}
if(!nr->addable) {
tempname(&tnr, nr->type);
- arch.cgen(nr, &tnr);
+ thearch.cgen(nr, &tnr);
nr = &tnr;
}
}
if(!nl->addable) {
tempname(&tnl, nl->type);
- arch.cgen(nl, &tnl);
+ thearch.cgen(nl, &tnl);
nl = &tnl;
}
if(op == ONE)
true = !true;
- arch.bgen(&na, true, likely, to);
+ thearch.bgen(&na, true, likely, to);
}
void
ra.op = OMINUS;
ra.left = nl;
ra.type = nl->type;
- arch.cgen(&ra, res);
+ thearch.cgen(&ra, res);
}
// build and execute tree
ra.left = &n1;
ra.right = &n3;
ra.type = n1.type;
- arch.cgen(&ra, &n5);
+ thearch.cgen(&ra, &n5);
memset(&ra, 0, sizeof(ra));
ra.op = op;
ra.left = &n2;
ra.right = &n4;
ra.type = n2.type;
- arch.cgen(&ra, &n6);
+ thearch.cgen(&ra, &n6);
}
// build and execute tree
ra.left = &rm1;
ra.right = &rm2;
ra.type = rm1.type;
- arch.cgen(&ra, &tmp);
+ thearch.cgen(&ra, &tmp);
// imag part
memset(&rm1, 0, sizeof(rm1));
ra.left = &rm1;
ra.right = &rm2;
ra.type = rm1.type;
- arch.cgen(&ra, &n6);
+ thearch.cgen(&ra, &n6);
// tmp ->real part
- arch.cgen(&tmp, &n5);
+ thearch.cgen(&tmp, &n5);
}
b = Bopen(asmhdr, OWRITE);
if(b == nil)
fatal("open %s: %r", asmhdr);
- Bprint(b, "// generated by %cg -asmhdr from package %s\n\n", arch.thechar, localpkg->name);
+ Bprint(b, "// generated by %cg -asmhdr from package %s\n\n", thearch.thechar, localpkg->name);
for(l=asmlist; l; l=l->next) {
n = l->n;
if(isblanksym(n->sym))
//dump("gen", n);
lno = setlineno(n);
- wasregalloc = arch.anyregalloc();
+ wasregalloc = thearch.anyregalloc();
if(n == N)
goto ret;
}
gen(n->nincr); // contin: incr
patch(p1, pc); // test:
- arch.bgen(n->ntest, 0, -1, breakpc); // if(!test) goto break
+ thearch.bgen(n->ntest, 0, -1, breakpc); // if(!test) goto break
genlist(n->nbody); // body
gjmp(continpc);
patch(breakpc, pc); // done:
p1 = gjmp(P); // goto test
p2 = gjmp(P); // p2: goto else
patch(p1, pc); // test:
- arch.bgen(n->ntest, 0, -n->likely, p2); // if(!test) goto p2
+ thearch.bgen(n->ntest, 0, -n->likely, p2); // if(!test) goto p2
genlist(n->nbody); // then
p3 = gjmp(P); // goto done
patch(p2, pc); // else:
break;
case OCALLINTER:
- arch.cgen_callinter(n, N, 0);
+ thearch.cgen_callinter(n, N, 0);
break;
case OCALLFUNC:
- arch.cgen_call(n, 0);
+ thearch.cgen_call(n, 0);
break;
case OPROC:
case ORETURN:
case ORETJMP:
- arch.cgen_ret(n);
+ thearch.cgen_ret(n);
break;
case OCHECKNIL:
}
ret:
- if(arch.anyregalloc() != wasregalloc) {
+ if(thearch.anyregalloc() != wasregalloc) {
dump("node", n);
fatal("registers left allocated");
}
if(n2.left->op == ONAME)
n2.left->class = PFUNC;
- arch.cgen_call(&n2, proc);
+ thearch.cgen_call(&n2, proc);
}
/*
break;
case OCALLINTER:
- arch.cgen_callinter(n->left, N, proc);
+ thearch.cgen_callinter(n->left, N, proc);
break;
case OCALLFUNC:
- arch.cgen_call(n->left, proc);
+ thearch.cgen_call(n->left, proc);
break;
}
}
ullmancalc(&z);
- arch.cgen(&z, n);
+ thearch.cgen(&z, n);
}
/*
if(isfat(tl)) {
if(nl->op == ONAME)
gvardef(nl);
- arch.clearfat(nl);
+ thearch.clearfat(nl);
return;
}
clearslim(nl);
if(tl == T)
return;
- arch.cgen(nr, nl);
+ thearch.cgen(nr, nl);
}
/*
Node *tmp;
tmp = temp(types[tptr]);
- arch.cgen(n->right, tmp);
+ thearch.cgen(n->right, tmp);
gvardef(res);
dst = *res;
dst.type = types[tptr];
dst.xoffset += widthptr;
- arch.cgen(tmp, &dst);
+ thearch.cgen(tmp, &dst);
dst.xoffset -= widthptr;
- arch.cgen(n->left, &dst);
+ thearch.cgen(n->left, &dst);
}
/*
if(isnil(n->left)) {
tempname(&src, n->left->type);
- arch.cgen(n->left, &src);
+ thearch.cgen(n->left, &src);
} else
src = *n->left;
if(n->op == OSLICE || n->op == OSLICE3 || n->op == OSLICESTR)
if(n->op == OSLICEARR || n->op == OSLICE3ARR) {
if(!isptr[n->left->type->etype])
fatal("slicearr is supposed to work on pointer: %+N\n", n);
- arch.cgen(&src, base);
+ thearch.cgen(&src, base);
cgen_checknil(base);
} else {
src.type = types[tptr];
- arch.cgen(&src, base);
+ thearch.cgen(&src, base);
}
// committed to the update
// compute len and cap.
// len = n-i, cap = m-i, and offs = i*width.
// computing offs last lets the multiply overwrite i.
- arch.cgen(len, tmplen);
+ thearch.cgen(len, tmplen);
if(n->op != OSLICESTR)
- arch.cgen(cap, tmpcap);
+ thearch.cgen(cap, tmpcap);
// if new cap != 0 { base += add }
// This avoids advancing base past the end of the underlying array/string,
nodconst(&con, tmpcap->type, 0);
cmp = nod(OEQ, tmpcap, &con);
typecheck(&cmp, Erv);
- arch.bgen(cmp, 1, -1, p2);
+ thearch.bgen(cmp, 1, -1, p2);
add = nod(OADD, base, offs);
typecheck(&add, Erv);
- arch.cgen(add, base);
+ thearch.cgen(add, base);
patch(p2, pc);
}
dst = *res;
dst.xoffset += Array_array;
dst.type = types[tptr];
- arch.cgen(base, &dst);
+ thearch.cgen(base, &dst);
// dst.len = hi [ - lo ]
dst = *res;
dst.xoffset += Array_nel;
dst.type = types[simtype[TUINT]];
- arch.cgen(tmplen, &dst);
+ thearch.cgen(tmplen, &dst);
if(n->op != OSLICESTR) {
// dst.cap = cap [ - lo ]
dst = *res;
dst.xoffset += Array_cap;
dst.type = types[simtype[TUINT]];
- arch.cgen(tmpcap, &dst);
+ thearch.cgen(tmpcap, &dst);
}
}
OCHECKNIL, // emit code to ensure pointer/interface not nil
OVARKILL, // variable is dead
- // arch-specific registers
+ // thearch-specific registers
OREGISTER, // a register, such as AX.
OINDREG, // offset plus indirect of a register, such as 8(SP).
void usefield(Node*);
/*
- * arch-specific ggen.c/gsubr.c/gobj.c/pgen.c/plive.c
+ * thearch-specific ggen.c/gsubr.c/gobj.c/pgen.c/plive.c
*/
#define P ((Prog*)0)
void (*cgen_callinter)(Node*, Node*, int);
void (*cgen_ret)(Node*);
void (*clearfat)(Node*);
- void (*dumpit)(char*, Flow*, int);
+ void (*defframe)(Prog*);
void (*excise)(Flow*);
void (*expandchecks)(Prog*);
void (*gclean)(void);
void afunclit(Addr*, Node*);
void clearp(Prog*);
-void defframe(Prog*);
int dgostringptr(Sym*, int, char*);
int dgostrlitptr(Sym*, int, Strlit*);
int dsname(Sym*, int, char*, int);
EXTERN int32 pcloc;
-EXTERN Arch arch;
+EXTERN Arch thearch;
EXTERN Node *newproc;
EXTERN Node *deferproc;
{
Prog *p;
- p = arch.gins(AGLOBL, nam, N);
+ p = thearch.gins(AGLOBL, nam, N);
p->lineno = nam->lineno;
p->from.sym->gotype = linksym(ngotype(nam));
p->to.sym = nil;
{
Prog *p;
- p = arch.gins(AUSEFIELD, N, N);
+ p = thearch.gins(AUSEFIELD, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.sym = linksym(s);
{
Prog *p;
- p = arch.gins(AGLOBL, N, N);
+ p = thearch.gins(AGLOBL, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.sym = linksym(s);
p = prog(as);
p->to.type = TYPE_BRANCH;
p->to.u.branch = P;
- if(as != AJMP && likely != 0 && arch.thechar != '9') {
+ if(as != AJMP && likely != 0 && thearch.thechar != '9') {
p->from.type = TYPE_CONST;
p->from.offset = likely > 0;
}
void
gused(Node *n)
{
- arch.gins(ANOP, n, N); // used
+ thearch.gins(ANOP, n, N); // used
}
Prog*
case OCLOSUREVAR:
return 1;
case OADDR:
- return arch.thechar == '6' || arch.thechar == '9'; // because 6g uses PC-relative addressing; TODO(rsc): not sure why 9g too
+ return thearch.thechar == '6' || thearch.thechar == '9'; // because 6g uses PC-relative addressing; TODO(rsc): not sure why 9g too
}
return 0;
}
switch(fp) {
case 0: // output arg
n->op = OINDREG;
- n->val.u.reg = arch.REGSP;
- if(arch.thechar == '5')
+ n->val.u.reg = thearch.REGSP;
+ if(thearch.thechar == '5')
n->xoffset += 4;
- if(arch.thechar == '9')
+ if(thearch.thechar == '9')
n->xoffset += 8;
break;
case 2: // offset output arg
fatal("shouldn't be used");
n->op = OINDREG;
- n->val.u.reg = arch.REGSP;
+ n->val.u.reg = thearch.REGSP;
n->xoffset += types[tptr]->width;
break;
}
a->type = TYPE_REG;
a->reg = n->val.u.reg;
a->sym = nil;
- if(arch.thechar == '8') // TODO(rsc): Never clear a->width.
+ if(thearch.thechar == '8') // TODO(rsc): Never clear a->width.
a->width = 0;
break;
a->offset = n->xoffset;
if(a->offset != (int32)a->offset)
yyerror("offset %lld too large for OINDREG", a->offset);
- if(arch.thechar == '8') // TODO(rsc): Never clear a->width.
+ if(thearch.thechar == '8') // TODO(rsc): Never clear a->width.
a->width = 0;
break;
if(!curfn->needctxt)
fatal("closurevar without needctxt");
a->type = TYPE_MEM;
- a->reg = arch.REGCTXT;
+ a->reg = thearch.REGCTXT;
a->sym = nil;
a->offset = n->xoffset;
break;
break;
case OLITERAL:
- if(arch.thechar == '8')
+ if(thearch.thechar == '8')
a->width = 0;
switch(n->val.ctype) {
default:
case OADDR:
naddr(n->left, a, canemitcode);
a->etype = tptr;
- if(arch.thechar != '5' && arch.thechar != '9') // TODO(rsc): Do this even for arm, ppc64.
+ if(thearch.thechar != '5' && thearch.thechar != '9') // TODO(rsc): Do this even for arm, ppc64.
a->width = widthptr;
if(a->type != TYPE_MEM)
fatal("naddr: OADDR %D (from %O)", a, n->left->op);
if(a->type == TYPE_CONST && a->offset == 0)
break; // len(nil)
a->etype = simtype[TUINT];
- if(arch.thechar == '9')
+ if(thearch.thechar == '9')
a->etype = simtype[TINT];
a->offset += Array_nel;
- if(arch.thechar != '5') // TODO(rsc): Do this even on arm.
+ if(thearch.thechar != '5') // TODO(rsc): Do this even on arm.
a->width = widthint;
break;
if(a->type == TYPE_CONST && a->offset == 0)
break; // cap(nil)
a->etype = simtype[TUINT];
- if(arch.thechar == '9')
+ if(thearch.thechar == '9')
a->etype = simtype[TINT];
a->offset += Array_cap;
- if(arch.thechar != '5') // TODO(rsc): Do this even on arm.
+ if(thearch.thechar != '5') // TODO(rsc): Do this even on arm.
a->width = widthint;
break;
void
usage(void)
{
- print("usage: %cg [options] file.go...\n", arch.thechar);
+ print("usage: %cg [options] file.go...\n", thearch.thechar);
flagprint(1);
exits("usage");
}
sep = "";
if(*p)
sep = " ";
- print("%cg version %s%s%s\n", arch.thechar, getgoversion(), sep, p);
+ print("%cg version %s%s%s\n", thearch.thechar, getgoversion(), sep, p);
exits(0);
}
// Tell the FPU to handle all exceptions.
setfcr(FPPDBL|FPRNR);
#endif
- // Allow GOARCH=arch.thestring or GOARCH=arch.thestringsuffix,
+ // Allow GOARCH=thearch.thestring or GOARCH=thearch.thestringsuffix,
// but not other values.
p = getgoarch();
- if(strncmp(p, arch.thestring, strlen(arch.thestring)) != 0)
- sysfatal("cannot use %cg with GOARCH=%s", arch.thechar, p);
+ if(strncmp(p, thearch.thestring, strlen(thearch.thestring)) != 0)
+ sysfatal("cannot use %cg with GOARCH=%s", thearch.thechar, p);
goarch = p;
- arch.linkarchinit();
- ctxt = linknew(arch.thelinkarch);
+ thearch.linkarchinit();
+ ctxt = linknew(thearch.thelinkarch);
ctxt->diag = yyerror;
ctxt->bso = &bstdout;
Binit(&bstdout, 1, OWRITE);
flagcount("wb", "enable write barrier", &use_writebarrier);
flagcount("x", "debug lexer", &debug['x']);
flagcount("y", "debug declarations in canned imports (with -d)", &debug['y']);
- if(arch.thechar == '6')
+ if(thearch.thechar == '6')
flagcount("largemodel", "generate code that assumes a large memory model", &flag_largemodel);
flagparse(&argc, &argv, usage);
if(debug['l'] <= 1)
debug['l'] = 1 - debug['l'];
- if(arch.thechar == '8') {
+ if(thearch.thechar == '8') {
p = getgo386();
if(strcmp(p, "387") == 0)
use_sse = 0;
}
fmtinstallgo();
- arch.betypeinit();
+ thearch.betypeinit();
if(widthptr == 0)
fatal("betypeinit failed");
snprint(namebuf, sizeof(namebuf), "%Z.a", name);
if(access(namebuf, 0) >= 0)
return 1;
- snprint(namebuf, sizeof(namebuf), "%Z.%c", name, arch.thechar);
+ snprint(namebuf, sizeof(namebuf), "%Z.%c", name, thearch.thechar);
if(access(namebuf, 0) >= 0)
return 1;
return 0;
snprint(namebuf, sizeof(namebuf), "%s/%Z.a", p->dir, name);
if(access(namebuf, 0) >= 0)
return 1;
- snprint(namebuf, sizeof(namebuf), "%s/%Z.%c", p->dir, name, arch.thechar);
+ snprint(namebuf, sizeof(namebuf), "%s/%Z.%c", p->dir, name, thearch.thechar);
if(access(namebuf, 0) >= 0)
return 1;
}
snprint(namebuf, sizeof(namebuf), "%s/pkg/%s_%s%s%s/%Z.a", goroot, goos, goarch, suffixsep, suffix, name);
if(access(namebuf, 0) >= 0)
return 1;
- snprint(namebuf, sizeof(namebuf), "%s/pkg/%s_%s%s%s/%Z.%c", goroot, goos, goarch, suffixsep, suffix, name, arch.thechar);
+ snprint(namebuf, sizeof(namebuf), "%s/pkg/%s_%s%s%s/%Z.%c", goroot, goos, goarch, suffixsep, suffix, name, thearch.thechar);
if(access(namebuf, 0) >= 0)
return 1;
}
}
// backend-specific builtin types (e.g. int).
- for(i=0; arch.typedefs[i].name; i++) {
- s = lookup(arch.typedefs[i].name);
+ for(i=0; thearch.typedefs[i].name; i++) {
+ s = lookup(thearch.typedefs[i].name);
if(s->def == N) {
- s->def = typenod(types[arch.typedefs[i].etype]);
+ s->def = typenod(types[thearch.typedefs[i].etype]);
s->origpkg = builtinpkg;
}
}
p = strrchr(namebuf, '.');
if(p != nil)
*p = 0;
- outfile = smprint("%s.%c", namebuf, arch.thechar);
+ outfile = smprint("%s.%c", namebuf, thearch.thechar);
}
}
if(size&1)
Bputc(bout, 0);
Bseek(bout, startobj - ArhdrSize, 0);
- snprint(namebuf, sizeof namebuf, "_go_.%c", arch.thechar);
+ snprint(namebuf, sizeof namebuf, "_go_.%c", thearch.thechar);
formathdr(arhdr, namebuf, size);
Bwrite(bout, arhdr, ArhdrSize);
}
{
Prog *p;
- p = arch.gins(ADATA, N, N);
+ p = thearch.gins(ADATA, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.offset = off;
return;
}
}
- p = arch.gins(ADATA, nam, nr);
+ p = thearch.gins(ADATA, nam, nr);
p->from3.type = TYPE_CONST;
p->from3.offset = wid;
}
w = cplxsubtype(nam->type->etype);
w = types[w]->width;
- p = arch.gins(ADATA, nam, N);
+ p = thearch.gins(ADATA, nam, N);
p->from3.type = TYPE_CONST;
p->from3.offset = w;
p->to.type = TYPE_FCONST;
p->to.u.dval = mpgetflt(&cval->real);
- p = arch.gins(ADATA, nam, N);
+ p = thearch.gins(ADATA, nam, N);
p->from3.type = TYPE_CONST;
p->from3.offset = w;
p->from.offset += w;
Prog *p;
Node nod1;
- p = arch.gins(ADATA, nam, N);
+ p = thearch.gins(ADATA, nam, N);
datastring(sval->s, sval->len, &p->to);
p->from3.type = TYPE_CONST;
p->from3.offset = types[tptr]->width;
//print("%P\n", p);
nodconst(&nod1, types[TINT], sval->len);
- p = arch.gins(ADATA, nam, &nod1);
+ p = thearch.gins(ADATA, nam, &nod1);
p->from3.type = TYPE_CONST;
p->from3.offset = widthint;
p->from.offset += widthptr;
Prog *p;
off = rnd(off, widthptr);
- p = arch.gins(ADATA, N, N);
+ p = thearch.gins(ADATA, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.sym = linksym(s);
return duintptr(s, off, 0);
off = rnd(off, widthptr);
- p = arch.gins(ADATA, N, N);
+ p = thearch.gins(ADATA, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.sym = linksym(s);
off = rnd(off, widthptr);
- p = arch.gins(ADATA, N, N);
+ p = thearch.gins(ADATA, N, N);
p->from.type = TYPE_MEM;
p->from.name = NAME_EXTERN;
p->from.sym = linksym(s);
pnod = newname(sym);
pnod->class = PEXTERN;
nodconst(&nod, types[TINT32], funcdatakind);
- arch.gins(AFUNCDATA, &nod, pnod);
+ thearch.gins(AFUNCDATA, &nod, pnod);
return sym;
}
case PAUTO:
case PPARAM:
case PPARAMOUT:
- arch.gins(as, N, n);
+ thearch.gins(as, N, n);
}
}
setlineno(curfn);
nodconst(&nod1, types[TINT32], 0);
- ptxt = arch.gins(ATEXT, isblank(curfn->nname) ? N : curfn->nname, &nod1);
+ ptxt = thearch.gins(ATEXT, isblank(curfn->nname) ? N : curfn->nname, &nod1);
if(fn->dupok)
ptxt->from3.offset |= DUPOK;
if(fn->wrapper)
afunclit(&ptxt->from, curfn->nname);
- arch.ginit();
+ thearch.ginit();
gcargs = makefuncdatasym("gcargs·%d", FUNCDATA_ArgsPointerMaps);
gclocals = makefuncdatasym("gclocals·%d", FUNCDATA_LocalsPointerMaps);
case PPARAM:
case PPARAMOUT:
nodconst(&nod1, types[TUINTPTR], l->n->type->width);
- p = arch.gins(ATYPE, l->n, &nod1);
+ p = thearch.gins(ATYPE, l->n, &nod1);
p->from.gotype = linksym(ngotype(l->n));
break;
}
genlist(curfn->enter);
genlist(curfn->nbody);
- arch.gclean();
+ thearch.gclean();
checklabels();
if(nerrors != 0)
goto ret;
lineno = curfn->endlineno;
if(curfn->type->outtuple != 0)
- arch.ginscall(throwreturn, 0);
+ thearch.ginscall(throwreturn, 0);
- arch.ginit();
+ thearch.ginit();
// TODO: Determine when the final cgen_ret can be omitted. Perhaps always?
- arch.cgen_ret(nil);
+ thearch.cgen_ret(nil);
if(hasdefer) {
// deferreturn pretends to have one uintptr argument.
// Reserve space for it so stack scanner is happy.
if(maxarg < widthptr)
maxarg = widthptr;
}
- arch.gclean();
+ thearch.gclean();
if(nerrors != 0)
goto ret;
regopt(ptxt);
nilopt(ptxt);
}
- arch.expandchecks(ptxt);
+ thearch.expandchecks(ptxt);
oldstksize = stksize;
allocauto(ptxt);
gcsymdup(gcargs);
gcsymdup(gclocals);
- defframe(ptxt);
+ thearch.defframe(ptxt);
if(debug['f'])
frame(0);
dowidth(n->type);
w = n->type->width;
- if(w >= arch.MAXWIDTH || w < 0)
+ if(w >= thearch.MAXWIDTH || w < 0)
fatal("bad width");
stksize += w;
stksize = rnd(stksize, n->type->align);
if(haspointers(n->type))
stkptrsize = stksize;
- if(arch.thechar == '5' || arch.thechar == '9')
+ if(thearch.thechar == '5' || thearch.thechar == '9')
stksize = rnd(stksize, widthptr);
if(stksize >= (1ULL<<31)) {
setlineno(curfn);
dump("checknil", n);
fatal("bad checknil");
}
- if(((arch.thechar == '5' || arch.thechar == '9') && n->op != OREGISTER) || !n->addable || n->op == OLITERAL) {
- arch.regalloc(®, types[tptr], n);
- arch.cgen(n, ®);
- arch.gins(ACHECKNIL, ®, N);
- arch.regfree(®);
+ if(((thearch.thechar == '5' || thearch.thechar == '9') && n->op != OREGISTER) || !n->addable || n->op == OLITERAL) {
+ thearch.regalloc(®, types[tptr], n);
+ thearch.cgen(n, ®);
+ thearch.gins(ACHECKNIL, ®, N);
+ thearch.regfree(®);
return;
}
- arch.gins(ACHECKNIL, n, N);
+ thearch.gins(ACHECKNIL, n, N);
}
bvresetall(varkill);
bvresetall(avarinit);
- arch.proginfo(&info, prog);
+ thearch.proginfo(&info, prog);
if(prog->as == ARET) {
// Return instructions implicitly read all the arguments. For
// the sake of correctness, out arguments must be read. For the
// If we added it to uevar too, we'd not see any kill
// and decide that the varible was live entry, which it is not.
// So only use uevar in the non-addrtaken case.
- // The p->to.type == arch.D_NONE limits the bvset to
+ // The p->to.type == thearch.D_NONE limits the bvset to
// non-tail-call return instructions; see note above
// the for loop for details.
if(!node->addrtaken && prog->to.type == TYPE_NONE)
#include <u.h>
#include <libc.h>
#include "go.h"
+#include "popt.h"
// p is a call instruction. Does the call fail to return?
int
nf = 0;
for(p = firstp; p != P; p = p->link) {
p->opt = nil; // should be already, but just in case
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
if(info.flags & Skip)
continue;
p->opt = (void*)1;
// Fill in pred/succ information.
for(f = start; f != nil; f = f->link) {
p = f->prog;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
if(!(info.flags & Break)) {
f1 = f->link;
f->s1 = f1;
return 0;
}
-enum {
- LOOP = 3,
-};
-
static void
loopmark(Flow **rpo2r, int32 head, Flow *r)
{
// single-use (that's why we have so many!).
for(f = g->start; f != nil; f = f->link) {
p = f->prog;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
if(p->from.node != N && ((Node*)(p->from.node))->opt && p->to.node != N && ((Node*)(p->to.node))->opt)
fatal("double node %P", p);
}
if(debugmerge > 1 && debug['v'])
- arch.dumpit("before", g->start, 0);
+ dumpit("before", g->start, 0);
nkill = 0;
// Used in only one instruction, which had better be a write.
if((f = v->use) != nil && (Flow*)f->data == nil) {
p = f->prog;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
if(p->to.node == v->node && (info.flags & RightWrite) && !(info.flags & RightRead)) {
p->as = ANOP;
p->to = zprog.to;
// no jumps to the next instruction. Happens mainly in 386 compiler.
if((f = v->use) != nil && f->link == (Flow*)f->data && (Flow*)((Flow*)f->data)->data == nil && uniqp(f->link) == f) {
p = f->prog;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
p1 = f->link->prog;
- arch.proginfo(&info1, p1);
+ thearch.proginfo(&info1, p1);
enum {
SizeAny = SizeB | SizeW | SizeL | SizeQ | SizeF | SizeD,
};
!((info.flags|info1.flags) & (LeftAddr|RightAddr)) &&
(info.flags & SizeAny) == (info1.flags & SizeAny)) {
p1->from = p->from;
- arch.excise(f);
+ thearch.excise(f);
v->removed = 1;
if(debugmerge > 0 && debug['v'])
print("drop immediate-use %S\n", v->node->sym);
}
if(debugmerge > 1 && debug['v'])
- arch.dumpit("after", g->start, 0);
+ dumpit("after", g->start, 0);
}
// Update node references to use merged temporaries.
return;
if(debug_checknil > 1 /* || strcmp(curfn->nname->sym->name, "f1") == 0 */)
- arch.dumpit("nilopt", g->start, 0);
+ dumpit("nilopt", g->start, 0);
ncheck = 0;
nkill = 0;
for(f = g->start; f != nil; f = f->link) {
p = f->prog;
- if(p->as != ACHECKNIL || !arch.regtyp(&p->from))
+ if(p->as != ACHECKNIL || !thearch.regtyp(&p->from))
continue;
ncheck++;
- if(arch.stackaddr(&p->from)) {
+ if(thearch.stackaddr(&p->from)) {
if(debug_checknil && p->lineno > 1)
warnl(p->lineno, "removed nil check of SP address");
f->data = &killed;
for(f = g->start; f != nil; f = f->link) {
if(f->data != nil) {
nkill++;
- arch.excise(f);
+ thearch.excise(f);
}
}
for(f = fcheck; f != nil; f = uniqp(f)) {
p = f->prog;
- arch.proginfo(&info, p);
- if((info.flags & RightWrite) && arch.sameaddr(&p->to, &fcheck->prog->from)) {
+ thearch.proginfo(&info, p);
+ if((info.flags & RightWrite) && thearch.sameaddr(&p->to, &fcheck->prog->from)) {
// Found initialization of value we're checking for nil.
// without first finding the check, so this one is unchecked.
return;
}
- if(f != fcheck && p->as == ACHECKNIL && arch.sameaddr(&p->from, &fcheck->prog->from)) {
+ if(f != fcheck && p->as == ACHECKNIL && thearch.sameaddr(&p->from, &fcheck->prog->from)) {
fcheck->data = &killed;
return;
}
// If same check, stop this loop but still check
// alternate predecessors up to this point.
- if(f1 != fcheck && p->as == ACHECKNIL && arch.sameaddr(&p->from, &fcheck->prog->from))
+ if(f1 != fcheck && p->as == ACHECKNIL && thearch.sameaddr(&p->from, &fcheck->prog->from))
break;
- arch.proginfo(&info, p);
- if((info.flags & RightWrite) && arch.sameaddr(&p->to, &fcheck->prog->from)) {
+ thearch.proginfo(&info, p);
+ if((info.flags & RightWrite) && thearch.sameaddr(&p->to, &fcheck->prog->from)) {
// Found initialization of value we're checking for nil.
// without first finding the check, so this one is unchecked.
fcheck->kill = 0;
if(f1->p1 == nil && f1->p2 == nil) {
print("lost pred for %P\n", fcheck->prog);
for(f1=f0; f1!=nil; f1=f1->p1) {
- arch.proginfo(&info, f1->prog);
- print("\t%P %d %d %D %D\n", r1->prog, info.flags&RightWrite, arch.sameaddr(&f1->prog->to, &fcheck->prog->from), &f1->prog->to, &fcheck->prog->from);
+ thearch.proginfo(&info, f1->prog);
+ print("\t%P %d %d %D %D\n", r1->prog, info.flags&RightWrite, thearch.sameaddr(&f1->prog->to, &fcheck->prog->from), &f1->prog->to, &fcheck->prog->from);
}
fatal("lost pred trail");
}
last = nil;
for(f = uniqs(fcheck); f != nil; f = uniqs(f)) {
p = f->prog;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
- if((info.flags & LeftRead) && arch.smallindir(&p->from, &fcheck->prog->from)) {
+ if((info.flags & LeftRead) && thearch.smallindir(&p->from, &fcheck->prog->from)) {
fcheck->data = &killed;
return;
}
- if((info.flags & (RightRead|RightWrite)) && arch.smallindir(&p->to, &fcheck->prog->from)) {
+ if((info.flags & (RightRead|RightWrite)) && thearch.smallindir(&p->to, &fcheck->prog->from)) {
fcheck->data = &killed;
return;
}
if(p->as == ACHECKNIL)
return;
// Stop if value is lost.
- if((info.flags & RightWrite) && arch.sameaddr(&p->to, &fcheck->prog->from))
+ if((info.flags & RightWrite) && thearch.sameaddr(&p->to, &fcheck->prog->from))
return;
// Stop if memory write.
- if((info.flags & RightWrite) && !arch.regtyp(&p->to))
+ if((info.flags & RightWrite) && !thearch.regtyp(&p->to))
return;
// Stop if we jump backward.
if(last != nil && f->id <= last->id)
* than in generated c code. define pseudo-variables for
* registers, so we have complete register usage information.
*/
- regnames = arch.regnames(&nreg);
+ regnames = thearch.regnames(&nreg);
nvar = nreg;
memset(var, 0, nreg*sizeof var[0]);
for(i=0; i<nreg; i++) {
var[i].node = regnodes[i];
}
- regbits = arch.excludedregs();
+ regbits = thearch.excludedregs();
externs = zbits;
params = zbits;
consts = zbits;
p = f->prog;
if(p->as == AVARDEF || p->as == AVARKILL)
continue;
- arch.proginfo(&info, p);
+ thearch.proginfo(&info, p);
// Avoid making variables for direct-called functions.
if(p->as == ACALL && p->to.type == TYPE_MEM && p->to.name == NAME_EXTERN)
// Compute used register for reg
if(info.flags & RegRead)
- r->use1.b[0] |= arch.RtoB(p->reg);
+ r->use1.b[0] |= thearch.RtoB(p->reg);
// Currently we never generate three register forms.
// If we do, this will need to change.
if(debug['w'])
print("%L: set and not used: %Q\n", f->prog->lineno, bit);
f->refset = 1;
- arch.excise(f);
+ thearch.excise(f);
}
for(z=0; z<BITS; z++)
bit.b[z] = LOAD(r) & ~(r->act.b[z] | addrs.b[z]);
* peep-hole on basic block
*/
if(!debug['R'] || debug['P'])
- arch.peep(firstp);
+ thearch.peep(firstp);
/*
* eliminate nops
a->type = TYPE_CONST;
*/
- p1->as = arch.optoas(OAS, types[(uchar)v->etype]);
+ p1->as = thearch.optoas(OAS, types[(uchar)v->etype]);
// TODO(rsc): Remove special case here.
- if((arch.thechar == '9' || arch.thechar == '5') && v->etype == TBOOL)
- p1->as = arch.optoas(OAS, types[TUINT8]);
+ if((thearch.thechar == '9' || thearch.thechar == '5') && v->etype == TBOOL)
+ p1->as = thearch.optoas(OAS, types[TUINT8]);
p1->from.type = TYPE_REG;
p1->from.reg = rn;
p1->from.name = NAME_NONE;
goto none;
r = (Reg*)f->data;
- r->use1.b[0] |= arch.doregbits(a->index); // TODO: Use RtoB
+ r->use1.b[0] |= thearch.doregbits(a->index); // TODO: Use RtoB
switch(a->type) {
default:
- regu = arch.doregbits(a->reg) | arch.RtoB(a->reg); // TODO: Use RtoB
+ regu = thearch.doregbits(a->reg) | thearch.RtoB(a->reg); // TODO: Use RtoB
if(regu == 0)
goto none;
bit = zbits;
case TYPE_ADDR:
// TODO(rsc): Remove special case here.
- if(arch.thechar == '9' || arch.thechar == '5')
+ if(thearch.thechar == '9' || thearch.thechar == '5')
goto memcase;
a->type = TYPE_MEM;
bit = mkvar(f, a);
case TYPE_MEM:
memcase:
if(r != R) {
- r->use1.b[0] |= arch.RtoB(a->reg);
+ r->use1.b[0] |= thearch.RtoB(a->reg);
/* NOTE: 5g did
if(r->f.prog->scond & (C_PBIT|C_WBIT))
r->set.b[0] |= RtoB(a->reg);
if(v->etype == et)
if(v->width == w) {
// TODO(rsc): Remove special case for arm here.
- if(!flag || arch.thechar != '5')
+ if(!flag || thearch.thechar != '5')
return blsh(i);
}
case TBOOL:
case TPTR32:
case TPTR64:
- i = arch.BtoR(~b);
+ i = thearch.BtoR(~b);
if(i && r->cost > 0) {
r->regno = i;
- return arch.RtoB(i);
+ return thearch.RtoB(i);
}
break;
case TFLOAT32:
case TFLOAT64:
- i = arch.BtoF(~b);
+ i = thearch.BtoF(~b);
if(i && r->cost > 0) {
r->regno = i;
- return arch.FtoB(i);
+ return thearch.FtoB(i);
}
break;
}
if(l < 0)
break;
// Check for overflow.
- if(n->type->width != 0 && arch.MAXWIDTH/n->type->width <= l)
+ if(n->type->width != 0 && thearch.MAXWIDTH/n->type->width <= l)
break;
nam->xoffset += l*n->type->width;
nam->type = n->type;
dowidth(t);
w = t->argwid;
- if(w >= arch.MAXWIDTH)
+ if(w >= thearch.MAXWIDTH)
fatal("bad argwid %T", t);
w += extra;
- if(w >= arch.MAXWIDTH)
+ if(w >= thearch.MAXWIDTH)
fatal("bad argwid %d + %T", extra, t);
if(w > maxarg)
maxarg = w;
case OCONV:
case OCONVNOP:
- if(arch.thechar == '5') {
+ if(thearch.thechar == '5') {
if(isfloat[n->left->type->etype]) {
if(n->type->etype == TINT64) {
n = mkcall("float64toint64", n->type, init, conv(n->left, types[TFLOAT64]));
Node *l, *r;
Node *n;
- if(arch.thechar == '9')
+ if(thearch.thechar == '9')
return;
n = *np;
Magic m;
// TODO(minux)
- if(arch.thechar == '9')
+ if(thearch.thechar == '9')
return;
n = *np;