Commit 76fed542 authored by Russ Cox's avatar Russ Cox

liblink: the zero Prog is now valid and ready for use

Use AXXX instead of AGOK (neither is a valid instruction but AXXX is zero)
for the initial setting of Prog.as, and now there are no non-zero default
field settings.

Remove the arch-specific zprog/zprg in favor of a single global zprog.
Remove the arch-specific prg constructor in favor of emallocz(sizeof(Prog)).

Change-Id: Ia73078726768333d7cdba296f548170c1bea9498
Reviewed-on: https://go-review.googlesource.com/3575Reviewed-by: default avatarAram Hăvărneanu <aram@mgk.ro>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 66541881
...@@ -247,6 +247,8 @@ struct Prog ...@@ -247,6 +247,8 @@ struct Prog
char mode; /* 16, 32, or 64 in 6l, 8l; internal use in 5g, 6g, 8g */ char mode; /* 16, 32, or 64 in 6l, 8l; internal use in 5g, 6g, 8g */
}; };
extern Prog zprog; // zeroed Prog
// prevent incompatible type signatures between liblink and 8l on Plan 9 // prevent incompatible type signatures between liblink and 8l on Plan 9
#pragma incomplete struct Section #pragma incomplete struct Section
...@@ -600,7 +602,6 @@ struct LinkArch ...@@ -600,7 +602,6 @@ struct LinkArch
void (*follow)(Link*, LSym*); void (*follow)(Link*, LSym*);
int (*iscall)(Prog*); int (*iscall)(Prog*);
int (*isdata)(Prog*); int (*isdata)(Prog*);
Prog* (*prg)(void);
void (*progedit)(Link*, Prog*); void (*progedit)(Link*, Prog*);
int minlc; int minlc;
......
...@@ -36,10 +36,6 @@ betypeinit(void) ...@@ -36,10 +36,6 @@ betypeinit(void)
widthint = 4; widthint = 4;
widthreg = 4; widthreg = 4;
zprog.as = AGOK;
zprog.scond = C_SCOND_NONE;
arch.zprog = zprog;
listinit5(); listinit5();
} }
...@@ -50,7 +46,6 @@ main(int argc, char **argv) ...@@ -50,7 +46,6 @@ main(int argc, char **argv)
arch.thestring = thestring; arch.thestring = thestring;
arch.thelinkarch = thelinkarch; arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs; arch.typedefs = typedefs;
arch.zprog = zprog;
arch.ACALL = ABL; arch.ACALL = ABL;
arch.ACHECKNIL = ACHECKNIL; arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA; arch.ADATA = ADATA;
......
...@@ -21,7 +21,6 @@ EXTERN int32 dynloc; ...@@ -21,7 +21,6 @@ EXTERN int32 dynloc;
EXTERN uchar reg[REGALLOC_FMAX+1]; EXTERN uchar reg[REGALLOC_FMAX+1];
EXTERN int32 pcloc; // instruction counter EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring; EXTERN Strlit emptystring;
EXTERN Prog zprog;
extern long unmappedzero; extern long unmappedzero;
/* /*
......
...@@ -1414,7 +1414,7 @@ optoas(int op, Type *t) ...@@ -1414,7 +1414,7 @@ optoas(int op, Type *t)
if(t == T) if(t == T)
fatal("optoas: t is nil"); fatal("optoas: t is nil");
a = AGOK; a = AXXX;
switch(CASE(op, simtype[t->etype])) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry %O-%T etype %T simtype %T", op, t, types[t->etype], types[simtype[t->etype]]); fatal("optoas: no entry %O-%T etype %T simtype %T", op, t, types[t->etype], types[simtype[t->etype]]);
......
...@@ -1385,7 +1385,6 @@ predicable(Prog *p) ...@@ -1385,7 +1385,6 @@ predicable(Prog *p)
case AXXX: case AXXX:
case ADATA: case ADATA:
case AGLOBL: case AGLOBL:
case AGOK:
case AHISTORY: case AHISTORY:
case ANAME: case ANAME:
case ASIGNAME: case ASIGNAME:
......
...@@ -253,7 +253,6 @@ enum ...@@ -253,7 +253,6 @@ enum
ADATA, ADATA,
AGLOBL, AGLOBL,
AGOK,
AHISTORY, AHISTORY,
ANAME, ANAME,
ARET, ARET,
......
...@@ -59,14 +59,6 @@ betypeinit(void) ...@@ -59,14 +59,6 @@ betypeinit(void)
} }
zprog.link = P;
zprog.as = AGOK;
zprog.from.type = TYPE_NONE;
zprog.from.index = TYPE_NONE;
zprog.from.scale = 0;
zprog.to = zprog.from;
arch.zprog = zprog;
listinit6(); listinit6();
} }
...@@ -77,7 +69,6 @@ main(int argc, char **argv) ...@@ -77,7 +69,6 @@ main(int argc, char **argv)
arch.thestring = thestring; arch.thestring = thestring;
arch.thelinkarch = thelinkarch; arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs; arch.typedefs = typedefs;
arch.zprog = zprog;
arch.ACALL = ACALL; arch.ACALL = ACALL;
arch.ACHECKNIL = ACHECKNIL; arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA; arch.ADATA = ADATA;
......
...@@ -13,7 +13,6 @@ EXTERN int32 dynloc; ...@@ -13,7 +13,6 @@ EXTERN int32 dynloc;
EXTERN uchar reg[MAXREG]; EXTERN uchar reg[MAXREG];
EXTERN int32 pcloc; // instruction counter EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring; EXTERN Strlit emptystring;
EXTERN Prog zprog;
EXTERN Node* panicdiv; EXTERN Node* panicdiv;
extern vlong unmappedzero; extern vlong unmappedzero;
extern int addptr; extern int addptr;
......
...@@ -1329,7 +1329,7 @@ optoas(int op, Type *t) ...@@ -1329,7 +1329,7 @@ optoas(int op, Type *t)
if(t == T) if(t == T)
fatal("optoas: t is nil"); fatal("optoas: t is nil");
a = AGOK; a = AXXX;
switch(CASE(op, simtype[t->etype])) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry %O-%T", op, t); fatal("optoas: no entry %O-%T", op, t);
......
...@@ -93,7 +93,6 @@ enum ...@@ -93,7 +93,6 @@ enum
ADIVW, ADIVW,
AENTER, AENTER,
AGLOBL, AGLOBL,
AGOK,
AHISTORY, AHISTORY,
AHLT, AHLT,
AIDIVB, AIDIVB,
......
...@@ -36,14 +36,6 @@ betypeinit(void) ...@@ -36,14 +36,6 @@ betypeinit(void)
widthint = 4; widthint = 4;
widthreg = 4; widthreg = 4;
zprog.link = P;
zprog.as = AGOK;
zprog.from.type = TYPE_NONE;
zprog.from.index = TYPE_NONE;
zprog.from.scale = 0;
zprog.to = zprog.from;
arch.zprog = zprog;
listinit8(); listinit8();
} }
...@@ -54,7 +46,6 @@ main(int argc, char **argv) ...@@ -54,7 +46,6 @@ main(int argc, char **argv)
arch.thestring = thestring; arch.thestring = thestring;
arch.thelinkarch = thelinkarch; arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs; arch.typedefs = typedefs;
arch.zprog = zprog;
arch.ACALL = ACALL; arch.ACALL = ACALL;
arch.ACHECKNIL = ACHECKNIL; arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA; arch.ADATA = ADATA;
......
...@@ -21,7 +21,6 @@ EXTERN int32 dynloc; ...@@ -21,7 +21,6 @@ EXTERN int32 dynloc;
EXTERN uchar reg[MAXREG]; EXTERN uchar reg[MAXREG];
EXTERN int32 pcloc; // instruction counter EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring; EXTERN Strlit emptystring;
EXTERN Prog zprog;
EXTERN Node* panicdiv; EXTERN Node* panicdiv;
extern uint32 unmappedzero; extern uint32 unmappedzero;
......
...@@ -271,7 +271,7 @@ optoas(int op, Type *t) ...@@ -271,7 +271,7 @@ optoas(int op, Type *t)
if(t == T) if(t == T)
fatal("optoas: t is nil"); fatal("optoas: t is nil");
a = AGOK; a = AXXX;
switch(CASE(op, simtype[t->etype])) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry %O-%T", op, t); fatal("optoas: no entry %O-%T", op, t);
...@@ -690,7 +690,7 @@ foptoas(int op, Type *t, int flg) ...@@ -690,7 +690,7 @@ foptoas(int op, Type *t, int flg)
{ {
int et, a; int et, a;
a = AGOK; a = AXXX;
et = simtype[t->etype]; et = simtype[t->etype];
if(use_sse) if(use_sse)
......
...@@ -88,7 +88,6 @@ enum ...@@ -88,7 +88,6 @@ enum
ADIVW, ADIVW,
AENTER, AENTER,
AGLOBL, AGLOBL,
AGOK,
AHISTORY, AHISTORY,
AHLT, AHLT,
AIDIVB, AIDIVB,
......
...@@ -670,7 +670,7 @@ outcode(int a, Addr *g1, int reg, Addr *g2) ...@@ -670,7 +670,7 @@ outcode(int a, Addr *g1, int reg, Addr *g2)
reg = g2->scale; reg = g2->scale;
} }
p = ctxt->arch->prg(); p = emallocz(sizeof(Prog));
p->as = a; p->as = a;
p->lineno = lineno; p->lineno = lineno;
if(nosched) if(nosched)
...@@ -700,7 +700,7 @@ outgcode(int a, Addr *g1, int reg, Addr *g2, Addr *g3) ...@@ -700,7 +700,7 @@ outgcode(int a, Addr *g1, int reg, Addr *g2, Addr *g3)
if(pass == 1) if(pass == 1)
goto out; goto out;
p = ctxt->arch->prg(); p = emallocz(sizeof(Prog));
p->as = a; p->as = a;
p->lineno = lineno; p->lineno = lineno;
if(nosched) if(nosched)
......
...@@ -43,9 +43,6 @@ betypeinit(void) ...@@ -43,9 +43,6 @@ betypeinit(void)
widthint = 8; widthint = 8;
widthreg = 8; widthreg = 8;
zprog.as = AGOK;
arch.zprog = zprog;
listinit9(); listinit9();
} }
...@@ -56,7 +53,6 @@ main(int argc, char **argv) ...@@ -56,7 +53,6 @@ main(int argc, char **argv)
arch.thestring = thestring; arch.thestring = thestring;
arch.thelinkarch = thelinkarch; arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs; arch.typedefs = typedefs;
arch.zprog = zprog;
arch.ACALL = ABL; arch.ACALL = ABL;
arch.ACHECKNIL = ACHECKNIL; arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA; arch.ADATA = ADATA;
......
...@@ -16,7 +16,6 @@ EXTERN int32 dynloc; ...@@ -16,7 +16,6 @@ EXTERN int32 dynloc;
EXTERN uchar reg[NREG+NFREG]; EXTERN uchar reg[NREG+NFREG];
EXTERN int32 pcloc; // instruction counter EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring; EXTERN Strlit emptystring;
EXTERN Prog zprog;
EXTERN Node* panicdiv; EXTERN Node* panicdiv;
extern vlong unmappedzero; extern vlong unmappedzero;
......
...@@ -1302,7 +1302,7 @@ optoas(int op, Type *t) ...@@ -1302,7 +1302,7 @@ optoas(int op, Type *t)
if(t == T) if(t == T)
fatal("optoas: t is nil"); fatal("optoas: t is nil");
a = AGOK; a = AXXX;
switch(CASE(op, simtype[t->etype])) { switch(CASE(op, simtype[t->etype])) {
default: default:
fatal("optoas: no entry for op=%O type=%T", op, t); fatal("optoas: no entry for op=%O type=%T", op, t);
......
...@@ -513,7 +513,6 @@ enum ...@@ -513,7 +513,6 @@ enum
ASYSCALL, ASYSCALL,
ADATA, ADATA,
AGLOBL, AGLOBL,
AGOK,
AHISTORY, AHISTORY,
ANAME, ANAME,
ANOP, ANOP,
......
...@@ -1657,7 +1657,6 @@ struct Arch ...@@ -1657,7 +1657,6 @@ struct Arch
char *thestring; char *thestring;
LinkArch *thelinkarch; LinkArch *thelinkarch;
Typedef *typedefs; Typedef *typedefs;
Prog zprog;
int ACALL; int ACALL;
int ACHECKNIL; int ACHECKNIL;
......
...@@ -621,7 +621,7 @@ mergetemp(Prog *firstp) ...@@ -621,7 +621,7 @@ mergetemp(Prog *firstp)
arch.proginfo(&info, p); arch.proginfo(&info, p);
if(p->to.node == v->node && (info.flags & RightWrite) && !(info.flags & RightRead)) { if(p->to.node == v->node && (info.flags & RightWrite) && !(info.flags & RightRead)) {
p->as = arch.ANOP; p->as = arch.ANOP;
p->to = arch.zprog.to; p->to = zprog.to;
v->removed = 1; v->removed = 1;
if(Debug) if(Debug)
print("drop write-only %S\n", v->node->sym); print("drop write-only %S\n", v->node->sym);
......
...@@ -351,11 +351,6 @@ static uint32 opbra(Link*, int, int); ...@@ -351,11 +351,6 @@ static uint32 opbra(Link*, int, int);
static Oprang oprange[ALAST]; static Oprang oprange[ALAST];
static uchar xcmp[C_GOK+1][C_GOK+1]; static uchar xcmp[C_GOK+1][C_GOK+1];
static Prog zprg = {
.as = AGOK,
.scond = C_SCOND_NONE,
};
static LSym *deferreturn; static LSym *deferreturn;
static void static void
...@@ -515,7 +510,7 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out) ...@@ -515,7 +510,7 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
// split it into two instructions: // split it into two instructions:
// ADD $-100004, R13 // ADD $-100004, R13
// MOVW R14, 0(R13) // MOVW R14, 0(R13)
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
p->scond &= ~C_WBIT; p->scond &= ~C_WBIT;
*q = *p; *q = *p;
a = &p->to; a = &p->to;
...@@ -534,12 +529,12 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out) ...@@ -534,12 +529,12 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
p->from = *a; p->from = *a;
p->from.reg = 0; p->from.reg = 0;
p->from.type = TYPE_CONST; p->from.type = TYPE_CONST;
p->to = zprg.to; p->to = zprog.to;
p->to.type = TYPE_REG; p->to.type = TYPE_REG;
p->to.reg = REG_R13; p->to.reg = REG_R13;
// make q into p but load/store from 0(R13) // make q into p but load/store from 0(R13)
q->spadj = 0; q->spadj = 0;
*a2 = zprg.from; *a2 = zprog.from;
a2->type = TYPE_MEM; a2->type = TYPE_MEM;
a2->reg = REG_R13; a2->reg = REG_R13;
a2->sym = nil; a2->sym = nil;
...@@ -578,7 +573,7 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out) ...@@ -578,7 +573,7 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
// This won't handle .W/.P, so we should reject such code. // This won't handle .W/.P, so we should reject such code.
if(p->scond & (C_PBIT|C_WBIT)) if(p->scond & (C_PBIT|C_WBIT))
ctxt->diag("unsupported instruction (.P/.W): %P", p); ctxt->diag("unsupported instruction (.P/.W): %P", p);
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
*q = *p; *q = *p;
if(p->to.type == TYPE_MEM) if(p->to.type == TYPE_MEM)
a2 = &q->to; a2 = &q->to;
...@@ -594,11 +589,11 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out) ...@@ -594,11 +589,11 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
p->as = AMOVW; p->as = AMOVW;
p->from = *a; p->from = *a;
p->from.type = TYPE_CONST; p->from.type = TYPE_CONST;
p->to = zprg.to; p->to = zprog.to;
p->to.type = TYPE_REG; p->to.type = TYPE_REG;
p->to.reg = REG_R11; p->to.reg = REG_R11;
// make q into p but load/store from 0(R11) // make q into p but load/store from 0(R11)
*a2 = zprg.from; *a2 = zprog.from;
a2->type = TYPE_MEM; a2->type = TYPE_MEM;
a2->reg = REG_R11; a2->reg = REG_R11;
a2->sym = nil; a2->sym = nil;
...@@ -731,14 +726,14 @@ span5(Link *ctxt, LSym *cursym) ...@@ -731,14 +726,14 @@ span5(Link *ctxt, LSym *cursym)
if(otxt < 0) if(otxt < 0)
otxt = -otxt; otxt = -otxt;
if(otxt >= (1L<<17) - 10) { if(otxt >= (1L<<17) - 10) {
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->link = p->link; q->link = p->link;
p->link = q; p->link = q;
q->as = AB; q->as = AB;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
q->pcond = p->pcond; q->pcond = p->pcond;
p->pcond = q; p->pcond = q;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->link = p->link; q->link = p->link;
p->link = q; p->link = q;
q->as = AB; q->as = AB;
...@@ -856,7 +851,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force) ...@@ -856,7 +851,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force)
if(ctxt->blitrl) { if(ctxt->blitrl) {
if(skip){ if(skip){
if(0 && skip==1)print("note: flush literal pool at %llux: len=%ud ref=%ux\n", p->pc+4, pool.size, pool.start); if(0 && skip==1)print("note: flush literal pool at %llux: len=%ud ref=%ux\n", p->pc+4, pool.size, pool.start);
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AB; q->as = AB;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
q->pcond = p->link; q->pcond = p->link;
...@@ -868,7 +863,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force) ...@@ -868,7 +863,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force)
return 0; return 0;
if(ctxt->headtype == Hnacl && pool.size % 16 != 0) { if(ctxt->headtype == Hnacl && pool.size % 16 != 0) {
// if pool is not multiple of 16 bytes, add an alignment marker // if pool is not multiple of 16 bytes, add an alignment marker
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = ADATABUNDLEEND; q->as = ADATABUNDLEEND;
ctxt->elitrl->link = q; ctxt->elitrl->link = q;
ctxt->elitrl = q; ctxt->elitrl = q;
...@@ -900,7 +895,7 @@ addpool(Link *ctxt, Prog *p, Addr *a) ...@@ -900,7 +895,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
c = aclass(ctxt, a); c = aclass(ctxt, a);
t = zprg; t = zprog;
t.as = AWORD; t.as = AWORD;
switch(c) { switch(c) {
...@@ -939,8 +934,8 @@ addpool(Link *ctxt, Prog *p, Addr *a) ...@@ -939,8 +934,8 @@ addpool(Link *ctxt, Prog *p, Addr *a)
if(ctxt->headtype == Hnacl && pool.size%16 == 0) { if(ctxt->headtype == Hnacl && pool.size%16 == 0) {
// start a new data bundle // start a new data bundle
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
*q = zprg; *q = zprog;
q->as = ADATABUNDLE; q->as = ADATABUNDLE;
q->pc = pool.size; q->pc = pool.size;
pool.size += 4; pool.size += 4;
...@@ -953,7 +948,7 @@ addpool(Link *ctxt, Prog *p, Addr *a) ...@@ -953,7 +948,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
ctxt->elitrl = q; ctxt->elitrl = q;
} }
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
*q = t; *q = t;
q->pc = pool.size; q->pc = pool.size;
......
...@@ -990,7 +990,6 @@ static Optab optab[] = ...@@ -990,7 +990,6 @@ static Optab optab[] =
{ AFXRSTOR64, ysvrs, Pw, {0x0f,0xae,(01),0x0f,0xae,(01)} }, { AFXRSTOR64, ysvrs, Pw, {0x0f,0xae,(01),0x0f,0xae,(01)} },
{ AFXSAVE64, ysvrs, Pw, {0x0f,0xae,(00),0x0f,0xae,(00)} }, { AFXSAVE64, ysvrs, Pw, {0x0f,0xae,(00),0x0f,0xae,(00)} },
{ AGLOBL }, { AGLOBL },
{ AGOK },
{ AHISTORY }, { AHISTORY },
{ AHLT, ynone, Px, {0xf4} }, { AHLT, ynone, Px, {0xf4} },
{ AIDIVB, ydivb, Pb, {0xf6,(07)} }, { AIDIVB, ydivb, Pb, {0xf6,(07)} },
......
...@@ -675,7 +675,6 @@ static Optab optab[] = ...@@ -675,7 +675,6 @@ static Optab optab[] =
{ ADIVW, ydivl, Pe, {0xf7,(06)} }, { ADIVW, ydivl, Pe, {0xf7,(06)} },
{ AENTER }, /* botch */ { AENTER }, /* botch */
{ AGLOBL }, { AGLOBL },
{ AGOK },
{ AHISTORY }, { AHISTORY },
{ AHLT, ynone, Px, {0xf4} }, { AHLT, ynone, Px, {0xf4} },
{ AIDIVB, ydivb, Pb, {0xf6,(07)} }, { AIDIVB, ydivb, Pb, {0xf6,(07)} },
......
...@@ -535,14 +535,14 @@ span9(Link *ctxt, LSym *cursym) ...@@ -535,14 +535,14 @@ span9(Link *ctxt, LSym *cursym)
if((o->type == 16 || o->type == 17) && p->pcond) { if((o->type == 16 || o->type == 17) && p->pcond) {
otxt = p->pcond->pc - c; otxt = p->pcond->pc - c;
if(otxt < -(1L<<15)+10 || otxt >= (1L<<15)-10) { if(otxt < -(1L<<15)+10 || otxt >= (1L<<15)-10) {
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->link = p->link; q->link = p->link;
p->link = q; p->link = q;
q->as = ABR; q->as = ABR;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
q->pcond = p->pcond; q->pcond = p->pcond;
p->pcond = q; p->pcond = q;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->link = p->link; q->link = p->link;
p->link = q; p->link = q;
q->as = ABR; q->as = ABR;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
int framepointer_enabled; int framepointer_enabled;
int fieldtrack_enabled; int fieldtrack_enabled;
Prog zprog;
// Toolchain experiments. // Toolchain experiments.
// These are controlled by the GOEXPERIMENT environment // These are controlled by the GOEXPERIMENT environment
......
...@@ -217,7 +217,8 @@ copyp(Link *ctxt, Prog *q) ...@@ -217,7 +217,8 @@ copyp(Link *ctxt, Prog *q)
{ {
Prog *p; Prog *p;
p = ctxt->arch->prg(); USED(ctxt);
p = emallocz(sizeof(Prog));
*p = *q; *p = *q;
return p; return p;
} }
...@@ -227,7 +228,8 @@ appendp(Link *ctxt, Prog *q) ...@@ -227,7 +228,8 @@ appendp(Link *ctxt, Prog *q)
{ {
Prog *p; Prog *p;
p = ctxt->arch->prg(); USED(ctxt);
p = emallocz(sizeof(Prog));
p->link = q->link; p->link = q->link;
q->link = p; q->link = p;
p->lineno = q->lineno; p->lineno = q->lineno;
......
...@@ -35,11 +35,6 @@ ...@@ -35,11 +35,6 @@
#include "../cmd/5l/5.out.h" #include "../cmd/5l/5.out.h"
#include "../runtime/stack.h" #include "../runtime/stack.h"
static Prog zprg5 = {
.as = AGOK,
.scond = C_SCOND_NONE,
};
static int static int
isdata(Prog *p) isdata(Prog *p)
{ {
...@@ -181,16 +176,6 @@ progedit(Link *ctxt, Prog *p) ...@@ -181,16 +176,6 @@ progedit(Link *ctxt, Prog *p)
} }
} }
static Prog*
prg(void)
{
Prog *p;
p = emallocz(sizeof(*p));
*p = zprg5;
return p;
}
static Prog* stacksplit(Link*, Prog*, int32, int); static Prog* stacksplit(Link*, Prog*, int32, int);
static void initdiv(Link*); static void initdiv(Link*);
static void softfloat(Link*, LSym*); static void softfloat(Link*, LSym*);
...@@ -515,7 +500,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -515,7 +500,7 @@ preprocess(Link *ctxt, LSym *cursym)
if(cursym->text->mark & LEAF) { if(cursym->text->mark & LEAF) {
if(!autosize) { if(!autosize) {
p->as = AB; p->as = AB;
p->from = zprg5.from; p->from = zprog.from;
if(p->to.sym) { // retjmp if(p->to.sym) { // retjmp
p->to.type = TYPE_BRANCH; p->to.type = TYPE_BRANCH;
} else { } else {
...@@ -731,11 +716,11 @@ softfloat(Link *ctxt, LSym *cursym) ...@@ -731,11 +716,11 @@ softfloat(Link *ctxt, LSym *cursym)
soft: soft:
if (!wasfloat || (p->mark&LABEL)) { if (!wasfloat || (p->mark&LABEL)) {
next = ctxt->arch->prg(); next = emallocz(sizeof(Prog));
*next = *p; *next = *p;
// BL _sfloat(SB) // BL _sfloat(SB)
*p = zprg5; *p = zprog;
p->link = next; p->link = next;
p->as = ABL; p->as = ABL;
p->to.type = TYPE_BRANCH; p->to.type = TYPE_BRANCH;
...@@ -889,7 +874,7 @@ follow(Link *ctxt, LSym *s) ...@@ -889,7 +874,7 @@ follow(Link *ctxt, LSym *s)
ctxt->cursym = s; ctxt->cursym = s;
firstp = ctxt->arch->prg(); firstp = emallocz(sizeof(Prog));
lastp = firstp; lastp = firstp;
xfol(ctxt, s->text, &lastp); xfol(ctxt, s->text, &lastp);
lastp->link = nil; lastp->link = nil;
...@@ -957,7 +942,7 @@ loop: ...@@ -957,7 +942,7 @@ loop:
continue; continue;
copy: copy:
for(;;) { for(;;) {
r = ctxt->arch->prg(); r = emallocz(sizeof(Prog));
*r = *p; *r = *p;
if(!(r->mark&FOLL)) if(!(r->mark&FOLL))
print("can't happen 1\n"); print("can't happen 1\n");
...@@ -985,7 +970,7 @@ loop: ...@@ -985,7 +970,7 @@ loop:
} }
} }
a = AB; a = AB;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = a; q->as = a;
q->lineno = p->lineno; q->lineno = p->lineno;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
...@@ -1034,7 +1019,6 @@ LinkArch linkarm = { ...@@ -1034,7 +1019,6 @@ LinkArch linkarm = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 4, .minlc = 4,
......
...@@ -35,18 +35,6 @@ ...@@ -35,18 +35,6 @@
#include "../cmd/6l/6.out.h" #include "../cmd/6l/6.out.h"
#include "../runtime/stack.h" #include "../runtime/stack.h"
static Prog zprg = {
.as = AGOK,
.from = {
.type = TYPE_NONE,
.index = TYPE_NONE,
},
.to = {
.type = TYPE_NONE,
.index = TYPE_NONE,
},
};
static void static void
nopout(Prog *p) nopout(Prog *p)
{ {
...@@ -865,7 +853,7 @@ follow(Link *ctxt, LSym *s) ...@@ -865,7 +853,7 @@ follow(Link *ctxt, LSym *s)
ctxt->cursym = s; ctxt->cursym = s;
firstp = ctxt->arch->prg(); firstp = emallocz(sizeof(Prog));
lastp = firstp; lastp = firstp;
xfol(ctxt, s->text, &lastp); xfol(ctxt, s->text, &lastp);
lastp->link = nil; lastp->link = nil;
...@@ -999,7 +987,7 @@ loop: ...@@ -999,7 +987,7 @@ loop:
goto loop; goto loop;
} }
} /* */ } /* */
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AJMP; q->as = AJMP;
q->lineno = p->lineno; q->lineno = p->lineno;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
...@@ -1057,16 +1045,6 @@ loop: ...@@ -1057,16 +1045,6 @@ loop:
goto loop; goto loop;
} }
static Prog*
prg(void)
{
Prog *p;
p = emallocz(sizeof(*p));
*p = zprg;
return p;
}
LinkArch linkamd64 = { LinkArch linkamd64 = {
.name = "amd64", .name = "amd64",
.thechar = '6', .thechar = '6',
...@@ -1078,7 +1056,6 @@ LinkArch linkamd64 = { ...@@ -1078,7 +1056,6 @@ LinkArch linkamd64 = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 1, .minlc = 1,
...@@ -1110,7 +1087,6 @@ LinkArch linkamd64p32 = { ...@@ -1110,7 +1087,6 @@ LinkArch linkamd64p32 = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 1, .minlc = 1,
......
...@@ -35,18 +35,6 @@ ...@@ -35,18 +35,6 @@
#include "../cmd/8l/8.out.h" #include "../cmd/8l/8.out.h"
#include "../runtime/stack.h" #include "../runtime/stack.h"
static Prog zprg = {
.as = AGOK,
.from = {
.type = TYPE_NONE,
.index = REG_NONE,
},
.to = {
.type = TYPE_NONE,
.index = REG_NONE,
},
};
static int static int
isdata(Prog *p) isdata(Prog *p)
{ {
...@@ -244,16 +232,6 @@ progedit(Link *ctxt, Prog *p) ...@@ -244,16 +232,6 @@ progedit(Link *ctxt, Prog *p)
} }
} }
static Prog*
prg(void)
{
Prog *p;
p = emallocz(sizeof(*p));
*p = zprg;
return p;
}
static Prog* load_g_cx(Link*, Prog*); static Prog* load_g_cx(Link*, Prog*);
static Prog* stacksplit(Link*, Prog*, int32, int, Prog**); static Prog* stacksplit(Link*, Prog*, int32, int, Prog**);
...@@ -681,7 +659,7 @@ follow(Link *ctxt, LSym *s) ...@@ -681,7 +659,7 @@ follow(Link *ctxt, LSym *s)
ctxt->cursym = s; ctxt->cursym = s;
firstp = ctxt->arch->prg(); firstp = emallocz(sizeof(Prog));
lastp = firstp; lastp = firstp;
xfol(ctxt, s->text, &lastp); xfol(ctxt, s->text, &lastp);
lastp->link = nil; lastp->link = nil;
...@@ -808,7 +786,7 @@ loop: ...@@ -808,7 +786,7 @@ loop:
goto loop; goto loop;
} }
} /* */ } /* */
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AJMP; q->as = AJMP;
q->lineno = p->lineno; q->lineno = p->lineno;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
...@@ -877,7 +855,6 @@ LinkArch link386 = { ...@@ -877,7 +855,6 @@ LinkArch link386 = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 1, .minlc = 1,
......
...@@ -35,10 +35,6 @@ ...@@ -35,10 +35,6 @@
#include "../runtime/stack.h" #include "../runtime/stack.h"
#include "../runtime/funcdata.h" #include "../runtime/funcdata.h"
static Prog zprg = {
.as = AGOK,
};
static int static int
isdata(Prog *p) isdata(Prog *p)
{ {
...@@ -512,7 +508,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -512,7 +508,7 @@ preprocess(Link *ctxt, LSym *cursym)
if(cursym->text->mark & LEAF) { if(cursym->text->mark & LEAF) {
if(!autosize) { if(!autosize) {
p->as = ABR; p->as = ABR;
p->from = zprg.from; p->from = zprog.from;
p->to.type = TYPE_REG; p->to.type = TYPE_REG;
p->to.reg = REG_LR; p->to.reg = REG_LR;
p->mark |= BRANCH; p->mark |= BRANCH;
...@@ -526,7 +522,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -526,7 +522,7 @@ preprocess(Link *ctxt, LSym *cursym)
p->to.reg = REGSP; p->to.reg = REGSP;
p->spadj = -autosize; p->spadj = -autosize;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = ABR; q->as = ABR;
q->lineno = p->lineno; q->lineno = p->lineno;
q->to.type = TYPE_REG; q->to.type = TYPE_REG;
...@@ -546,7 +542,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -546,7 +542,7 @@ preprocess(Link *ctxt, LSym *cursym)
p->to.type = TYPE_REG; p->to.type = TYPE_REG;
p->to.reg = REGTMP; p->to.reg = REGTMP;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AMOVD; q->as = AMOVD;
q->lineno = p->lineno; q->lineno = p->lineno;
q->from.type = TYPE_REG; q->from.type = TYPE_REG;
...@@ -560,7 +556,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -560,7 +556,7 @@ preprocess(Link *ctxt, LSym *cursym)
if(0) { if(0) {
// Debug bad returns // Debug bad returns
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AMOVD; q->as = AMOVD;
q->lineno = p->lineno; q->lineno = p->lineno;
q->from.type = TYPE_MEM; q->from.type = TYPE_MEM;
...@@ -575,7 +571,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -575,7 +571,7 @@ preprocess(Link *ctxt, LSym *cursym)
} }
if(autosize) { if(autosize) {
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = AADD; q->as = AADD;
q->lineno = p->lineno; q->lineno = p->lineno;
q->from.type = TYPE_CONST; q->from.type = TYPE_CONST;
...@@ -588,7 +584,7 @@ preprocess(Link *ctxt, LSym *cursym) ...@@ -588,7 +584,7 @@ preprocess(Link *ctxt, LSym *cursym)
p->link = q; p->link = q;
} }
q1 = ctxt->arch->prg(); q1 = emallocz(sizeof(Prog));
q1->as = ABR; q1->as = ABR;
q1->lineno = p->lineno; q1->lineno = p->lineno;
q1->to.type = TYPE_REG; q1->to.type = TYPE_REG;
...@@ -802,7 +798,7 @@ follow(Link *ctxt, LSym *s) ...@@ -802,7 +798,7 @@ follow(Link *ctxt, LSym *s)
ctxt->cursym = s; ctxt->cursym = s;
firstp = ctxt->arch->prg(); firstp = emallocz(sizeof(Prog));
lastp = firstp; lastp = firstp;
xfol(ctxt, s->text, &lastp); xfol(ctxt, s->text, &lastp);
lastp->link = nil; lastp->link = nil;
...@@ -878,7 +874,7 @@ loop: ...@@ -878,7 +874,7 @@ loop:
continue; continue;
copy: copy:
for(;;) { for(;;) {
r = ctxt->arch->prg(); r = emallocz(sizeof(Prog));
*r = *p; *r = *p;
if(!(r->mark&FOLL)) if(!(r->mark&FOLL))
print("cant happen 1\n"); print("cant happen 1\n");
...@@ -905,7 +901,7 @@ loop: ...@@ -905,7 +901,7 @@ loop:
} }
a = ABR; a = ABR;
q = ctxt->arch->prg(); q = emallocz(sizeof(Prog));
q->as = a; q->as = a;
q->lineno = p->lineno; q->lineno = p->lineno;
q->to.type = TYPE_BRANCH; q->to.type = TYPE_BRANCH;
...@@ -935,16 +931,6 @@ loop: ...@@ -935,16 +931,6 @@ loop:
goto loop; goto loop;
} }
static Prog*
prg(void)
{
Prog *p;
p = emallocz(sizeof(*p));
*p = zprg;
return p;
}
LinkArch linkppc64 = { LinkArch linkppc64 = {
.name = "ppc64", .name = "ppc64",
.thechar = '9', .thechar = '9',
...@@ -956,7 +942,6 @@ LinkArch linkppc64 = { ...@@ -956,7 +942,6 @@ LinkArch linkppc64 = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 4, .minlc = 4,
...@@ -988,7 +973,6 @@ LinkArch linkppc64le = { ...@@ -988,7 +973,6 @@ LinkArch linkppc64le = {
.follow = follow, .follow = follow,
.iscall = iscall, .iscall = iscall,
.isdata = isdata, .isdata = isdata,
.prg = prg,
.progedit = progedit, .progedit = progedit,
.minlc = 4, .minlc = 4,
......
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