tmp.op = OADDR;
tmp.left = &n2;
p1 = gins(AMOVW, &tmp, &n3);
- p1->from.scale = w;
+ p1->reg = w;
} else {
nodconst(&n1, t, w);
gins(optoas(OMUL, t), &n1, &n2);
/*
* block copy:
- * memmove(&n, &ns, w);
+ * memmove(&res, &n, w);
*/
void
-sgen(Node *n, Node *ns, int32 w)
+sgen(Node *n, Node *res, int32 w)
{
Node nodl, nodr, ndat, nend;
int32 c, q, odst, osrc;
if(debug['g']) {
print("\nsgen w=%d\n", w);
dump("r", n);
- dump("res", ns);
+ dump("res", res);
}
if(w == 0)
return;
- if(n->ullman >= UINF && ns->ullman >= UINF) {
+ if(n->ullman >= UINF && res->ullman >= UINF) {
fatal("sgen UINF");
}
// offset on the stack
osrc = stkof(n);
- odst = stkof(ns);
+ odst = stkof(res);
regalloc(&nodl, types[tptr], N);
regalloc(&nodr, types[tptr], N);
regalloc(&ndat, types[TUINT32], N);
- if(n->ullman >= ns->ullman) {
+ if(n->ullman >= res->ullman) {
agen(n, &nodr);
- agen(ns, &nodl);
+ agen(res, &nodl);
} else {
- agen(ns, &nodl);
+ agen(res, &nodl);
agen(n, &nodr);
}
// normal direction
if(q >= 4) {
regalloc(&nend, types[TUINT32], N);
- p = gins(AMOVW, &nodl, &nend);
+ p = gins(AMOVW, &nodr, &nend);
p->from.type = D_CONST;
p->from.offset = q;
- p = gins(AMOVW, &nodl, &ndat);
+ p = gins(AMOVW, &nodr, &ndat);
p->from.type = D_OREG;
p->from.offset = 4;
p->scond |= C_PBIT;
- p = gins(AMOVW, &ndat, &nodr);
+ p = gins(AMOVW, &ndat, &nodl);
p->to.type = D_OREG;
p->to.offset = 4;
p->scond |= C_PBIT;
- gins(ACMP, &nodl, &nend);
+ gins(ACMP, &nodr, &nend);
fatal("sgen loop not implemented");
p = gins(ABNE, N, N);
// TODO(PC offset)
regfree(&nend);
} else
while(q > 0) {
- p = gins(AMOVW, &nodl, &ndat);
+ p = gins(AMOVW, &nodr, &ndat);
p->from.type = D_OREG;
p->from.offset = 4;
p->scond |= C_PBIT;
- p = gins(AMOVW, &ndat, &nodr);
+ p = gins(AMOVW, &ndat, &nodl);
p->to.type = D_OREG;
p->to.offset = 4;
p->scond |= C_PBIT;
zprog.from.type = D_NONE;
zprog.from.name = D_NONE;
zprog.from.reg = NREG;
- zprog.from.scale = 0;
zprog.to = zprog.from;
listinit();
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-
#include <u.h>
#include <libc.h>
char name;
char reg;
uchar etype;
- uchar scale; /* doubles as width in DATA op */
};
#define A ((Addr*)0)
struct Prog
{
- short as; // opcode
+ short as; // opcode
uint32 loc; // pc offset in this func
uint32 lineno; // source line that generated this
Addr from; // src address
- Addr to; // dst address
+ Addr to; // dst address
Prog* link; // next instruction in this func
- char reg;
+ char reg; // doubles as width in DATA op
uchar scond;
};
}
p = gins(ADATA, &nam, nr->left);
- p->from.scale = types[tptr]->width;
- p->to.type = D_ADDR;
+ p->reg = types[tptr]->width;
+ p->to.type = D_CONST;
//print("%P\n", p);
nodconst(&nod1, types[TINT32], nr->left->type->bound);
p = gins(ADATA, &nam, &nod1);
- p->from.scale = types[TINT32]->width;
+ p->reg = types[TINT32]->width;
p->from.offset += types[tptr]->width;
//print("%P\n", p);
p = gins(ADATA, &nam, &nod1);
- p->from.scale = types[TINT32]->width;
+ p->reg = types[TINT32]->width;
p->from.offset += types[tptr]->width+types[TINT32]->width;
goto yes;
case TFLOAT64:
case TFLOAT:
p = gins(ADATA, &nam, nr);
- p->from.scale = nr->type->width;
+ p->reg = nr->type->width;
break;
case TSTRING:
p = gins(ADATA, &nam, N);
datastring(nr->val.u.sval->s, nr->val.u.sval->len, &p->to);
- p->from.scale = types[tptr]->width;
- p->to.type = D_ADDR;
+ p->reg = types[tptr]->width;
+ p->to.type = D_CONST;
//print("%P\n", p);
nodconst(&nod1, types[TINT32], nr->val.u.sval->len);
p = gins(ADATA, &nam, &nod1);
- p->from.scale = types[TINT32]->width;
+ p->reg = types[TINT32]->width;
p->from.offset += types[tptr]->width;
//print("%P\n", p);
p = gins(ADATA, &nam, &nod1);
- p->from.scale = types[TINT32]->width;
+ p->reg = types[TINT32]->width;
p->from.offset += types[tptr]->width+types[TINT32]->width;
break;
}
case D_REG:
case D_FREG:
case D_PSR:
- case D_ADDR:
break;
case D_CONST2:
p->from = ao;
p->from.offset = w;
- p->from.scale = NSNAME;
+ p->reg = NSNAME;
if(w+8 > len)
- p->from.scale = len-w;
+ p->reg = len-w;
p->to = ac;
p->to.type = D_SCONST;
p->to.offset = len;
- memmove(p->to.sval, s+w, p->from.scale);
+ memmove(p->to.sval, s+w, p->reg);
}
p = pc;
ggloblsym(ao.sym, len, ao.name == D_EXTERN);
// $string len+ptr
datastring(sval->s, sval->len, &ap);
- ap.type = D_ADDR;
+ ap.type = D_CONST;
ap.etype = TINT32;
wi = types[TUINT32]->width;
wp = types[tptr]->width;
p = pc;
gins(ADATA, N, N);
p->from = ao;
- p->from.scale = wp;
+ p->reg = wp;
p->to = ap;
// DATA gostring+wp, wi, $len
gins(ADATA, N, N);
p->from = ao;
p->from.offset = wp;
- p->from.scale = wi;
+ p->reg = wi;
p->to = ac;
p->to.offset = sval->len;
p->from.name = D_EXTERN;
p->from.sym = s;
p->from.offset = off;
- p->from.scale = widthptr;
+ p->reg = widthptr;
datastring(str, strlen(str)+1, &p->to);
- p->to.type = D_ADDR;
+ p->to.type = D_CONST;
p->to.etype = TINT32;
off += widthptr;
p->from.name = D_EXTERN;
p->from.sym = s;
p->from.offset = off;
- p->from.scale = wid;
+ p->reg = wid;
p->to.type = D_CONST;
p->to.name = D_NONE;
p->to.offset = v;
p->from.name = D_EXTERN;
p->from.sym = s;
p->from.offset = off;
- p->from.scale = widthptr;
- p->to.type = D_ADDR;
+ p->reg = widthptr;
+ p->to.type = D_CONST;
p->to.name = D_EXTERN;
p->to.sym = x;
p->to.offset = 0;
// p->from.sym = b->sym;
// p->to.type = D_CONST;
// p->to.offset = 0;
-// p->from.scale = 7;
+// p->reg = 7;
// //print("1. %P\n", p);
// loaded = 0;
p->to.name = D_NONE;
p->to.offset = width;
if(dupok)
- p->from.scale = DUPOK;
+ p->reg = DUPOK;
}
int
void
naddr(Node *n, Addr *a)
{
- a->scale = 0;
a->type = D_NONE;
a->name = D_NONE;
a->reg = NREG;
break;
case ADATA:
- sconsize = p->from.scale;
+ sconsize = p->reg;
snprint(str, sizeof(str), "%.4ld (%4ld) %-7A %D/%d,%D",
p->loc, p->lineno, p->as, &p->from, sconsize, &p->to);
break;
case D_FREG:
case D_PSR:
case D_FPCR:
- case D_ADDR:
break;
case D_REGREG: