summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2009-11-04 18:17:57 -0800
committerKen Thompson <ken@golang.org>2009-11-04 18:17:57 -0800
commit4aea02feb7aba0dd724b17e5fdb2ada173542ecf (patch)
tree6096a01a45cfcd7ee826e643ed09bf7c9fdaa64c /src
parentce9b3deaa4fa22e9d5580df05e9762b988793baa (diff)
downloadgolang-4aea02feb7aba0dd724b17e5fdb2ada173542ecf.tar.gz
speed up 6l
hopefully no change R=rsc http://go/go-review/1017035
Diffstat (limited to 'src')
-rw-r--r--src/cmd/6l/asm.c107
-rw-r--r--src/cmd/6l/l.h7
-rw-r--r--src/cmd/6l/list.c4
-rw-r--r--src/cmd/6l/obj.c31
-rw-r--r--src/cmd/6l/span.c23
5 files changed, 126 insertions, 46 deletions
diff --git a/src/cmd/6l/asm.c b/src/cmd/6l/asm.c
index 077755105..e5aa42c71 100644
--- a/src/cmd/6l/asm.c
+++ b/src/cmd/6l/asm.c
@@ -925,16 +925,17 @@ datblk(int32 s, int32 n)
int32 l, fl, j;
vlong o;
int i, c;
+ Adr *a;
memset(buf.dbuf, 0, n+Dbufslop);
for(p = datap; p != P; p = p->link) {
- curp = p;
- if(!p->from.sym->reachable)
- diag("unreachable symbol in datblk - %s", p->from.sym->name);
- if(p->from.sym->type == SMACHO)
+ a = &p->from;
+
+ l = a->sym->value + a->offset - s;
+ if(l >= n)
continue;
- l = p->from.sym->value + p->from.offset - s;
- c = p->from.scale;
+
+ c = a->scale;
i = 0;
if(l < 0) {
if(l+c <= 0)
@@ -942,8 +943,13 @@ datblk(int32 s, int32 n)
i = -l;
l = 0;
}
- if(l >= n)
+
+ curp = p;
+ if(!a->sym->reachable)
+ diag("unreachable symbol in datblk - %s", a->sym->name);
+ if(a->sym->type == SMACHO)
continue;
+
if(p->as != AINIT && p->as != ADYNT) {
for(j=l+(c-i)-1; j>=l; j--)
if(buf.dbuf[j]) {
@@ -960,8 +966,6 @@ datblk(int32 s, int32 n)
case 4:
fl = ieeedtof(&p->to.ieee);
cast = (uchar*)&fl;
- if(debug['a'] && i == 0)
- outa(c, cast, fnuxi4, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[fnuxi4[i]];
l++;
@@ -969,8 +973,6 @@ datblk(int32 s, int32 n)
break;
case 8:
cast = (uchar*)&p->to.ieee;
- if(debug['a'] && i == 0)
- outa(c, cast, fnuxi8, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[fnuxi8[i]];
l++;
@@ -980,8 +982,6 @@ datblk(int32 s, int32 n)
break;
case D_SCONST:
- if(debug['a'] && i == 0)
- outa(c, (uchar*)p->to.scon, nil, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = p->to.scon[i];
l++;
@@ -1016,24 +1016,18 @@ datblk(int32 s, int32 n)
diag("bad nuxi %d %d\n%P", c, i, curp);
break;
case 1:
- if(debug['a'] && i == 0)
- outa(c, cast, inuxi1, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[inuxi1[i]];
l++;
}
break;
case 2:
- if(debug['a'] && i == 0)
- outa(c, cast, inuxi2, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[inuxi2[i]];
l++;
}
break;
case 4:
- if(debug['a'] && i == 0)
- outa(c, cast, inuxi4, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[inuxi4[i]];
l++;
@@ -1041,8 +1035,6 @@ datblk(int32 s, int32 n)
break;
case 8:
cast = (uchar*)&o;
- if(debug['a'] && i == 0)
- outa(c, cast, inuxi8, l+s+INITDAT);
for(; i<c; i++) {
buf.dbuf[l] = cast[inuxi8[i]];
l++;
@@ -1052,7 +1044,80 @@ datblk(int32 s, int32 n)
break;
}
}
+
write(cout, buf.dbuf, n);
+ if(!debug['a'])
+ return;
+
+ /*
+ * a second pass just to print the asm
+ */
+ for(p = datap; p != P; p = p->link) {
+ a = &p->from;
+
+ l = a->sym->value + a->offset - s;
+ if(l >= n)
+ continue;
+
+ c = a->scale;
+ i = 0;
+ if(l < 0)
+ continue;
+
+ if(a->sym->type == SMACHO)
+ continue;
+
+ switch(p->to.type) {
+ case D_FCONST:
+ switch(c) {
+ default:
+ case 4:
+ fl = ieeedtof(&p->to.ieee);
+ cast = (uchar*)&fl;
+ outa(c, cast, fnuxi4, l+s+INITDAT);
+ break;
+ case 8:
+ cast = (uchar*)&p->to.ieee;
+ outa(c, cast, fnuxi8, l+s+INITDAT);
+ break;
+ }
+ break;
+
+ case D_SCONST:
+ outa(c, (uchar*)p->to.scon, nil, l+s+INITDAT);
+ break;
+
+ default:
+ o = p->to.offset;
+ if(p->to.type == D_SIZE)
+ o += p->to.sym->size;
+ if(p->to.type == D_ADDR) {
+ if(p->to.sym) {
+ o += p->to.sym->value;
+ if(p->to.sym->type != STEXT && p->to.sym->type != SUNDEF)
+ o += INITDAT;
+ }
+ }
+ fl = o;
+ cast = (uchar*)&fl;
+ switch(c) {
+ case 1:
+ outa(c, cast, inuxi1, l+s+INITDAT);
+ break;
+ case 2:
+ outa(c, cast, inuxi2, l+s+INITDAT);
+ break;
+ case 4:
+ outa(c, cast, inuxi4, l+s+INITDAT);
+ break;
+ case 8:
+ cast = (uchar*)&o;
+ outa(c, cast, inuxi8, l+s+INITDAT);
+ break;
+ }
+ break;
+ }
+ }
}
vlong
diff --git a/src/cmd/6l/l.h b/src/cmd/6l/l.h
index 91cfbabfd..be1aa4178 100644
--- a/src/cmd/6l/l.h
+++ b/src/cmd/6l/l.h
@@ -75,7 +75,6 @@ struct Adr
short type;
char index;
char scale;
- Sym* gotype;
};
#define offset u0.u0offset
@@ -97,10 +96,12 @@ struct Prog
Prog* pcond; /* work on this */
vlong pc;
int32 line;
+ short as;
+ char ft; /* oclass cache */
+ char tt;
uchar mark; /* work on these */
uchar back;
- short as;
char width; /* fake for DATA */
char mode; /* 16, 32, or 64 */
};
@@ -338,6 +339,8 @@ EXTERN int version;
EXTERN Prog zprg;
EXTERN int dtype;
EXTERN char* paramspace;
+EXTERN Sym* adrgotype; // type symbol on last Adr read
+EXTERN Sym* fromgotype; // type symbol on last p->from read
EXTERN Adr* reloca;
EXTERN int doexp; // export table
diff --git a/src/cmd/6l/list.c b/src/cmd/6l/list.c
index 286bba69c..34b66c0c8 100644
--- a/src/cmd/6l/list.c
+++ b/src/cmd/6l/list.c
@@ -209,8 +209,8 @@ brk:
}
conv:
fmtstrcpy(fp, str);
- if(a->gotype)
- fmtprint(fp, "«%s»", a->gotype->name);
+// if(a->gotype)
+// fmtprint(fp, "«%s»", a->gotype->name);
return 0;
}
diff --git a/src/cmd/6l/obj.c b/src/cmd/6l/obj.c
index 7098b42eb..ffe93fce4 100644
--- a/src/cmd/6l/obj.c
+++ b/src/cmd/6l/obj.c
@@ -408,12 +408,11 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
Auto *u;
t = Bgetc(f);
+ a->index = D_NONE;
+ a->scale = 0;
if(t & T_INDEX) {
a->index = Bgetc(f);
a->scale = Bgetc(f);
- } else {
- a->index = D_NONE;
- a->scale = 0;
}
a->offset = 0;
if(t & T_OFFSET) {
@@ -438,16 +437,17 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
}
if(t & T_TYPE)
a->type = Bgetc(f);
+ adrgotype = S;
if(t & T_GOTYPE)
- a->gotype = h[Bgetc(f)];
+ adrgotype = h[Bgetc(f)];
s = a->sym;
if(s == S)
return;
t = a->type;
if(t != D_AUTO && t != D_PARAM) {
- if(a->gotype)
- s->gotype = a->gotype;
+ if(adrgotype)
+ s->gotype = adrgotype;
return;
}
l = a->offset;
@@ -456,8 +456,8 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
if(u->type == t) {
if(u->aoffset > l)
u->aoffset = l;
- if(a->gotype)
- u->gotype = a->gotype;
+ if(adrgotype)
+ u->gotype = adrgotype;
return;
}
}
@@ -468,7 +468,7 @@ zaddr(Biobuf *f, Adr *a, Sym *h[])
u->asym = s;
u->aoffset = l;
u->type = t;
- u->gotype = a->gotype;
+ u->gotype = adrgotype;
}
void
@@ -575,7 +575,10 @@ loop:
p->line = Bget4(f);
p->back = 2;
p->mode = mode;
+ p->ft = 0;
+ p->tt = 0;
zaddr(f, &p->from, h);
+ fromgotype = adrgotype;
zaddr(f, &p->to, h);
if(debug['W'])
@@ -673,8 +676,8 @@ loop:
// redefinitions.
s = p->from.sym;
if(s != S && s->dupok) {
- if(debug['v'])
- Bprint(&bso, "skipping %s in %s: dupok\n", s->name, pn);
+// if(debug['v'])
+// Bprint(&bso, "skipping %s in %s: dupok\n", s->name, pn);
goto loop;
}
if(s != S) {
@@ -720,10 +723,10 @@ loop:
}
diag("%s: redefinition: %s\n%P", pn, s->name, p);
}
- if(p->from.gotype) {
- if(s->gotype && s->gotype != p->from.gotype)
+ if(fromgotype) {
+ if(s->gotype && s->gotype != fromgotype)
diag("%s: type mismatch for %s", pn, s->name);
- s->gotype = p->from.gotype;
+ s->gotype = fromgotype;
}
newtext(p, s);
goto loop;
diff --git a/src/cmd/6l/span.c b/src/cmd/6l/span.c
index 4930e545b..237a81fff 100644
--- a/src/cmd/6l/span.c
+++ b/src/cmd/6l/span.c
@@ -952,10 +952,12 @@ asmando(Adr *a, int o)
}
static void
-bytereg(Adr *a)
+bytereg(Adr *a, char *t)
{
- if(a->index == D_NONE && (a->type >= D_AX && a->type <= D_R15))
+ if(a->index == D_NONE && (a->type >= D_AX && a->type <= D_R15)) {
a->type = D_AL + (a->type-D_AX);
+ *t = 0;
+ }
}
#define E 0xff
@@ -1171,8 +1173,15 @@ doasm(Prog *p)
diag("asmins: missing op %P", p);
return;
}
- ft = oclass(&p->from) * Ymax;
- tt = oclass(&p->to) * Ymax;
+
+ if(p->ft == 0)
+ p->ft = oclass(&p->from);
+ if(p->tt == 0)
+ p->tt = oclass(&p->to);
+
+ ft = p->ft * Ymax;
+ tt = p->tt * Ymax;
+
t = o->ytab;
if(t == 0) {
diag("asmins: noproto %P", p);
@@ -1213,8 +1222,8 @@ found:
break;
case Pb: /* botch */
- bytereg(&p->from);
- bytereg(&p->to);
+ bytereg(&p->from, &p->ft);
+ bytereg(&p->to, &p->tt);
break;
case P32: /* 32 bit but illegal if 64-bit mode */
@@ -1247,7 +1256,7 @@ found:
break;
case Zmb_r:
- bytereg(&p->from);
+ bytereg(&p->from, &p->ft);
/* fall through */
case Zm_r:
*andptr++ = op;