]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gc, cmd/ld, liblink: update for portable Prog, Addr changes
authorRuss Cox <rsc@golang.org>
Mon, 26 Jan 2015 20:14:23 +0000 (15:14 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 30 Jan 2015 03:15:44 +0000 (03:15 +0000)
Change-Id: Ia6f8badca56565b9df80c8dbe28c47f6cf7e653f
Reviewed-on: https://go-review.googlesource.com/3515
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
src/cmd/gc/align.c
src/cmd/gc/go.h
src/cmd/gc/pgen.c
src/cmd/gc/plive.c
src/cmd/gc/popt.c
src/cmd/ld/dwarf.c
src/cmd/ld/lib.c
src/liblink/data.c
src/liblink/objfile.c
src/liblink/pass.c
src/liblink/pcln.c

index cf03994184170bc0ff9f9b4bce17d61d14f26c1c..26d72e87fcb572a2832a321458e0621de897c9fd 100644 (file)
@@ -19,7 +19,7 @@ vlong
 rnd(vlong o, vlong r)
 {
        if(r < 1 || r > 8 || (r&(r-1)) != 0)
-               fatal("rnd");
+               fatal("rnd %lld", r);
        return (o+r-1)&~(r-1);
 }
 
index 11fbe1a825e75bbc5c8a6661d468a7f5f5788e75..526cb5d8a0e0c51a2432b4ffdb945bcb2b2bf472 100644 (file)
@@ -1675,10 +1675,6 @@ struct Arch
        int AUNDEF;
        int AVARDEF;
        int AVARKILL;
-       int D_AUTO;
-       int D_BRANCH;
-       int D_NONE;
-       int D_PARAM;
        vlong MAXWIDTH;
 
        void (*afunclit)(Addr*, Node*);
index a19b4c272faab1805f4f4880e4e88f5d52e130ba..99644d201fa76f00480e2d2b55c2315cf349692b 100644 (file)
@@ -127,7 +127,7 @@ removevardef(Prog *firstp)
        for(p = firstp; p != P; p = p->link) {
                while(p->link != P && (p->link->as == arch.AVARDEF || p->link->as == arch.AVARKILL))
                        p->link = p->link->link;
-               if(p->to.type == arch.D_BRANCH)
+               if(p->to.type == TYPE_BRANCH)
                        while(p->to.u.branch != P && (p->to.u.branch->as == arch.AVARDEF || p->to.u.branch->as == arch.AVARKILL))
                                p->to.u.branch = p->to.u.branch->link;
        }
index fa9e7dc0036a88eaa01c34c992b6df2052d86d03..ba98a9772f4507d3eadd34c218fca0a82b0d06f7 100644 (file)
@@ -512,7 +512,7 @@ newcfg(Prog *firstp)
        bb = newblock(firstp);
        arrayadd(cfg, &bb);
        for(p = firstp; p != P; p = p->link) {
-               if(p->to.type == arch.D_BRANCH) {
+               if(p->to.type == TYPE_BRANCH) {
                        if(p->to.u.branch == nil)
                                fatal("prog branch to nil");
                        if(p->to.u.branch->opt == nil) {
@@ -551,7 +551,7 @@ newcfg(Prog *firstp)
                        if(isselectgocall(p))
                                arrayadd(selectgo, &bb);
                }
-               if(bb->last->to.type == arch.D_BRANCH)
+               if(bb->last->to.type == TYPE_BRANCH)
                        addedge(bb, bb->last->to.u.branch->opt);
                if(bb->last->link != nil) {
                        // Add a fall-through when the instruction is
@@ -704,7 +704,7 @@ progeffects(Prog *prog, Array *vars, Bvec *uevar, Bvec *varkill, Bvec *avarinit)
                                // The p->to.type == arch.D_NONE limits the bvset to
                                // non-tail-call return instructions; see note above
                                // the for loop for details.
-                               if(!node->addrtaken && prog->to.type == arch.D_NONE)
+                               if(!node->addrtaken && prog->to.type == TYPE_NONE)
                                        bvset(uevar, i);
                                break;
                        }
@@ -987,6 +987,10 @@ checkauto(Node *fn, Prog *p, Node *n)
                if(l->n->op == ONAME && l->n->class == PAUTO && l->n == n)
                        return;
 
+       if(n == nil) {
+               print("%L: checkauto %N: nil node in %P\n", p->lineno, curfn, p);
+               return;
+       }
        print("checkauto %N: %N (%p; class=%d) not found in %P\n", curfn, n, n, n->class, p);
        for(l = fn->dcl; l != nil; l = l->next)
                print("\t%N (%p; class=%d)\n", l->n, l->n, l->n->class);
@@ -1018,13 +1022,13 @@ checkparam(Node *fn, Prog *p, Node *n)
 static void
 checkprog(Node *fn, Prog *p)
 {
-       if(p->from.type == arch.D_AUTO)
+       if(p->from.name == NAME_AUTO)
                checkauto(fn, p, p->from.node);
-       if(p->from.type == arch.D_PARAM)
+       if(p->from.name == NAME_PARAM)
                checkparam(fn, p, p->from.node);
-       if(p->to.type == arch.D_AUTO)
+       if(p->to.name == NAME_AUTO)
                checkauto(fn, p, p->to.node);
-       if(p->to.type == arch.D_PARAM)
+       if(p->to.name == NAME_PARAM)
                checkparam(fn, p, p->to.node);
 }
 
index ee771aba6a8e2c7c8d0e76a254a0081cd9652326..fba57ac16c713a57a1ac73b8cad7f87c9bb5e7af 100644 (file)
@@ -81,7 +81,7 @@ chasejmp(Prog *p, int *jmploop)
        int n;
 
        n = 0;
-       while(p != P && p->as == arch.AJMP && p->to.type == arch.D_BRANCH) {
+       while(p != P && p->as == arch.AJMP && p->to.type == TYPE_BRANCH) {
                if(++n > 10) {
                        *jmploop = 1;
                        break;
@@ -112,7 +112,7 @@ mark(Prog *firstp)
                if(p->opt != dead)
                        break;
                p->opt = alive;
-               if(p->as != arch.ACALL && p->to.type == arch.D_BRANCH && p->to.u.branch)
+               if(p->as != arch.ACALL && p->to.type == TYPE_BRANCH && p->to.u.branch)
                        mark(p->to.u.branch);
                if(p->as == arch.AJMP || p->as == arch.ARET || p->as == arch.AUNDEF)
                        break;
@@ -133,7 +133,7 @@ fixjmp(Prog *firstp)
        for(p=firstp; p; p=p->link) {
                if(debug['R'] && debug['v'])
                        print("%P\n", p);
-               if(p->as != arch.ACALL && p->to.type == arch.D_BRANCH && p->to.u.branch && p->to.u.branch->as == arch.AJMP) {
+               if(p->as != arch.ACALL && p->to.type == TYPE_BRANCH && p->to.u.branch && p->to.u.branch->as == arch.AJMP) {
                        p->to.u.branch = chasejmp(p->to.u.branch, &jmploop);
                        if(debug['R'] && debug['v'])
                                print("->%P\n", p);
@@ -176,7 +176,7 @@ fixjmp(Prog *firstp)
        if(!jmploop) {
                last = nil;
                for(p=firstp; p; p=p->link) {
-                       if(p->as == arch.AJMP && p->to.type == arch.D_BRANCH && p->to.u.branch == p->link) {
+                       if(p->as == arch.AJMP && p->to.type == TYPE_BRANCH && p->to.u.branch == p->link) {
                                if(debug['R'] && debug['v'])
                                        print("del %P\n", p);
                                continue;
@@ -275,7 +275,7 @@ flowstart(Prog *firstp, int size)
                        f->s1 = f1;
                        f1->p1 = f;
                }
-               if(p->to.type == arch.D_BRANCH) {
+               if(p->to.type == TYPE_BRANCH) {
                        if(p->to.u.branch == P)
                                fatal("pnil %P", p);
                        f1 = p->to.u.branch->opt;
index b5331e829f1dc595d316659dc2c9da34403583da..061171ea0b12b47acd0c9abdd1b852404dc58679 100644 (file)
@@ -1658,7 +1658,7 @@ writelines(void)
                dwfunc->hash = varhash;  // enable indexing of children by name
                memset(varhash, 0, sizeof varhash);
                for(a = s->autom; a; a = a->link) {
-                       switch (a->type) {
+                       switch (a->name) {
                        case A_AUTO:
                                dt = DW_ABRV_AUTO;
                                offs = a->aoffset - PtrSize;
index 925274bfd34eec408a7f889216b61e55a60a574f..fa08bc5f031716e5a72a14038a423dd4224fa2ed 100644 (file)
@@ -1411,11 +1411,11 @@ genasmsym(void (*put)(LSym*, char*, int, vlong, vlong, int, LSym*))
                for(a=s->autom; a; a=a->link) {
                        // Emit a or p according to actual offset, even if label is wrong.
                        // This avoids negative offsets, which cannot be encoded.
-                       if(a->type != A_AUTO && a->type != A_PARAM)
+                       if(a->name != A_AUTO && a->name != A_PARAM)
                                continue;
                        
                        // compute offset relative to FP
-                       if(a->type == A_PARAM)
+                       if(a->name == A_PARAM)
                                off = a->aoffset;
                        else
                                off = a->aoffset - PtrSize;
index e5efa2eb2da8ac42ccc51d66fc4d004f541d5b39..3de86fe05015e2f08d87586d32b80614e765803a 100644 (file)
@@ -87,7 +87,7 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
                ctxt->diag("data out of order (already have %d)\n%P", p);
        symgrow(ctxt, s, off+siz);
 
-       if(p->to.type == ctxt->arch->D_FCONST) {
+       if(p->to.type == TYPE_FCONST) {
                switch(siz) {
                default:
                case 4:
@@ -102,10 +102,10 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
                                s->p[off+i] = cast[fnuxi8[i]];
                        break;
                }
-       } else if(p->to.type == ctxt->arch->D_SCONST) {
+       } else if(p->to.type == TYPE_SCONST) {
                for(i=0; i<siz; i++)
                        s->p[off+i] = p->to.u.sval[i];
-       } else if(p->to.type == ctxt->arch->D_CONST) {
+       } else if(p->to.type == TYPE_CONST) {
                if(p->to.sym)
                        goto addr;
                o = p->to.offset;
@@ -132,7 +132,7 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
                                s->p[off+i] = cast[inuxi8[i]];
                        break;
                }
-       } else if(p->to.type == ctxt->arch->D_ADDR) {
+       } else if(p->to.type == TYPE_ADDR) {
        addr:
                r = addrel(s);
                r->off = off;
index f29ebbc5177845f0291eda4c702d4abc42fe0684..bdd63ccb644cd0d4b0f61a906330c0e54c49d76e 100644 (file)
@@ -167,7 +167,7 @@ writeobj(Link *ctxt, Biobuf *b)
                                a = emallocz(sizeof *a);
                                a->asym = p->from.sym;
                                a->aoffset = p->from.offset;
-                               a->type = ctxt->arch->symtype(&p->from);
+                               a->name = p->from.name;
                                a->gotype = p->from.gotype;
                                a->link = curtext->autom;
                                curtext->autom = a;
@@ -240,7 +240,7 @@ writeobj(Link *ctxt, Biobuf *b)
                                if(curtext == nil) // func _() {}
                                        continue;
                                if(strcmp(p->to.sym->name, "go_args_stackmap") == 0) {
-                                       if(p->from.type != ctxt->arch->D_CONST || p->from.offset != FUNCDATA_ArgsPointerMaps)
+                                       if(p->from.type != TYPE_CONST || p->from.offset != FUNCDATA_ArgsPointerMaps)
                                                ctxt->diag("FUNCDATA use of go_args_stackmap(SB) without FUNCDATA_ArgsPointerMaps");
                                        p->to.sym = linklookup(ctxt, smprint("%s.args_stackmap", curtext->name), curtext->version);
                                }
@@ -260,7 +260,7 @@ writeobj(Link *ctxt, Biobuf *b)
                        continue;
                found = 0;
                for(p = s->text; p != nil; p = p->link) {
-                       if(p->as == ctxt->arch->AFUNCDATA && p->from.type == ctxt->arch->D_CONST && p->from.offset == FUNCDATA_ArgsPointerMaps) {
+                       if(p->as == ctxt->arch->AFUNCDATA && p->from.type == TYPE_CONST && p->from.offset == FUNCDATA_ArgsPointerMaps) {
                                found = 1;
                                break;
                        }
@@ -268,14 +268,10 @@ writeobj(Link *ctxt, Biobuf *b)
                if(!found) {
                        p = appendp(ctxt, s->text);
                        p->as = ctxt->arch->AFUNCDATA;
-                       p->from.type = ctxt->arch->D_CONST;
+                       p->from.type = TYPE_CONST;
                        p->from.offset = FUNCDATA_ArgsPointerMaps;
-                       if(ctxt->arch->thechar == '6' || ctxt->arch->thechar == '8')
-                               p->to.type = ctxt->arch->D_EXTERN;
-                       else {
-                               p->to.type = ctxt->arch->D_OREG;
-                               p->to.name = ctxt->arch->D_EXTERN;
-                       }
+                       p->to.type = TYPE_MEM;
+                       p->to.name = NAME_EXTERN;
                        p->to.sym = linklookup(ctxt, smprint("%s.args_stackmap", s->name), s->version);
                }
        }
@@ -285,7 +281,7 @@ writeobj(Link *ctxt, Biobuf *b)
                mkfwd(s);
                linkpatch(ctxt, s);
                ctxt->arch->follow(ctxt, s);
-               ctxt->arch->addstacksplit(ctxt, s);
+               ctxt->arch->preprocess(ctxt, s);
                ctxt->arch->assemble(ctxt, s);
                linkpcln(ctxt, s);
        }
@@ -407,12 +403,12 @@ writesym(Link *ctxt, Biobuf *b, LSym *s)
                for(a = s->autom; a != nil; a = a->link) {
                        wrsym(b, a->asym);
                        wrint(b, a->aoffset);
-                       if(a->type == ctxt->arch->D_AUTO)
+                       if(a->name == NAME_AUTO)
                                wrint(b, A_AUTO);
-                       else if(a->type == ctxt->arch->D_PARAM)
+                       else if(a->name == NAME_PARAM)
                                wrint(b, A_PARAM);
                        else
-                               sysfatal("%s: invalid local variable type %d", s->name, a->type);
+                               sysfatal("%s: invalid local variable type %d", s->name, a->name);
                        wrsym(b, a->gotype);
                }
 
@@ -649,7 +645,7 @@ overwrite:
                        a = emallocz(sizeof *a);
                        a->asym = rdsym(ctxt, f, pkg);
                        a->aoffset = rdint(f);
-                       a->type = rdint(f);
+                       a->name = rdint(f);
                        a->gotype = rdsym(ctxt, f, pkg);
                        a->link = s->autom;
                        s->autom = a;
index 6d4db2757a48d76b242e635ad5e82858eb61c96b..edc4d9ba7353ef37a6fe074089aa8870f8e3995b 100644 (file)
@@ -77,7 +77,7 @@ linkpatch(Link *ctxt, LSym *sym)
        for(p = sym->text; p != nil; p = p->link) {
                if(ctxt->arch->progedit)
                        ctxt->arch->progedit(ctxt, p);
-               if(p->to.type != ctxt->arch->D_BRANCH)
+               if(p->to.type != TYPE_BRANCH)
                        continue;
                if(p->to.u.branch != nil) {
                        // TODO: Remove to.u.branch in favor of p->pcond.
@@ -100,7 +100,7 @@ linkpatch(Link *ctxt, LSym *sym)
                        if(p->to.sym)
                                name = p->to.sym->name;
                        ctxt->diag("branch out of range (%#ux)\n%P [%s]", c, p, name);
-                       p->to.type = ctxt->arch->D_NONE;
+                       p->to.type = TYPE_NONE;
                }
                p->to.u.branch = q;
                p->pcond = q;
@@ -111,7 +111,7 @@ linkpatch(Link *ctxt, LSym *sym)
                if(p->pcond != nil) {
                        p->pcond = brloop(ctxt, p->pcond);
                        if(p->pcond != nil)
-                       if(p->to.type == ctxt->arch->D_BRANCH)
+                       if(p->to.type == TYPE_BRANCH)
                                p->to.offset = p->pcond->pc;
                }
        }
index f0ee1dc6726c9cdc5adcdd1a61b039c667576b44..0ab1581e1d0c849ed3197be1bd611c62cb3e117e 100644 (file)
@@ -291,7 +291,7 @@ linkpcln(Link *ctxt, LSym *cursym)
                        if(p->as == ctxt->arch->AFUNCDATA) {
                                i = p->from.offset;
                                pcln->funcdataoff[i] = p->to.offset;
-                               if(p->to.type != ctxt->arch->D_CONST) {
+                               if(p->to.type != TYPE_CONST) {
                                        // TODO: Dedup.
                                        //funcdata_bytes += p->to.sym->size;
                                        pcln->funcdata[i] = p->to.sym;