rnd(vlong o, vlong r)
{
if(r < 1 || r > 8 || (r&(r-1)) != 0)
- fatal("rnd");
+ fatal("rnd %lld", r);
return (o+r-1)&~(r-1);
}
int AUNDEF;
int AVARDEF;
int AVARKILL;
- int D_AUTO;
- int D_BRANCH;
- int D_NONE;
- int D_PARAM;
vlong MAXWIDTH;
void (*afunclit)(Addr*, Node*);
for(p = firstp; p != P; p = p->link) {
while(p->link != P && (p->link->as == arch.AVARDEF || p->link->as == arch.AVARKILL))
p->link = p->link->link;
- if(p->to.type == arch.D_BRANCH)
+ if(p->to.type == TYPE_BRANCH)
while(p->to.u.branch != P && (p->to.u.branch->as == arch.AVARDEF || p->to.u.branch->as == arch.AVARKILL))
p->to.u.branch = p->to.u.branch->link;
}
bb = newblock(firstp);
arrayadd(cfg, &bb);
for(p = firstp; p != P; p = p->link) {
- if(p->to.type == arch.D_BRANCH) {
+ if(p->to.type == TYPE_BRANCH) {
if(p->to.u.branch == nil)
fatal("prog branch to nil");
if(p->to.u.branch->opt == nil) {
if(isselectgocall(p))
arrayadd(selectgo, &bb);
}
- if(bb->last->to.type == arch.D_BRANCH)
+ if(bb->last->to.type == TYPE_BRANCH)
addedge(bb, bb->last->to.u.branch->opt);
if(bb->last->link != nil) {
// Add a fall-through when the instruction is
// The p->to.type == arch.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 == arch.D_NONE)
+ if(!node->addrtaken && prog->to.type == TYPE_NONE)
bvset(uevar, i);
break;
}
if(l->n->op == ONAME && l->n->class == PAUTO && l->n == n)
return;
+ if(n == nil) {
+ print("%L: checkauto %N: nil node in %P\n", p->lineno, curfn, p);
+ return;
+ }
print("checkauto %N: %N (%p; class=%d) not found in %P\n", curfn, n, n, n->class, p);
for(l = fn->dcl; l != nil; l = l->next)
print("\t%N (%p; class=%d)\n", l->n, l->n, l->n->class);
static void
checkprog(Node *fn, Prog *p)
{
- if(p->from.type == arch.D_AUTO)
+ if(p->from.name == NAME_AUTO)
checkauto(fn, p, p->from.node);
- if(p->from.type == arch.D_PARAM)
+ if(p->from.name == NAME_PARAM)
checkparam(fn, p, p->from.node);
- if(p->to.type == arch.D_AUTO)
+ if(p->to.name == NAME_AUTO)
checkauto(fn, p, p->to.node);
- if(p->to.type == arch.D_PARAM)
+ if(p->to.name == NAME_PARAM)
checkparam(fn, p, p->to.node);
}
int n;
n = 0;
- while(p != P && p->as == arch.AJMP && p->to.type == arch.D_BRANCH) {
+ while(p != P && p->as == arch.AJMP && p->to.type == TYPE_BRANCH) {
if(++n > 10) {
*jmploop = 1;
break;
if(p->opt != dead)
break;
p->opt = alive;
- if(p->as != arch.ACALL && p->to.type == arch.D_BRANCH && p->to.u.branch)
+ if(p->as != arch.ACALL && p->to.type == TYPE_BRANCH && p->to.u.branch)
mark(p->to.u.branch);
if(p->as == arch.AJMP || p->as == arch.ARET || p->as == arch.AUNDEF)
break;
for(p=firstp; p; p=p->link) {
if(debug['R'] && debug['v'])
print("%P\n", p);
- if(p->as != arch.ACALL && p->to.type == arch.D_BRANCH && p->to.u.branch && p->to.u.branch->as == arch.AJMP) {
+ if(p->as != arch.ACALL && p->to.type == TYPE_BRANCH && p->to.u.branch && p->to.u.branch->as == arch.AJMP) {
p->to.u.branch = chasejmp(p->to.u.branch, &jmploop);
if(debug['R'] && debug['v'])
print("->%P\n", p);
if(!jmploop) {
last = nil;
for(p=firstp; p; p=p->link) {
- if(p->as == arch.AJMP && p->to.type == arch.D_BRANCH && p->to.u.branch == p->link) {
+ if(p->as == arch.AJMP && p->to.type == TYPE_BRANCH && p->to.u.branch == p->link) {
if(debug['R'] && debug['v'])
print("del %P\n", p);
continue;
f->s1 = f1;
f1->p1 = f;
}
- if(p->to.type == arch.D_BRANCH) {
+ if(p->to.type == TYPE_BRANCH) {
if(p->to.u.branch == P)
fatal("pnil %P", p);
f1 = p->to.u.branch->opt;
dwfunc->hash = varhash; // enable indexing of children by name
memset(varhash, 0, sizeof varhash);
for(a = s->autom; a; a = a->link) {
- switch (a->type) {
+ switch (a->name) {
case A_AUTO:
dt = DW_ABRV_AUTO;
offs = a->aoffset - PtrSize;
for(a=s->autom; a; a=a->link) {
// Emit a or p according to actual offset, even if label is wrong.
// This avoids negative offsets, which cannot be encoded.
- if(a->type != A_AUTO && a->type != A_PARAM)
+ if(a->name != A_AUTO && a->name != A_PARAM)
continue;
// compute offset relative to FP
- if(a->type == A_PARAM)
+ if(a->name == A_PARAM)
off = a->aoffset;
else
off = a->aoffset - PtrSize;
ctxt->diag("data out of order (already have %d)\n%P", p);
symgrow(ctxt, s, off+siz);
- if(p->to.type == ctxt->arch->D_FCONST) {
+ if(p->to.type == TYPE_FCONST) {
switch(siz) {
default:
case 4:
s->p[off+i] = cast[fnuxi8[i]];
break;
}
- } else if(p->to.type == ctxt->arch->D_SCONST) {
+ } else if(p->to.type == TYPE_SCONST) {
for(i=0; i<siz; i++)
s->p[off+i] = p->to.u.sval[i];
- } else if(p->to.type == ctxt->arch->D_CONST) {
+ } else if(p->to.type == TYPE_CONST) {
if(p->to.sym)
goto addr;
o = p->to.offset;
s->p[off+i] = cast[inuxi8[i]];
break;
}
- } else if(p->to.type == ctxt->arch->D_ADDR) {
+ } else if(p->to.type == TYPE_ADDR) {
addr:
r = addrel(s);
r->off = off;
a = emallocz(sizeof *a);
a->asym = p->from.sym;
a->aoffset = p->from.offset;
- a->type = ctxt->arch->symtype(&p->from);
+ a->name = p->from.name;
a->gotype = p->from.gotype;
a->link = curtext->autom;
curtext->autom = a;
if(curtext == nil) // func _() {}
continue;
if(strcmp(p->to.sym->name, "go_args_stackmap") == 0) {
- if(p->from.type != ctxt->arch->D_CONST || p->from.offset != FUNCDATA_ArgsPointerMaps)
+ if(p->from.type != TYPE_CONST || p->from.offset != FUNCDATA_ArgsPointerMaps)
ctxt->diag("FUNCDATA use of go_args_stackmap(SB) without FUNCDATA_ArgsPointerMaps");
p->to.sym = linklookup(ctxt, smprint("%s.args_stackmap", curtext->name), curtext->version);
}
continue;
found = 0;
for(p = s->text; p != nil; p = p->link) {
- if(p->as == ctxt->arch->AFUNCDATA && p->from.type == ctxt->arch->D_CONST && p->from.offset == FUNCDATA_ArgsPointerMaps) {
+ if(p->as == ctxt->arch->AFUNCDATA && p->from.type == TYPE_CONST && p->from.offset == FUNCDATA_ArgsPointerMaps) {
found = 1;
break;
}
if(!found) {
p = appendp(ctxt, s->text);
p->as = ctxt->arch->AFUNCDATA;
- p->from.type = ctxt->arch->D_CONST;
+ p->from.type = TYPE_CONST;
p->from.offset = FUNCDATA_ArgsPointerMaps;
- if(ctxt->arch->thechar == '6' || ctxt->arch->thechar == '8')
- p->to.type = ctxt->arch->D_EXTERN;
- else {
- p->to.type = ctxt->arch->D_OREG;
- p->to.name = ctxt->arch->D_EXTERN;
- }
+ p->to.type = TYPE_MEM;
+ p->to.name = NAME_EXTERN;
p->to.sym = linklookup(ctxt, smprint("%s.args_stackmap", s->name), s->version);
}
}
mkfwd(s);
linkpatch(ctxt, s);
ctxt->arch->follow(ctxt, s);
- ctxt->arch->addstacksplit(ctxt, s);
+ ctxt->arch->preprocess(ctxt, s);
ctxt->arch->assemble(ctxt, s);
linkpcln(ctxt, s);
}
for(a = s->autom; a != nil; a = a->link) {
wrsym(b, a->asym);
wrint(b, a->aoffset);
- if(a->type == ctxt->arch->D_AUTO)
+ if(a->name == NAME_AUTO)
wrint(b, A_AUTO);
- else if(a->type == ctxt->arch->D_PARAM)
+ else if(a->name == NAME_PARAM)
wrint(b, A_PARAM);
else
- sysfatal("%s: invalid local variable type %d", s->name, a->type);
+ sysfatal("%s: invalid local variable type %d", s->name, a->name);
wrsym(b, a->gotype);
}
a = emallocz(sizeof *a);
a->asym = rdsym(ctxt, f, pkg);
a->aoffset = rdint(f);
- a->type = rdint(f);
+ a->name = rdint(f);
a->gotype = rdsym(ctxt, f, pkg);
a->link = s->autom;
s->autom = a;
for(p = sym->text; p != nil; p = p->link) {
if(ctxt->arch->progedit)
ctxt->arch->progedit(ctxt, p);
- if(p->to.type != ctxt->arch->D_BRANCH)
+ if(p->to.type != TYPE_BRANCH)
continue;
if(p->to.u.branch != nil) {
// TODO: Remove to.u.branch in favor of p->pcond.
if(p->to.sym)
name = p->to.sym->name;
ctxt->diag("branch out of range (%#ux)\n%P [%s]", c, p, name);
- p->to.type = ctxt->arch->D_NONE;
+ p->to.type = TYPE_NONE;
}
p->to.u.branch = q;
p->pcond = q;
if(p->pcond != nil) {
p->pcond = brloop(ctxt, p->pcond);
if(p->pcond != nil)
- if(p->to.type == ctxt->arch->D_BRANCH)
+ if(p->to.type == TYPE_BRANCH)
p->to.offset = p->pcond->pc;
}
}
if(p->as == ctxt->arch->AFUNCDATA) {
i = p->from.offset;
pcln->funcdataoff[i] = p->to.offset;
- if(p->to.type != ctxt->arch->D_CONST) {
+ if(p->to.type != TYPE_CONST) {
// TODO: Dedup.
//funcdata_bytes += p->to.sym->size;
pcln->funcdata[i] = p->to.sym;