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
#pragma incomplete struct Section
void (*follow)(Link*, LSym*);
int (*iscall)(Prog*);
int (*isdata)(Prog*);
- Prog* (*prg)(void);
void (*progedit)(Link*, Prog*);
int minlc;
widthint = 4;
widthreg = 4;
- zprog.as = AGOK;
- zprog.scond = C_SCOND_NONE;
- arch.zprog = zprog;
-
listinit5();
}
arch.thestring = thestring;
arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs;
- arch.zprog = zprog;
arch.ACALL = ABL;
arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA;
EXTERN uchar reg[REGALLOC_FMAX+1];
EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring;
-EXTERN Prog zprog;
extern long unmappedzero;
/*
if(t == T)
fatal("optoas: t is nil");
- a = AGOK;
+ a = AXXX;
switch(CASE(op, simtype[t->etype])) {
default:
fatal("optoas: no entry %O-%T etype %T simtype %T", op, t, types[t->etype], types[simtype[t->etype]]);
case AXXX:
case ADATA:
case AGLOBL:
- case AGOK:
case AHISTORY:
case ANAME:
case ASIGNAME:
ADATA,
AGLOBL,
- AGOK,
AHISTORY,
ANAME,
ARET,
}
- 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();
}
arch.thestring = thestring;
arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs;
- arch.zprog = zprog;
arch.ACALL = ACALL;
arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA;
EXTERN uchar reg[MAXREG];
EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring;
-EXTERN Prog zprog;
EXTERN Node* panicdiv;
extern vlong unmappedzero;
extern int addptr;
if(t == T)
fatal("optoas: t is nil");
- a = AGOK;
+ a = AXXX;
switch(CASE(op, simtype[t->etype])) {
default:
fatal("optoas: no entry %O-%T", op, t);
ADIVW,
AENTER,
AGLOBL,
- AGOK,
AHISTORY,
AHLT,
AIDIVB,
widthint = 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();
}
arch.thestring = thestring;
arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs;
- arch.zprog = zprog;
arch.ACALL = ACALL;
arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA;
EXTERN uchar reg[MAXREG];
EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring;
-EXTERN Prog zprog;
EXTERN Node* panicdiv;
extern uint32 unmappedzero;
if(t == T)
fatal("optoas: t is nil");
- a = AGOK;
+ a = AXXX;
switch(CASE(op, simtype[t->etype])) {
default:
fatal("optoas: no entry %O-%T", op, t);
{
int et, a;
- a = AGOK;
+ a = AXXX;
et = simtype[t->etype];
if(use_sse)
ADIVW,
AENTER,
AGLOBL,
- AGOK,
AHISTORY,
AHLT,
AIDIVB,
reg = g2->scale;
}
- p = ctxt->arch->prg();
+ p = emallocz(sizeof(Prog));
p->as = a;
p->lineno = lineno;
if(nosched)
if(pass == 1)
goto out;
- p = ctxt->arch->prg();
+ p = emallocz(sizeof(Prog));
p->as = a;
p->lineno = lineno;
if(nosched)
widthint = 8;
widthreg = 8;
- zprog.as = AGOK;
- arch.zprog = zprog;
-
listinit9();
}
arch.thestring = thestring;
arch.thelinkarch = thelinkarch;
arch.typedefs = typedefs;
- arch.zprog = zprog;
arch.ACALL = ABL;
arch.ACHECKNIL = ACHECKNIL;
arch.ADATA = ADATA;
EXTERN uchar reg[NREG+NFREG];
EXTERN int32 pcloc; // instruction counter
EXTERN Strlit emptystring;
-EXTERN Prog zprog;
EXTERN Node* panicdiv;
extern vlong unmappedzero;
if(t == T)
fatal("optoas: t is nil");
- a = AGOK;
+ a = AXXX;
switch(CASE(op, simtype[t->etype])) {
default:
fatal("optoas: no entry for op=%O type=%T", op, t);
ASYSCALL,
ADATA,
AGLOBL,
- AGOK,
AHISTORY,
ANAME,
ANOP,
char *thestring;
LinkArch *thelinkarch;
Typedef *typedefs;
- Prog zprog;
int ACALL;
int ACHECKNIL;
arch.proginfo(&info, p);
if(p->to.node == v->node && (info.flags & RightWrite) && !(info.flags & RightRead)) {
p->as = arch.ANOP;
- p->to = arch.zprog.to;
+ p->to = zprog.to;
v->removed = 1;
if(Debug)
print("drop write-only %S\n", v->node->sym);
static Oprang oprange[ALAST];
static uchar xcmp[C_GOK+1][C_GOK+1];
-static Prog zprg = {
- .as = AGOK,
- .scond = C_SCOND_NONE,
-};
-
static LSym *deferreturn;
static void
// split it into two instructions:
// ADD $-100004, R13
// MOVW R14, 0(R13)
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
p->scond &= ~C_WBIT;
*q = *p;
a = &p->to;
p->from = *a;
p->from.reg = 0;
p->from.type = TYPE_CONST;
- p->to = zprg.to;
+ p->to = zprog.to;
p->to.type = TYPE_REG;
p->to.reg = REG_R13;
// make q into p but load/store from 0(R13)
q->spadj = 0;
- *a2 = zprg.from;
+ *a2 = zprog.from;
a2->type = TYPE_MEM;
a2->reg = REG_R13;
a2->sym = nil;
// This won't handle .W/.P, so we should reject such code.
if(p->scond & (C_PBIT|C_WBIT))
ctxt->diag("unsupported instruction (.P/.W): %P", p);
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
*q = *p;
if(p->to.type == TYPE_MEM)
a2 = &q->to;
p->as = AMOVW;
p->from = *a;
p->from.type = TYPE_CONST;
- p->to = zprg.to;
+ p->to = zprog.to;
p->to.type = TYPE_REG;
p->to.reg = REG_R11;
// make q into p but load/store from 0(R11)
- *a2 = zprg.from;
+ *a2 = zprog.from;
a2->type = TYPE_MEM;
a2->reg = REG_R11;
a2->sym = nil;
if(otxt < 0)
otxt = -otxt;
if(otxt >= (1L<<17) - 10) {
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->link = p->link;
p->link = q;
q->as = AB;
q->to.type = TYPE_BRANCH;
q->pcond = p->pcond;
p->pcond = q;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->link = p->link;
p->link = q;
q->as = AB;
if(ctxt->blitrl) {
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);
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AB;
q->to.type = TYPE_BRANCH;
q->pcond = p->link;
return 0;
if(ctxt->headtype == Hnacl && pool.size % 16 != 0) {
// if pool is not multiple of 16 bytes, add an alignment marker
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = ADATABUNDLEEND;
ctxt->elitrl->link = q;
ctxt->elitrl = q;
c = aclass(ctxt, a);
- t = zprg;
+ t = zprog;
t.as = AWORD;
switch(c) {
if(ctxt->headtype == Hnacl && pool.size%16 == 0) {
// start a new data bundle
- q = ctxt->arch->prg();
- *q = zprg;
+ q = emallocz(sizeof(Prog));
+ *q = zprog;
q->as = ADATABUNDLE;
q->pc = pool.size;
pool.size += 4;
ctxt->elitrl = q;
}
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
*q = t;
q->pc = pool.size;
{ AFXRSTOR64, ysvrs, Pw, {0x0f,0xae,(01),0x0f,0xae,(01)} },
{ AFXSAVE64, ysvrs, Pw, {0x0f,0xae,(00),0x0f,0xae,(00)} },
{ AGLOBL },
- { AGOK },
{ AHISTORY },
{ AHLT, ynone, Px, {0xf4} },
{ AIDIVB, ydivb, Pb, {0xf6,(07)} },
{ ADIVW, ydivl, Pe, {0xf7,(06)} },
{ AENTER }, /* botch */
{ AGLOBL },
- { AGOK },
{ AHISTORY },
{ AHLT, ynone, Px, {0xf4} },
{ AIDIVB, ydivb, Pb, {0xf6,(07)} },
if((o->type == 16 || o->type == 17) && p->pcond) {
otxt = p->pcond->pc - c;
if(otxt < -(1L<<15)+10 || otxt >= (1L<<15)-10) {
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->link = p->link;
p->link = q;
q->as = ABR;
q->to.type = TYPE_BRANCH;
q->pcond = p->pcond;
p->pcond = q;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->link = p->link;
p->link = q;
q->as = ABR;
int framepointer_enabled;
int fieldtrack_enabled;
+Prog zprog;
// Toolchain experiments.
// These are controlled by the GOEXPERIMENT environment
{
Prog *p;
- p = ctxt->arch->prg();
+ USED(ctxt);
+ p = emallocz(sizeof(Prog));
*p = *q;
return p;
}
{
Prog *p;
- p = ctxt->arch->prg();
+ USED(ctxt);
+ p = emallocz(sizeof(Prog));
p->link = q->link;
q->link = p;
p->lineno = q->lineno;
#include "../cmd/5l/5.out.h"
#include "../runtime/stack.h"
-static Prog zprg5 = {
- .as = AGOK,
- .scond = C_SCOND_NONE,
-};
-
static int
isdata(Prog *p)
{
}
}
-static Prog*
-prg(void)
-{
- Prog *p;
-
- p = emallocz(sizeof(*p));
- *p = zprg5;
- return p;
-}
-
static Prog* stacksplit(Link*, Prog*, int32, int);
static void initdiv(Link*);
static void softfloat(Link*, LSym*);
if(cursym->text->mark & LEAF) {
if(!autosize) {
p->as = AB;
- p->from = zprg5.from;
+ p->from = zprog.from;
if(p->to.sym) { // retjmp
p->to.type = TYPE_BRANCH;
} else {
soft:
if (!wasfloat || (p->mark&LABEL)) {
- next = ctxt->arch->prg();
+ next = emallocz(sizeof(Prog));
*next = *p;
// BL _sfloat(SB)
- *p = zprg5;
+ *p = zprog;
p->link = next;
p->as = ABL;
p->to.type = TYPE_BRANCH;
ctxt->cursym = s;
- firstp = ctxt->arch->prg();
+ firstp = emallocz(sizeof(Prog));
lastp = firstp;
xfol(ctxt, s->text, &lastp);
lastp->link = nil;
continue;
copy:
for(;;) {
- r = ctxt->arch->prg();
+ r = emallocz(sizeof(Prog));
*r = *p;
if(!(r->mark&FOLL))
print("can't happen 1\n");
}
}
a = AB;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = a;
q->lineno = p->lineno;
q->to.type = TYPE_BRANCH;
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 4,
#include "../cmd/6l/6.out.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
nopout(Prog *p)
{
ctxt->cursym = s;
- firstp = ctxt->arch->prg();
+ firstp = emallocz(sizeof(Prog));
lastp = firstp;
xfol(ctxt, s->text, &lastp);
lastp->link = nil;
goto loop;
}
} /* */
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AJMP;
q->lineno = p->lineno;
q->to.type = TYPE_BRANCH;
goto loop;
}
-static Prog*
-prg(void)
-{
- Prog *p;
-
- p = emallocz(sizeof(*p));
- *p = zprg;
- return p;
-}
-
LinkArch linkamd64 = {
.name = "amd64",
.thechar = '6',
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 1,
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 1,
#include "../cmd/8l/8.out.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
isdata(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* stacksplit(Link*, Prog*, int32, int, Prog**);
ctxt->cursym = s;
- firstp = ctxt->arch->prg();
+ firstp = emallocz(sizeof(Prog));
lastp = firstp;
xfol(ctxt, s->text, &lastp);
lastp->link = nil;
goto loop;
}
} /* */
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AJMP;
q->lineno = p->lineno;
q->to.type = TYPE_BRANCH;
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 1,
#include "../runtime/stack.h"
#include "../runtime/funcdata.h"
-static Prog zprg = {
- .as = AGOK,
-};
-
static int
isdata(Prog *p)
{
if(cursym->text->mark & LEAF) {
if(!autosize) {
p->as = ABR;
- p->from = zprg.from;
+ p->from = zprog.from;
p->to.type = TYPE_REG;
p->to.reg = REG_LR;
p->mark |= BRANCH;
p->to.reg = REGSP;
p->spadj = -autosize;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = ABR;
q->lineno = p->lineno;
q->to.type = TYPE_REG;
p->to.type = TYPE_REG;
p->to.reg = REGTMP;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AMOVD;
q->lineno = p->lineno;
q->from.type = TYPE_REG;
if(0) {
// Debug bad returns
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AMOVD;
q->lineno = p->lineno;
q->from.type = TYPE_MEM;
}
if(autosize) {
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = AADD;
q->lineno = p->lineno;
q->from.type = TYPE_CONST;
p->link = q;
}
- q1 = ctxt->arch->prg();
+ q1 = emallocz(sizeof(Prog));
q1->as = ABR;
q1->lineno = p->lineno;
q1->to.type = TYPE_REG;
ctxt->cursym = s;
- firstp = ctxt->arch->prg();
+ firstp = emallocz(sizeof(Prog));
lastp = firstp;
xfol(ctxt, s->text, &lastp);
lastp->link = nil;
continue;
copy:
for(;;) {
- r = ctxt->arch->prg();
+ r = emallocz(sizeof(Prog));
*r = *p;
if(!(r->mark&FOLL))
print("cant happen 1\n");
}
a = ABR;
- q = ctxt->arch->prg();
+ q = emallocz(sizeof(Prog));
q->as = a;
q->lineno = p->lineno;
q->to.type = TYPE_BRANCH;
goto loop;
}
-static Prog*
-prg(void)
-{
- Prog *p;
-
- p = emallocz(sizeof(*p));
- *p = zprg;
- return p;
-}
-
LinkArch linkppc64 = {
.name = "ppc64",
.thechar = '9',
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 4,
.follow = follow,
.iscall = iscall,
.isdata = isdata,
- .prg = prg,
.progedit = progedit,
.minlc = 4,