Commit b2797f2a authored by Dave Cheney's avatar Dave Cheney

cmd/{5,6,8}g: reduce size of Prog and Addr

5g: Prog went from 128 bytes to 88 bytes
6g: Prog went from 174 bytes to 144 bytes
8g: Prog went from 124 bytes to 92 bytes

There may be a little more that can be squeezed out of Addr, but alignment will be a factor.

All: remove the unused pun field from Addr

R=rsc, minux.ma
CC=golang-dev
https://golang.org/cl/6922048
parent 0df58a4b
...@@ -15,9 +15,13 @@ struct Addr ...@@ -15,9 +15,13 @@ struct Addr
{ {
int32 offset; int32 offset;
int32 offset2; int32 offset2;
double dval;
Prog* branch; union {
char sval[NSNAME]; double dval;
vlong vval;
Prog* branch;
char sval[NSNAME];
} u;
Sym* sym; Sym* sym;
Node* node; Node* node;
...@@ -25,22 +29,21 @@ struct Addr ...@@ -25,22 +29,21 @@ struct Addr
uchar type; uchar type;
char name; char name;
uchar reg; uchar reg;
char pun;
uchar etype; uchar etype;
}; };
#define A ((Addr*)0) #define A ((Addr*)0)
struct Prog struct Prog
{ {
short as; // opcode
uint32 loc; // pc offset in this func uint32 loc; // pc offset in this func
uint32 lineno; // source line that generated this uint32 lineno; // source line that generated this
Addr from; // src address
Addr to; // dst address
Prog* link; // next instruction in this func Prog* link; // next instruction in this func
void* regp; // points to enclosing Reg struct void* regp; // points to enclosing Reg struct
short as; // opcode
uchar reg; // doubles as width in DATA op uchar reg; // doubles as width in DATA op
uchar scond; uchar scond;
Addr from; // src address
Addr to; // dst address
}; };
#define TEXTFLAG reg #define TEXTFLAG reg
......
...@@ -128,9 +128,9 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -128,9 +128,9 @@ zaddr(Biobuf *b, Addr *a, int s)
break; break;
case D_BRANCH: case D_BRANCH:
if(a->branch == nil) if(a->u.branch == nil)
fatal("unpatched branch"); fatal("unpatched branch");
a->offset = a->branch->loc; a->offset = a->u.branch->loc;
l = a->offset; l = a->offset;
Bputc(b, l); Bputc(b, l);
Bputc(b, l>>8); Bputc(b, l>>8);
...@@ -139,7 +139,7 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -139,7 +139,7 @@ zaddr(Biobuf *b, Addr *a, int s)
break; break;
case D_SCONST: case D_SCONST:
n = a->sval; n = a->u.sval;
for(i=0; i<NSNAME; i++) { for(i=0; i<NSNAME; i++) {
Bputc(b, *n); Bputc(b, *n);
n++; n++;
...@@ -152,7 +152,7 @@ zaddr(Biobuf *b, Addr *a, int s) ...@@ -152,7 +152,7 @@ zaddr(Biobuf *b, Addr *a, int s)
break; break;
case D_FCONST: case D_FCONST:
ieeedtod(&e, a->dval); ieeedtod(&e, a->u.dval);
l = e; l = e;
Bputc(b, l); Bputc(b, l);
Bputc(b, l>>8); Bputc(b, l>>8);
...@@ -289,7 +289,7 @@ dsname(Sym *sym, int off, char *t, int n) ...@@ -289,7 +289,7 @@ dsname(Sym *sym, int off, char *t, int n)
p->to.name = D_NONE; p->to.name = D_NONE;
p->to.reg = NREG; p->to.reg = NREG;
p->to.offset = 0; p->to.offset = 0;
memmove(p->to.sval, t, n); memmove(p->to.u.sval, t, n);
return off + n; return off + n;
} }
...@@ -373,13 +373,13 @@ gdatacomplex(Node *nam, Mpcplx *cval) ...@@ -373,13 +373,13 @@ gdatacomplex(Node *nam, Mpcplx *cval)
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->reg = w; p->reg = w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->real); p->to.u.dval = mpgetflt(&cval->real);
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->reg = w; p->reg = w;
p->from.offset += w; p->from.offset += w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->imag); p->to.u.dval = mpgetflt(&cval->imag);
} }
void void
......
...@@ -123,7 +123,7 @@ gbranch(int as, Type *t, int likely) ...@@ -123,7 +123,7 @@ gbranch(int as, Type *t, int likely)
p = prog(as); p = prog(as);
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.branch = P; p->to.u.branch = P;
return p; return p;
} }
...@@ -135,7 +135,7 @@ patch(Prog *p, Prog *to) ...@@ -135,7 +135,7 @@ patch(Prog *p, Prog *to)
{ {
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("patch: not a branch"); fatal("patch: not a branch");
p->to.branch = to; p->to.u.branch = to;
p->to.offset = to->loc; p->to.offset = to->loc;
} }
...@@ -146,8 +146,8 @@ unpatch(Prog *p) ...@@ -146,8 +146,8 @@ unpatch(Prog *p)
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("unpatch: not a branch"); fatal("unpatch: not a branch");
q = p->to.branch; q = p->to.u.branch;
p->to.branch = P; p->to.u.branch = P;
p->to.offset = 0; p->to.offset = 0;
return q; return q;
} }
...@@ -1326,7 +1326,7 @@ naddr(Node *n, Addr *a, int canemitcode) ...@@ -1326,7 +1326,7 @@ naddr(Node *n, Addr *a, int canemitcode)
break; break;
case CTFLT: case CTFLT:
a->type = D_FCONST; a->type = D_FCONST;
a->dval = mpgetflt(n->val.u.fval); a->u.dval = mpgetflt(n->val.u.fval);
break; break;
case CTINT: case CTINT:
case CTRUNE: case CTRUNE:
......
...@@ -166,24 +166,24 @@ Dconv(Fmt *fp) ...@@ -166,24 +166,24 @@ Dconv(Fmt *fp)
break; break;
case D_BRANCH: case D_BRANCH:
if(a->branch == P || a->branch->loc == 0) { if(a->u.branch == P || a->u.branch->loc == 0) {
if(a->sym != S) if(a->sym != S)
sprint(str, "%s+%d(APC)", a->sym->name, a->offset); sprint(str, "%s+%d(APC)", a->sym->name, a->offset);
else else
sprint(str, "%d(APC)", a->offset); sprint(str, "%d(APC)", a->offset);
} else } else
if(a->sym != S) if(a->sym != S)
sprint(str, "%s+%d(APC)", a->sym->name, a->branch->loc); sprint(str, "%s+%d(APC)", a->sym->name, a->u.branch->loc);
else else
sprint(str, "%d(APC)", a->branch->loc); sprint(str, "%d(APC)", a->u.branch->loc);
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof(str), "$(%.17e)", a->dval); snprint(str, sizeof(str), "$(%.17e)", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof(str), "$\"%Y\"", a->sval); snprint(str, sizeof(str), "$\"%Y\"", a->u.sval);
break; break;
// TODO(kaib): Add back // TODO(kaib): Add back
......
...@@ -437,9 +437,9 @@ regopt(Prog *firstp) ...@@ -437,9 +437,9 @@ regopt(Prog *firstp)
for(r=firstr; r!=R; r=r->link) { for(r=firstr; r!=R; r=r->link) {
p = r->prog; p = r->prog;
if(p->to.type == D_BRANCH) { if(p->to.type == D_BRANCH) {
if(p->to.branch == P) if(p->to.u.branch == P)
fatal("pnil %P", p); fatal("pnil %P", p);
r1 = p->to.branch->regp; r1 = p->to.u.branch->regp;
if(r1 == R) if(r1 == R)
fatal("rnil %P", p); fatal("rnil %P", p);
if(r1 == r) { if(r1 == r) {
...@@ -704,8 +704,8 @@ brk: ...@@ -704,8 +704,8 @@ brk:
while(p->link != P && p->link->as == ANOP) while(p->link != P && p->link->as == ANOP)
p->link = p->link->link; p->link = p->link->link;
if(p->to.type == D_BRANCH) if(p->to.type == D_BRANCH)
while(p->to.branch != P && p->to.branch->as == ANOP) while(p->to.u.branch != P && p->to.u.branch->as == ANOP)
p->to.branch = p->to.branch->link; p->to.u.branch = p->to.u.branch->link;
if(p->as == AMOVW && p->to.reg == 13) { if(p->as == AMOVW && p->to.reg == 13) {
if(p->scond & C_WBIT) { if(p->scond & C_WBIT) {
vreg = -p->to.offset; // in adjust region vreg = -p->to.offset; // in adjust region
...@@ -1687,7 +1687,7 @@ chasejmp(Prog *p, int *jmploop) ...@@ -1687,7 +1687,7 @@ chasejmp(Prog *p, int *jmploop)
*jmploop = 1; *jmploop = 1;
break; break;
} }
p = p->to.branch; p = p->to.u.branch;
} }
return p; return p;
} }
...@@ -1709,8 +1709,8 @@ mark(Prog *firstp) ...@@ -1709,8 +1709,8 @@ mark(Prog *firstp)
if(p->regp != dead) if(p->regp != dead)
break; break;
p->regp = alive; p->regp = alive;
if(p->as != ABL && p->to.type == D_BRANCH && p->to.branch) if(p->as != ABL && p->to.type == D_BRANCH && p->to.u.branch)
mark(p->to.branch); mark(p->to.u.branch);
if(p->as == AB || p->as == ARET || (p->as == ABL && noreturn(p))) if(p->as == AB || p->as == ARET || (p->as == ABL && noreturn(p)))
break; break;
} }
...@@ -1730,8 +1730,8 @@ fixjmp(Prog *firstp) ...@@ -1730,8 +1730,8 @@ fixjmp(Prog *firstp)
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("%P\n", p); print("%P\n", p);
if(p->as != ABL && p->to.type == D_BRANCH && p->to.branch && p->to.branch->as == AB) { if(p->as != ABL && p->to.type == D_BRANCH && p->to.u.branch && p->to.u.branch->as == AB) {
p->to.branch = chasejmp(p->to.branch, &jmploop); p->to.u.branch = chasejmp(p->to.u.branch, &jmploop);
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("->%P\n", p); print("->%P\n", p);
} }
...@@ -1767,7 +1767,7 @@ fixjmp(Prog *firstp) ...@@ -1767,7 +1767,7 @@ fixjmp(Prog *firstp)
if(!jmploop) { if(!jmploop) {
last = nil; last = nil;
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(p->as == AB && p->to.type == D_BRANCH && p->to.branch == p->link) { if(p->as == AB && p->to.type == D_BRANCH && p->to.u.branch == p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("del %P\n", p); print("del %P\n", p);
continue; continue;
......
...@@ -14,9 +14,13 @@ typedef struct Addr Addr; ...@@ -14,9 +14,13 @@ typedef struct Addr Addr;
struct Addr struct Addr
{ {
vlong offset; vlong offset;
double dval;
Prog* branch; union {
char sval[NSNAME]; double dval;
vlong vval;
Prog* branch;
char sval[NSNAME];
} u;
Sym* gotype; Sym* gotype;
Sym* sym; Sym* sym;
...@@ -26,7 +30,6 @@ struct Addr ...@@ -26,7 +30,6 @@ struct Addr
uchar index; uchar index;
uchar etype; uchar etype;
uchar scale; /* doubles as width in DATA op */ uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
}; };
#define A ((Addr*)0) #define A ((Addr*)0)
......
...@@ -94,9 +94,9 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -94,9 +94,9 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
switch(a->type) { switch(a->type) {
case D_BRANCH: case D_BRANCH:
if(a->branch == nil) if(a->u.branch == nil)
fatal("unpatched branch"); fatal("unpatched branch");
a->offset = a->branch->loc; a->offset = a->u.branch->loc;
default: default:
t |= T_TYPE; t |= T_TYPE;
...@@ -139,7 +139,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -139,7 +139,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
if(t & T_SYM) /* implies sym */ if(t & T_SYM) /* implies sym */
Bputc(b, s); Bputc(b, s);
if(t & T_FCONST) { if(t & T_FCONST) {
ieeedtod(&e, a->dval); ieeedtod(&e, a->u.dval);
l = e; l = e;
Bputc(b, l); Bputc(b, l);
Bputc(b, l>>8); Bputc(b, l>>8);
...@@ -153,7 +153,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -153,7 +153,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
return; return;
} }
if(t & T_SCONST) { if(t & T_SCONST) {
n = a->sval; n = a->u.sval;
for(i=0; i<NSNAME; i++) { for(i=0; i<NSNAME; i++) {
Bputc(b, *n); Bputc(b, *n);
n++; n++;
...@@ -295,7 +295,7 @@ dsname(Sym *s, int off, char *t, int n) ...@@ -295,7 +295,7 @@ dsname(Sym *s, int off, char *t, int n)
p->to.type = D_SCONST; p->to.type = D_SCONST;
p->to.index = D_NONE; p->to.index = D_NONE;
memmove(p->to.sval, t, n); memmove(p->to.u.sval, t, n);
return off + n; return off + n;
} }
...@@ -364,13 +364,13 @@ gdatacomplex(Node *nam, Mpcplx *cval) ...@@ -364,13 +364,13 @@ gdatacomplex(Node *nam, Mpcplx *cval)
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->from.scale = w; p->from.scale = w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->real); p->to.u.dval = mpgetflt(&cval->real);
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->from.scale = w; p->from.scale = w;
p->from.offset += w; p->from.offset += w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->imag); p->to.u.dval = mpgetflt(&cval->imag);
} }
void void
......
...@@ -117,7 +117,7 @@ gbranch(int as, Type *t, int likely) ...@@ -117,7 +117,7 @@ gbranch(int as, Type *t, int likely)
p = prog(as); p = prog(as);
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.branch = P; p->to.u.branch = P;
if(as != AJMP && likely != 0) { if(as != AJMP && likely != 0) {
p->from.type = D_CONST; p->from.type = D_CONST;
p->from.offset = likely > 0; p->from.offset = likely > 0;
...@@ -133,7 +133,7 @@ patch(Prog *p, Prog *to) ...@@ -133,7 +133,7 @@ patch(Prog *p, Prog *to)
{ {
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("patch: not a branch"); fatal("patch: not a branch");
p->to.branch = to; p->to.u.branch = to;
p->to.offset = to->loc; p->to.offset = to->loc;
} }
...@@ -144,8 +144,8 @@ unpatch(Prog *p) ...@@ -144,8 +144,8 @@ unpatch(Prog *p)
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("unpatch: not a branch"); fatal("unpatch: not a branch");
q = p->to.branch; q = p->to.u.branch;
p->to.branch = P; p->to.u.branch = P;
p->to.offset = 0; p->to.offset = 0;
return q; return q;
} }
...@@ -1202,7 +1202,7 @@ naddr(Node *n, Addr *a, int canemitcode) ...@@ -1202,7 +1202,7 @@ naddr(Node *n, Addr *a, int canemitcode)
break; break;
case CTFLT: case CTFLT:
a->type = D_FCONST; a->type = D_FCONST;
a->dval = mpgetflt(n->val.u.fval); a->u.dval = mpgetflt(n->val.u.fval);
break; break;
case CTINT: case CTINT:
case CTRUNE: case CTRUNE:
......
...@@ -107,10 +107,10 @@ Dconv(Fmt *fp) ...@@ -107,10 +107,10 @@ Dconv(Fmt *fp)
break; break;
case D_BRANCH: case D_BRANCH:
if(a->branch == nil) if(a->u.branch == nil)
snprint(str, sizeof(str), "<nil>"); snprint(str, sizeof(str), "<nil>");
else else
snprint(str, sizeof(str), "%d", a->branch->loc); snprint(str, sizeof(str), "%d", a->u.branch->loc);
break; break;
case D_EXTERN: case D_EXTERN:
...@@ -140,11 +140,11 @@ Dconv(Fmt *fp) ...@@ -140,11 +140,11 @@ Dconv(Fmt *fp)
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof(str), "$(%.17e)", a->dval); snprint(str, sizeof(str), "$(%.17e)", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof(str), "$\"%Y\"", a->sval); snprint(str, sizeof(str), "$\"%Y\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
......
...@@ -1303,7 +1303,7 @@ loop: ...@@ -1303,7 +1303,7 @@ loop:
if(p->from.node == p0->from.node) if(p->from.node == p0->from.node)
if(p->from.offset == p0->from.offset) if(p->from.offset == p0->from.offset)
if(p->from.scale == p0->from.scale) if(p->from.scale == p0->from.scale)
if(p->from.dval == p0->from.dval) if(p->from.u.vval == p0->from.u.vval)
if(p->from.index == p0->from.index) { if(p->from.index == p0->from.index) {
excise(r); excise(r);
goto loop; goto loop;
......
...@@ -610,9 +610,9 @@ regopt(Prog *firstp) ...@@ -610,9 +610,9 @@ regopt(Prog *firstp)
for(r=firstr; r!=R; r=r->link) { for(r=firstr; r!=R; r=r->link) {
p = r->prog; p = r->prog;
if(p->to.type == D_BRANCH) { if(p->to.type == D_BRANCH) {
if(p->to.branch == P) if(p->to.u.branch == P)
fatal("pnil %P", p); fatal("pnil %P", p);
r1 = p->to.branch->reg; r1 = p->to.u.branch->reg;
if(r1 == R) if(r1 == R)
fatal("rnil %P", p); fatal("rnil %P", p);
if(r1 == r) { if(r1 == r) {
...@@ -804,8 +804,8 @@ brk: ...@@ -804,8 +804,8 @@ brk:
while(p->link != P && p->link->as == ANOP) while(p->link != P && p->link->as == ANOP)
p->link = p->link->link; p->link = p->link->link;
if(p->to.type == D_BRANCH) if(p->to.type == D_BRANCH)
while(p->to.branch != P && p->to.branch->as == ANOP) while(p->to.u.branch != P && p->to.u.branch->as == ANOP)
p->to.branch = p->to.branch->link; p->to.u.branch = p->to.u.branch->link;
} }
if(lastr != R) { if(lastr != R) {
...@@ -1751,7 +1751,7 @@ chasejmp(Prog *p, int *jmploop) ...@@ -1751,7 +1751,7 @@ chasejmp(Prog *p, int *jmploop)
*jmploop = 1; *jmploop = 1;
break; break;
} }
p = p->to.branch; p = p->to.u.branch;
} }
return p; return p;
} }
...@@ -1773,8 +1773,8 @@ mark(Prog *firstp) ...@@ -1773,8 +1773,8 @@ mark(Prog *firstp)
if(p->reg != dead) if(p->reg != dead)
break; break;
p->reg = alive; p->reg = alive;
if(p->as != ACALL && p->to.type == D_BRANCH && p->to.branch) if(p->as != ACALL && p->to.type == D_BRANCH && p->to.u.branch)
mark(p->to.branch); mark(p->to.u.branch);
if(p->as == AJMP || p->as == ARET || p->as == AUNDEF) if(p->as == AJMP || p->as == ARET || p->as == AUNDEF)
break; break;
} }
...@@ -1794,8 +1794,8 @@ fixjmp(Prog *firstp) ...@@ -1794,8 +1794,8 @@ fixjmp(Prog *firstp)
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("%P\n", p); print("%P\n", p);
if(p->as != ACALL && p->to.type == D_BRANCH && p->to.branch && p->to.branch->as == AJMP) { if(p->as != ACALL && p->to.type == D_BRANCH && p->to.u.branch && p->to.u.branch->as == AJMP) {
p->to.branch = chasejmp(p->to.branch, &jmploop); p->to.u.branch = chasejmp(p->to.u.branch, &jmploop);
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("->%P\n", p); print("->%P\n", p);
} }
...@@ -1831,7 +1831,7 @@ fixjmp(Prog *firstp) ...@@ -1831,7 +1831,7 @@ fixjmp(Prog *firstp)
if(!jmploop) { if(!jmploop) {
last = nil; last = nil;
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(p->as == AJMP && p->to.type == D_BRANCH && p->to.branch == p->link) { if(p->as == AJMP && p->to.type == D_BRANCH && p->to.u.branch == p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("del %P\n", p); print("del %P\n", p);
continue; continue;
......
...@@ -16,9 +16,12 @@ struct Addr ...@@ -16,9 +16,12 @@ struct Addr
int32 offset; int32 offset;
int32 offset2; int32 offset2;
double dval; union {
Prog* branch; double dval;
char sval[NSNAME]; vlong vval;
Prog* branch;
char sval[NSNAME];
} u;
Sym* gotype; Sym* gotype;
Sym* sym; Sym* sym;
...@@ -28,7 +31,6 @@ struct Addr ...@@ -28,7 +31,6 @@ struct Addr
uchar index; uchar index;
uchar etype; uchar etype;
uchar scale; /* doubles as width in DATA op */ uchar scale; /* doubles as width in DATA op */
uchar pun; /* dont register variable */
}; };
#define A ((Addr*)0) #define A ((Addr*)0)
......
...@@ -94,9 +94,9 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -94,9 +94,9 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
switch(a->type) { switch(a->type) {
case D_BRANCH: case D_BRANCH:
if(a->branch == nil) if(a->u.branch == nil)
fatal("unpatched branch"); fatal("unpatched branch");
a->offset = a->branch->loc; a->offset = a->u.branch->loc;
default: default:
t |= T_TYPE; t |= T_TYPE;
...@@ -137,7 +137,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -137,7 +137,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
if(t & T_SYM) /* implies sym */ if(t & T_SYM) /* implies sym */
Bputc(b, s); Bputc(b, s);
if(t & T_FCONST) { if(t & T_FCONST) {
ieeedtod(&e, a->dval); ieeedtod(&e, a->u.dval);
l = e; l = e;
Bputc(b, l); Bputc(b, l);
Bputc(b, l>>8); Bputc(b, l>>8);
...@@ -151,7 +151,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype) ...@@ -151,7 +151,7 @@ zaddr(Biobuf *b, Addr *a, int s, int gotype)
return; return;
} }
if(t & T_SCONST) { if(t & T_SCONST) {
n = a->sval; n = a->u.sval;
for(i=0; i<NSNAME; i++) { for(i=0; i<NSNAME; i++) {
Bputc(b, *n); Bputc(b, *n);
n++; n++;
...@@ -293,7 +293,7 @@ dsname(Sym *s, int off, char *t, int n) ...@@ -293,7 +293,7 @@ dsname(Sym *s, int off, char *t, int n)
p->to.type = D_SCONST; p->to.type = D_SCONST;
p->to.index = D_NONE; p->to.index = D_NONE;
memmove(p->to.sval, t, n); memmove(p->to.u.sval, t, n);
return off + n; return off + n;
} }
...@@ -373,13 +373,13 @@ gdatacomplex(Node *nam, Mpcplx *cval) ...@@ -373,13 +373,13 @@ gdatacomplex(Node *nam, Mpcplx *cval)
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->from.scale = w; p->from.scale = w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->real); p->to.u.dval = mpgetflt(&cval->real);
p = gins(ADATA, nam, N); p = gins(ADATA, nam, N);
p->from.scale = w; p->from.scale = w;
p->from.offset += w; p->from.offset += w;
p->to.type = D_FCONST; p->to.type = D_FCONST;
p->to.dval = mpgetflt(&cval->imag); p->to.u.dval = mpgetflt(&cval->imag);
} }
void void
......
...@@ -118,7 +118,7 @@ gbranch(int as, Type *t, int likely) ...@@ -118,7 +118,7 @@ gbranch(int as, Type *t, int likely)
USED(t); USED(t);
p = prog(as); p = prog(as);
p->to.type = D_BRANCH; p->to.type = D_BRANCH;
p->to.branch = P; p->to.u.branch = P;
if(likely != 0) { if(likely != 0) {
p->from.type = D_CONST; p->from.type = D_CONST;
p->from.offset = likely > 0; p->from.offset = likely > 0;
...@@ -134,7 +134,7 @@ patch(Prog *p, Prog *to) ...@@ -134,7 +134,7 @@ patch(Prog *p, Prog *to)
{ {
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("patch: not a branch"); fatal("patch: not a branch");
p->to.branch = to; p->to.u.branch = to;
p->to.offset = to->loc; p->to.offset = to->loc;
} }
...@@ -145,8 +145,8 @@ unpatch(Prog *p) ...@@ -145,8 +145,8 @@ unpatch(Prog *p)
if(p->to.type != D_BRANCH) if(p->to.type != D_BRANCH)
fatal("unpatch: not a branch"); fatal("unpatch: not a branch");
q = p->to.branch; q = p->to.u.branch;
p->to.branch = P; p->to.u.branch = P;
p->to.offset = 0; p->to.offset = 0;
return q; return q;
} }
...@@ -1932,7 +1932,7 @@ naddr(Node *n, Addr *a, int canemitcode) ...@@ -1932,7 +1932,7 @@ naddr(Node *n, Addr *a, int canemitcode)
break; break;
case CTFLT: case CTFLT:
a->type = D_FCONST; a->type = D_FCONST;
a->dval = mpgetflt(n->val.u.fval); a->u.dval = mpgetflt(n->val.u.fval);
break; break;
case CTINT: case CTINT:
case CTRUNE: case CTRUNE:
......
...@@ -107,7 +107,7 @@ Dconv(Fmt *fp) ...@@ -107,7 +107,7 @@ Dconv(Fmt *fp)
break; break;
case D_BRANCH: case D_BRANCH:
snprint(str, sizeof(str), "%d", a->branch->loc); snprint(str, sizeof(str), "%d", a->u.branch->loc);
break; break;
case D_EXTERN: case D_EXTERN:
...@@ -137,11 +137,11 @@ Dconv(Fmt *fp) ...@@ -137,11 +137,11 @@ Dconv(Fmt *fp)
break; break;
case D_FCONST: case D_FCONST:
snprint(str, sizeof(str), "$(%.17e)", a->dval); snprint(str, sizeof(str), "$(%.17e)", a->u.dval);
break; break;
case D_SCONST: case D_SCONST:
snprint(str, sizeof(str), "$\"%Y\"", a->sval); snprint(str, sizeof(str), "$\"%Y\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
......
...@@ -961,7 +961,7 @@ loop: ...@@ -961,7 +961,7 @@ loop:
if(p->from.node == p0->from.node) if(p->from.node == p0->from.node)
if(p->from.offset == p0->from.offset) if(p->from.offset == p0->from.offset)
if(p->from.scale == p0->from.scale) if(p->from.scale == p0->from.scale)
if(p->from.dval == p0->from.dval) if(p->from.u.vval == p0->from.u.vval)
if(p->from.index == p0->from.index) { if(p->from.index == p0->from.index) {
excise(r); excise(r);
goto loop; goto loop;
......
...@@ -507,9 +507,9 @@ regopt(Prog *firstp) ...@@ -507,9 +507,9 @@ regopt(Prog *firstp)
for(r=firstr; r!=R; r=r->link) { for(r=firstr; r!=R; r=r->link) {
p = r->prog; p = r->prog;
if(p->to.type == D_BRANCH) { if(p->to.type == D_BRANCH) {
if(p->to.branch == P) if(p->to.u.branch == P)
fatal("pnil %P", p); fatal("pnil %P", p);
r1 = p->to.branch->reg; r1 = p->to.u.branch->reg;
if(r1 == R) if(r1 == R)
fatal("rnil %P", p); fatal("rnil %P", p);
if(r1 == r) { if(r1 == r) {
...@@ -690,8 +690,8 @@ brk: ...@@ -690,8 +690,8 @@ brk:
while(p->link != P && p->link->as == ANOP) while(p->link != P && p->link->as == ANOP)
p->link = p->link->link; p->link = p->link->link;
if(p->to.type == D_BRANCH) if(p->to.type == D_BRANCH)
while(p->to.branch != P && p->to.branch->as == ANOP) while(p->to.u.branch != P && p->to.u.branch->as == ANOP)
p->to.branch = p->to.branch->link; p->to.u.branch = p->to.u.branch->link;
} }
if(lastr != R) { if(lastr != R) {
...@@ -1600,7 +1600,7 @@ chasejmp(Prog *p, int *jmploop) ...@@ -1600,7 +1600,7 @@ chasejmp(Prog *p, int *jmploop)
*jmploop = 1; *jmploop = 1;
break; break;
} }
p = p->to.branch; p = p->to.u.branch;
} }
return p; return p;
} }
...@@ -1622,8 +1622,8 @@ mark(Prog *firstp) ...@@ -1622,8 +1622,8 @@ mark(Prog *firstp)
if(p->reg != dead) if(p->reg != dead)
break; break;
p->reg = alive; p->reg = alive;
if(p->as != ACALL && p->to.type == D_BRANCH && p->to.branch) if(p->as != ACALL && p->to.type == D_BRANCH && p->to.u.branch)
mark(p->to.branch); mark(p->to.u.branch);
if(p->as == AJMP || p->as == ARET || p->as == AUNDEF) if(p->as == AJMP || p->as == ARET || p->as == AUNDEF)
break; break;
} }
...@@ -1643,8 +1643,8 @@ fixjmp(Prog *firstp) ...@@ -1643,8 +1643,8 @@ fixjmp(Prog *firstp)
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("%P\n", p); print("%P\n", p);
if(p->as != ACALL && p->to.type == D_BRANCH && p->to.branch && p->to.branch->as == AJMP) { if(p->as != ACALL && p->to.type == D_BRANCH && p->to.u.branch && p->to.u.branch->as == AJMP) {
p->to.branch = chasejmp(p->to.branch, &jmploop); p->to.u.branch = chasejmp(p->to.u.branch, &jmploop);
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("->%P\n", p); print("->%P\n", p);
} }
...@@ -1680,7 +1680,7 @@ fixjmp(Prog *firstp) ...@@ -1680,7 +1680,7 @@ fixjmp(Prog *firstp)
if(!jmploop) { if(!jmploop) {
last = nil; last = nil;
for(p=firstp; p; p=p->link) { for(p=firstp; p; p=p->link) {
if(p->as == AJMP && p->to.type == D_BRANCH && p->to.branch == p->link) { if(p->as == AJMP && p->to.type == D_BRANCH && p->to.u.branch == p->link) {
if(debug['R'] && debug['v']) if(debug['R'] && debug['v'])
print("del %P\n", p); print("del %P\n", p);
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment