]> Cypherpunks repositories - gostls13.git/commitdiff
liblink: the zero Prog is now valid and ready for use
authorRuss Cox <rsc@golang.org>
Thu, 29 Jan 2015 21:16:24 +0000 (16:16 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 3 Feb 2015 18:22:45 +0000 (18:22 +0000)
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/3575
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-by: Austin Clements <austin@google.com>
31 files changed:
include/link.h
src/cmd/5g/galign.c
src/cmd/5g/gg.h
src/cmd/5g/gsubr.c
src/cmd/5g/peep.c
src/cmd/5l/5.out.h
src/cmd/6g/galign.c
src/cmd/6g/gg.h
src/cmd/6g/gsubr.c
src/cmd/6l/6.out.h
src/cmd/8g/galign.c
src/cmd/8g/gg.h
src/cmd/8g/gsubr.c
src/cmd/8l/8.out.h
src/cmd/9a/lex.c
src/cmd/9g/galign.c
src/cmd/9g/gg.h
src/cmd/9g/gsubr.c
src/cmd/9l/9.out.h
src/cmd/gc/go.h
src/cmd/gc/popt.c
src/liblink/asm5.c
src/liblink/asm6.c
src/liblink/asm8.c
src/liblink/asm9.c
src/liblink/go.c
src/liblink/ld.c
src/liblink/obj5.c
src/liblink/obj6.c
src/liblink/obj8.c
src/liblink/obj9.c

index a72c66d17ef59371dfef3b660d4434183b612bef..78de54b2fbe0db4d657a06d3b1e75d8bc0d2c144 100644 (file)
@@ -247,6 +247,8 @@ struct      Prog
        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
 
@@ -600,7 +602,6 @@ struct LinkArch
        void    (*follow)(Link*, LSym*);
        int     (*iscall)(Prog*);
        int     (*isdata)(Prog*);
-       Prog*   (*prg)(void);
        void    (*progedit)(Link*, Prog*);
 
        int     minlc;
index c2940f3b5141cc7398f627fa813a9211c4adb637..f2cba77eb6d425b7cdcfd472665b5f3c871555e2 100644 (file)
@@ -36,10 +36,6 @@ betypeinit(void)
        widthint = 4;
        widthreg = 4;
 
-       zprog.as = AGOK;
-       zprog.scond = C_SCOND_NONE;
-       arch.zprog = zprog;
-
        listinit5();
 }
 
@@ -50,7 +46,6 @@ main(int argc, char **argv)
        arch.thestring = thestring;
        arch.thelinkarch = thelinkarch;
        arch.typedefs = typedefs;
-       arch.zprog = zprog;
        arch.ACALL = ABL;
        arch.ACHECKNIL = ACHECKNIL;
        arch.ADATA = ADATA;
index 6ee7008574d29d5f6e524bd33d439299a0664e1a..8a75311d734857ac8240ed334187ecc7127f714b 100644 (file)
@@ -21,7 +21,6 @@ EXTERN        int32   dynloc;
 EXTERN uchar   reg[REGALLOC_FMAX+1];
 EXTERN int32   pcloc;          // instruction counter
 EXTERN Strlit  emptystring;
-EXTERN Prog    zprog;
 extern long    unmappedzero;
 
 /*
index 66acdedbd58ee268f7557a33187bb7449cffaf72..194d590d2cd3db43b46a7101017ab614cc61b820 100644 (file)
@@ -1414,7 +1414,7 @@ optoas(int op, Type *t)
        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]]);
index 46c7046ca35fbd2f430e2cbb2b06dc08535d1dd1..a96d1f93dc13fdfc38f68e4ce2a52523f3f1e9cb 100644 (file)
@@ -1385,7 +1385,6 @@ predicable(Prog *p)
        case AXXX:
        case ADATA:
        case AGLOBL:
-       case AGOK:
        case AHISTORY:
        case ANAME:
        case ASIGNAME:
index bc31b5e298bfa553aa091e12a4adcf48b5a5e9ea..2dcb0ec2b7e04f9aba18b5b83ac7cdff6bb12dcb 100644 (file)
@@ -253,7 +253,6 @@ enum
 
        ADATA,
        AGLOBL,
-       AGOK,
        AHISTORY,
        ANAME,
        ARET,
index c81cd7d0f2a65e7dcd1babaeffaca7116bc87d48..fc97d62d9b011880aa2f01a80c6645e4e27b02e0 100644 (file)
@@ -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();
 }
 
@@ -77,7 +69,6 @@ main(int argc, char **argv)
        arch.thestring = thestring;
        arch.thelinkarch = thelinkarch;
        arch.typedefs = typedefs;
-       arch.zprog = zprog;
        arch.ACALL = ACALL;
        arch.ACHECKNIL = ACHECKNIL;
        arch.ADATA = ADATA;
index 7a7b824da1476dbbf0aedce0ac907290db894a9f..7a09f673ef1e85994057637b349e03dccc8bb1a9 100644 (file)
@@ -13,7 +13,6 @@ EXTERN        int32   dynloc;
 EXTERN uchar   reg[MAXREG];
 EXTERN int32   pcloc;          // instruction counter
 EXTERN Strlit  emptystring;
-EXTERN Prog    zprog;
 EXTERN Node*   panicdiv;
 extern vlong   unmappedzero;
 extern int     addptr;
index 6c7cc89025f10e6c5263a4a4bf9137d469592fd5..697016c6f3fba6e5d46e996d9cbf4be84213ed26 100644 (file)
@@ -1329,7 +1329,7 @@ optoas(int op, Type *t)
        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);
index ccefe97ae17880d9b9f355e80748daeeeee761d0..b40c6b994b0cc63a5041e88531ee04cd74f50c65 100644 (file)
@@ -93,7 +93,6 @@ enum
        ADIVW,
        AENTER,
        AGLOBL,
-       AGOK,
        AHISTORY,
        AHLT,
        AIDIVB,
index f5a99121d0e80cd98ee6855a4c59389b2ef4ac67..0fdf19dfe8c396c853ced324db9685d474dc3684 100644 (file)
@@ -36,14 +36,6 @@ betypeinit(void)
        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();
 }
 
@@ -54,7 +46,6 @@ main(int argc, char **argv)
        arch.thestring = thestring;
        arch.thelinkarch = thelinkarch;
        arch.typedefs = typedefs;
-       arch.zprog = zprog;
        arch.ACALL = ACALL;
        arch.ACHECKNIL = ACHECKNIL;
        arch.ADATA = ADATA;
index d9cc2e562f1fefc3ec0fb4940750a13f5b2452d7..b2b1178a522c0b5d28bb96f724a1ceda0d1348fe 100644 (file)
@@ -21,7 +21,6 @@ EXTERN        int32   dynloc;
 EXTERN uchar   reg[MAXREG];
 EXTERN int32   pcloc;          // instruction counter
 EXTERN Strlit  emptystring;
-EXTERN Prog    zprog;
 EXTERN Node*   panicdiv;
 extern uint32  unmappedzero;
 
index 6f3a2c69068aa87aca6d1a4b36bacfb3a80959a1..dd75e9f092a6921f77b6d997fa211c42d4db3d11 100644 (file)
@@ -271,7 +271,7 @@ optoas(int op, Type *t)
        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);
@@ -690,7 +690,7 @@ foptoas(int op, Type *t, int flg)
 {
        int et, a;
 
-       a = AGOK;
+       a = AXXX;
        et = simtype[t->etype];
 
        if(use_sse)
index f796d05e0ebc543ba028866b2f2e3b744c2af461..f88b48259c092151dc2387787fea37b75f35e9dc 100644 (file)
@@ -88,7 +88,6 @@ enum
        ADIVW,
        AENTER,
        AGLOBL,
-       AGOK,
        AHISTORY,
        AHLT,
        AIDIVB,
index 9b343f0d691c9fde462f351d0a2ab265674b29a2..942791247e45762437fe38df4e4b0a8901b5a951 100644 (file)
@@ -670,7 +670,7 @@ outcode(int a, Addr *g1, int reg, Addr *g2)
                reg = g2->scale;
        }
 
-       p = ctxt->arch->prg();
+       p = emallocz(sizeof(Prog));
        p->as = a;
        p->lineno = lineno;
        if(nosched)
@@ -700,7 +700,7 @@ outgcode(int a, Addr *g1, int reg, Addr *g2, Addr *g3)
        if(pass == 1)
                goto out;
 
-       p = ctxt->arch->prg();
+       p = emallocz(sizeof(Prog));
        p->as = a;
        p->lineno = lineno;
        if(nosched)
index 5559e03a5382b8e453476937de53169a6b064619..86509dcc50d14662768e9c4da6957052152b7c05 100644 (file)
@@ -43,9 +43,6 @@ betypeinit(void)
        widthint = 8;
        widthreg = 8;
 
-       zprog.as = AGOK;
-       arch.zprog = zprog;
-
        listinit9();
 }
 
@@ -56,7 +53,6 @@ main(int argc, char **argv)
        arch.thestring = thestring;
        arch.thelinkarch = thelinkarch;
        arch.typedefs = typedefs;
-       arch.zprog = zprog;
        arch.ACALL = ABL;
        arch.ACHECKNIL = ACHECKNIL;
        arch.ADATA = ADATA;
index 983a22a27049b1dd9127a4b5715db1998f27ec0d..367a858e860b1f8fa51b001161347b33291b289e 100644 (file)
@@ -16,7 +16,6 @@ EXTERN        int32   dynloc;
 EXTERN uchar   reg[NREG+NFREG];
 EXTERN int32   pcloc;          // instruction counter
 EXTERN Strlit  emptystring;
-EXTERN Prog    zprog;
 EXTERN Node*   panicdiv;
 extern vlong   unmappedzero;
 
index 5e8e21a9c76eb290aa228bd05fe7cafbde4de9af..e58f58c704fec312683cd5cb7809c3a8098acc09 100644 (file)
@@ -1302,7 +1302,7 @@ optoas(int op, Type *t)
        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);
index 66ee8c43cbc38ef9515bfaf24a34282e9783a728..a9748b719f9f50c67f8c6911aac27f5fe2c5026b 100644 (file)
@@ -513,7 +513,6 @@ enum
        ASYSCALL,
        ADATA,
        AGLOBL,
-       AGOK,
        AHISTORY,
        ANAME,
        ANOP,
index 526cb5d8a0e0c51a2432b4ffdb945bcb2b2bf472..fe74f3484d373d7db944bdfb5eddbe53c430a9db 100644 (file)
@@ -1657,7 +1657,6 @@ struct Arch
        char *thestring;
        LinkArch *thelinkarch;
        Typedef *typedefs;
-       Prog zprog;
        
        int ACALL;
        int ACHECKNIL;
index fba57ac16c713a57a1ac73b8cad7f87c9bb5e7af..a86d3dfa1582b14a0666461df2702097acadae7b 100644 (file)
@@ -621,7 +621,7 @@ mergetemp(Prog *firstp)
                        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);
index eee6093cfcbacc7afcdf59cf02be7ecd3683aace..9ae041eeb8927e2f1efc8b5ace4efe021a42f640 100644 (file)
@@ -351,11 +351,6 @@ static uint32      opbra(Link*, int, int);
 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
@@ -515,7 +510,7 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
                        // 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;
@@ -534,12 +529,12 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
                        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;
@@ -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.
                                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;
@@ -594,11 +589,11 @@ asmoutnacl(Link *ctxt, int32 origPC, Prog *p, Optab *o, uint32 *out)
                                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;
@@ -731,14 +726,14 @@ span5(Link *ctxt, LSym *cursym)
                                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;
@@ -856,7 +851,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force)
        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;
@@ -868,7 +863,7 @@ flushpool(Link *ctxt, Prog *p, int skip, int force)
                        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;
@@ -900,7 +895,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
 
        c = aclass(ctxt, a);
 
-       t = zprg;
+       t = zprog;
        t.as = AWORD;
 
        switch(c) {
@@ -939,8 +934,8 @@ addpool(Link *ctxt, Prog *p, Addr *a)
 
        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;
@@ -953,7 +948,7 @@ addpool(Link *ctxt, Prog *p, Addr *a)
                ctxt->elitrl = q;
        }
 
-       q = ctxt->arch->prg();
+       q = emallocz(sizeof(Prog));
        *q = t;
        q->pc = pool.size;
 
index 71d24821e0f4adfa89730492bb7c11a538a5a038..b3a19dc9fbcbdc09cfd71c28e265f3be5892f258 100644 (file)
@@ -990,7 +990,6 @@ static Optab optab[] =
        { 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)} },
index e8508eb07ab5f24d06be274d4cc58bf2dd8366b4..c982ca98b7ad859a2b6afd3ca173ad2853b35117 100644 (file)
@@ -675,7 +675,6 @@ static Optab optab[] =
        { ADIVW,        ydivl,  Pe, {0xf7,(06)} },
        { AENTER },                             /* botch */
        { AGLOBL },
-       { AGOK },
        { AHISTORY },
        { AHLT,         ynone,  Px, {0xf4} },
        { AIDIVB,       ydivb,  Pb, {0xf6,(07)} },
index bc3174d08f6f7747faaf59c717ac1df6db310155..f1c762574772ec6df704537a127d84e4f7fc9194 100644 (file)
@@ -535,14 +535,14 @@ span9(Link *ctxt, LSym *cursym)
                        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;
index 3bc780b85281d57d6d03461db4b0dea128ef9127..754a7cc15e43cfc2a8ffa9b207b35217f85116a8 100644 (file)
@@ -11,6 +11,7 @@
 
 int framepointer_enabled;
 int fieldtrack_enabled;
+Prog zprog;
 
 // Toolchain experiments.
 // These are controlled by the GOEXPERIMENT environment
index 6d0fe4a2a4d05d5615329144e1e83aea9826476d..e055829142b6b439a66a61a60852f513081d9b53 100644 (file)
@@ -217,7 +217,8 @@ copyp(Link *ctxt, Prog *q)
 {
        Prog *p;
 
-       p = ctxt->arch->prg();
+       USED(ctxt);
+       p = emallocz(sizeof(Prog));
        *p = *q;
        return p;
 }
@@ -227,7 +228,8 @@ appendp(Link *ctxt, Prog *q)
 {
        Prog *p;
 
-       p = ctxt->arch->prg();
+       USED(ctxt);
+       p = emallocz(sizeof(Prog));
        p->link = q->link;
        q->link = p;
        p->lineno = q->lineno;
index 8d20173912de164359f676624b7943ddebf6d070..fd3d4071c53ec567dcfc4d7a456a88ea21370d38 100644 (file)
 #include "../cmd/5l/5.out.h"
 #include "../runtime/stack.h"
 
-static Prog zprg5 = {
-       .as = AGOK,
-       .scond = C_SCOND_NONE,
-};
-
 static int
 isdata(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 void            initdiv(Link*);
 static void    softfloat(Link*, LSym*);
@@ -515,7 +500,7 @@ preprocess(Link *ctxt, LSym *cursym)
                        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 {
@@ -731,11 +716,11 @@ softfloat(Link *ctxt, LSym *cursym)
 
        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;
@@ -889,7 +874,7 @@ follow(Link *ctxt, LSym *s)
 
        ctxt->cursym = s;
 
-       firstp = ctxt->arch->prg();
+       firstp = emallocz(sizeof(Prog));
        lastp = firstp;
        xfol(ctxt, s->text, &lastp);
        lastp->link = nil;
@@ -957,7 +942,7 @@ loop:
                                continue;
                copy:
                        for(;;) {
-                               r = ctxt->arch->prg();
+                               r = emallocz(sizeof(Prog));
                                *r = *p;
                                if(!(r->mark&FOLL))
                                        print("can't happen 1\n");
@@ -985,7 +970,7 @@ loop:
                        }
                }
                a = AB;
-               q = ctxt->arch->prg();
+               q = emallocz(sizeof(Prog));
                q->as = a;
                q->lineno = p->lineno;
                q->to.type = TYPE_BRANCH;
@@ -1034,7 +1019,6 @@ LinkArch linkarm = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 4,
index 15dd9e99a7cc774d583be91808d57e88db751780..c567eeb051199d8366f80fd7b83c47024dc4e1b3 100644 (file)
 #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)
 {
@@ -865,7 +853,7 @@ follow(Link *ctxt, LSym *s)
 
        ctxt->cursym = s;
 
-       firstp = ctxt->arch->prg();
+       firstp = emallocz(sizeof(Prog));
        lastp = firstp;
        xfol(ctxt, s->text, &lastp);
        lastp->link = nil;
@@ -999,7 +987,7 @@ loop:
                                goto loop;
                        }
                } /* */
-               q = ctxt->arch->prg();
+               q = emallocz(sizeof(Prog));
                q->as = AJMP;
                q->lineno = p->lineno;
                q->to.type = TYPE_BRANCH;
@@ -1057,16 +1045,6 @@ loop:
        goto loop;
 }
 
-static Prog*
-prg(void)
-{
-       Prog *p;
-
-       p = emallocz(sizeof(*p));
-       *p = zprg;
-       return p;
-}
-
 LinkArch linkamd64 = {
        .name = "amd64",
        .thechar = '6',
@@ -1078,7 +1056,6 @@ LinkArch linkamd64 = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 1,
@@ -1110,7 +1087,6 @@ LinkArch linkamd64p32 = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 1,
index 37ef8a490e55c12cf64e186d9b1fcdd34b763ecb..7ce21ec6cd1944100243aa3a1bfcfb49c6a4a313 100644 (file)
 #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)
 {
@@ -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*   stacksplit(Link*, Prog*, int32, int, Prog**);
 
@@ -681,7 +659,7 @@ follow(Link *ctxt, LSym *s)
 
        ctxt->cursym = s;
 
-       firstp = ctxt->arch->prg();
+       firstp = emallocz(sizeof(Prog));
        lastp = firstp;
        xfol(ctxt, s->text, &lastp);
        lastp->link = nil;
@@ -808,7 +786,7 @@ loop:
                                goto loop;
                        }
                } /* */
-               q = ctxt->arch->prg();
+               q = emallocz(sizeof(Prog));
                q->as = AJMP;
                q->lineno = p->lineno;
                q->to.type = TYPE_BRANCH;
@@ -877,7 +855,6 @@ LinkArch link386 = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 1,
index 60fa1d66e13aec1d9acaed7474c801624ab2c491..f1de2231729fd506a735441eb760999f9143966d 100644 (file)
 #include "../runtime/stack.h"
 #include "../runtime/funcdata.h"
 
-static Prog zprg = {
-       .as = AGOK,
-};
-
 static int
 isdata(Prog *p)
 {
@@ -512,7 +508,7 @@ preprocess(Link *ctxt, LSym *cursym)
                        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;
@@ -526,7 +522,7 @@ preprocess(Link *ctxt, LSym *cursym)
                                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;
@@ -546,7 +542,7 @@ preprocess(Link *ctxt, LSym *cursym)
                        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;
@@ -560,7 +556,7 @@ preprocess(Link *ctxt, LSym *cursym)
 
                        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;
@@ -575,7 +571,7 @@ preprocess(Link *ctxt, LSym *cursym)
                        }
 
                        if(autosize) {
-                               q = ctxt->arch->prg();
+                               q = emallocz(sizeof(Prog));
                                q->as = AADD;
                                q->lineno = p->lineno;
                                q->from.type = TYPE_CONST;
@@ -588,7 +584,7 @@ preprocess(Link *ctxt, LSym *cursym)
                                p->link = q;
                        }
 
-                       q1 = ctxt->arch->prg();
+                       q1 = emallocz(sizeof(Prog));
                        q1->as = ABR;
                        q1->lineno = p->lineno;
                        q1->to.type = TYPE_REG;
@@ -802,7 +798,7 @@ follow(Link *ctxt, LSym *s)
 
        ctxt->cursym = s;
 
-       firstp = ctxt->arch->prg();
+       firstp = emallocz(sizeof(Prog));
        lastp = firstp;
        xfol(ctxt, s->text, &lastp);
        lastp->link = nil;
@@ -878,7 +874,7 @@ loop:
                                continue;
                copy:
                        for(;;) {
-                               r = ctxt->arch->prg();
+                               r = emallocz(sizeof(Prog));
                                *r = *p;
                                if(!(r->mark&FOLL))
                                        print("cant happen 1\n");
@@ -905,7 +901,7 @@ loop:
                }
 
                a = ABR;
-               q = ctxt->arch->prg();
+               q = emallocz(sizeof(Prog));
                q->as = a;
                q->lineno = p->lineno;
                q->to.type = TYPE_BRANCH;
@@ -935,16 +931,6 @@ loop:
        goto loop;
 }
 
-static Prog*
-prg(void)
-{
-       Prog *p;
-
-       p = emallocz(sizeof(*p));
-       *p = zprg;
-       return p;
-}
-
 LinkArch linkppc64 = {
        .name = "ppc64",
        .thechar = '9',
@@ -956,7 +942,6 @@ LinkArch linkppc64 = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 4,
@@ -988,7 +973,6 @@ LinkArch linkppc64le = {
        .follow = follow,
        .iscall = iscall,
        .isdata = isdata,
-       .prg = prg,
        .progedit = progedit,
 
        .minlc = 4,