diff options
Diffstat (limited to 'src/cmd/8c')
-rw-r--r-- | src/cmd/8c/gc.h | 75 | ||||
-rw-r--r-- | src/cmd/8c/list.c | 316 | ||||
-rw-r--r-- | src/cmd/8c/peep.c | 16 | ||||
-rw-r--r-- | src/cmd/8c/reg.c | 29 | ||||
-rw-r--r-- | src/cmd/8c/swt.c | 273 | ||||
-rw-r--r-- | src/cmd/8c/txt.c | 49 |
6 files changed, 73 insertions, 685 deletions
diff --git a/src/cmd/8c/gc.h b/src/cmd/8c/gc.h index b668b4c63..87b8e22bc 100644 --- a/src/cmd/8c/gc.h +++ b/src/cmd/8c/gc.h @@ -46,11 +46,8 @@ #define SZ_DOUBLE 8 #define FNX 100 -typedef struct Adr Adr; -typedef struct Prog Prog; typedef struct Case Case; typedef struct C1 C1; -typedef struct Var Var; typedef struct Reg Reg; typedef struct Rgn Rgn; typedef struct Renv Renv; @@ -64,30 +61,10 @@ EXTERN struct short ptr; } idx; -struct Adr -{ - int32 offset; - int32 offset2; - double dval; - char sval[NSNAME]; - - Sym* sym; - uchar type; - uchar index; - uchar etype; - uchar scale; /* doubles as width in DATA op */ -}; -#define A ((Adr*)0) +#define A ((Addr*)0) #define INDEXED 9 -struct Prog -{ - Adr from; - Adr to; - Prog* link; - int32 lineno; - short as; -}; + #define P ((Prog*)0) struct Case @@ -106,14 +83,6 @@ struct C1 int32 label; }; -struct Var -{ - int32 offset; - Sym* sym; - char name; - char etype; -}; - struct Reg { int32 pc; @@ -171,7 +140,6 @@ EXTERN Node fconstnode; EXTERN int32 continpc; EXTERN int32 curarg; EXTERN int32 cursafe; -EXTERN Prog* firstp; EXTERN Prog* lastp; EXTERN int32 maxargsafe; EXTERN int mnstring; @@ -226,7 +194,6 @@ EXTERN Reg* firstr; EXTERN Reg* lastr; EXTERN Reg zreg; EXTERN Reg* freer; -EXTERN Var var[NVAR]; EXTERN int32* idom; EXTERN Reg** rpo2r; EXTERN int32 maxnr; @@ -287,7 +254,7 @@ void regaalloc1(Node*, Node*); void regaalloc(Node*, Node*); void regind(Node*, Node*); void gprep(Node*, Node*); -void naddr(Node*, Adr*); +void naddr(Node*, Addr*); void gmove(Node*, Node*); void gins(int a, Node*, Node*); void fgopcode(int, Node*, Node*, int, int); @@ -315,19 +282,11 @@ void nullwarn(Node*, Node*); void sextern(Sym*, Node*, int32, int32); void gextern(Sym*, Node*, int32, int32); void outcode(void); -void ieeedtod(Ieee*, double); /* * list */ void listinit(void); -int Pconv(Fmt*); -int Aconv(Fmt*); -int Dconv(Fmt*); -int Sconv(Fmt*); -int Rconv(Fmt*); -int Xconv(Fmt*); -int Bconv(Fmt*); /* * reg.c @@ -336,7 +295,7 @@ Reg* rega(void); int rcmp(const void*, const void*); void regopt(Prog*); void addmove(Reg*, int, int, int); -Bits mkvar(Reg*, Adr*); +Bits mkvar(Reg*, Addr*); void prop(Reg*, Bits, Bits); void loopit(Reg*, int32); void synch(Reg*, Bits); @@ -344,7 +303,7 @@ uint32 allreg(uint32, Rgn*); void paint1(Reg*, int); uint32 paint2(Reg*, int); void paint3(Reg*, int, int32, int); -void addreg(Adr*, int); +void addreg(Addr*, int); /* * peep.c @@ -353,17 +312,17 @@ void peep(void); void excise(Reg*); Reg* uniqp(Reg*); Reg* uniqs(Reg*); -int regtyp(Adr*); -int anyvar(Adr*); +int regtyp(Addr*); +int anyvar(Addr*); int subprop(Reg*); int copyprop(Reg*); -int copy1(Adr*, Adr*, Reg*, int); -int copyu(Prog*, Adr*, Adr*); +int copy1(Addr*, Addr*, Reg*, int); +int copyu(Prog*, Addr*, Addr*); -int copyas(Adr*, Adr*); -int copyau(Adr*, Adr*); -int copysub(Adr*, Adr*, Adr*, int); -int copysub1(Prog*, Adr*, Adr*, int); +int copyas(Addr*, Addr*); +int copyau(Addr*, Addr*); +int copysub(Addr*, Addr*, Addr*, int); +int copysub1(Prog*, Addr*, Addr*, int); int32 RtoB(int); int32 FtoB(int); @@ -401,14 +360,6 @@ void mulgen(Type*, Node*, Node*); void genmuladd(Node*, Node*, int, Node*); void shiftit(Type*, Node*, Node*); -#pragma varargck type "A" int -#pragma varargck type "B" Bits -#pragma varargck type "D" Adr* -#pragma varargck type "lD" Adr* -#pragma varargck type "P" Prog* -#pragma varargck type "R" int -#pragma varargck type "S" char* - /* wrecklessly steal a field */ #define rplink label diff --git a/src/cmd/8c/list.c b/src/cmd/8c/list.c index 8506e08ef..1730eccd0 100644 --- a/src/cmd/8c/list.c +++ b/src/cmd/8c/list.c @@ -34,319 +34,5 @@ void listinit(void) { - - fmtinstall('A', Aconv); - fmtinstall('B', Bconv); - fmtinstall('P', Pconv); - fmtinstall('S', Sconv); - fmtinstall('D', Dconv); - fmtinstall('R', Rconv); -} - -int -Bconv(Fmt *fp) -{ - char str[STRINGSZ], ss[STRINGSZ], *s; - Bits bits; - int i; - - str[0] = 0; - bits = va_arg(fp->args, Bits); - while(bany(&bits)) { - i = bnum(bits); - if(str[0]) - strcat(str, " "); - if(var[i].sym == S) { - sprint(ss, "$%d", var[i].offset); - s = ss; - } else - s = var[i].sym->name; - if(strlen(str) + strlen(s) + 1 >= STRINGSZ) - break; - strcat(str, s); - bits.b[i/32] &= ~(1L << (i%32)); - } - return fmtstrcpy(fp, str); -} - -int -Pconv(Fmt *fp) -{ - char str[STRINGSZ]; - Prog *p; - - p = va_arg(fp->args, Prog*); - switch(p->as) { - case ADATA: - sprint(str, "(%L) %A %D/%d,%D", - p->lineno, p->as, &p->from, p->from.scale, &p->to); - break; - - case ATEXT: - if(p->from.scale) { - sprint(str, "(%L) %A %D,%d,%lD", - p->lineno, p->as, &p->from, p->from.scale, &p->to); - break; - } - sprint(str, "(%L) %A %D,%lD", - p->lineno, p->as, &p->from, &p->to); - break; - - default: - sprint(str, "(%L) %A %D,%D", - p->lineno, p->as, &p->from, &p->to); - break; - } - return fmtstrcpy(fp, str); -} - -int -Aconv(Fmt *fp) -{ - int i; - - i = va_arg(fp->args, int); - return fmtstrcpy(fp, anames[i]); -} - -int -Dconv(Fmt *fp) -{ - char str[STRINGSZ], s[STRINGSZ]; - Adr *a; - int i; - - a = va_arg(fp->args, Adr*); - i = a->type; - - if(fp->flags & FmtLong) { - if(i == D_CONST2) - sprint(str, "$%d-%d", a->offset, a->offset2); - else { - // ATEXT dst is not constant - sprint(str, "!!%D", a); - } - goto brk; - } - - if(i >= D_INDIR) { - if(a->offset) - sprint(str, "%d(%R)", a->offset, i-D_INDIR); - else - sprint(str, "(%R)", i-D_INDIR); - goto brk; - } - switch(i) { - default: - if(a->offset) - sprint(str, "$%d,%R", a->offset, i); - else - sprint(str, "%R", i); - break; - - case D_NONE: - str[0] = 0; - break; - - case D_BRANCH: - sprint(str, "%d", a->offset); - break; - - case D_EXTERN: - sprint(str, "%s+%d(SB)", a->sym->name, a->offset); - break; - - case D_STATIC: - sprint(str, "%s<>+%d(SB)", a->sym->name, a->offset); - break; - - case D_AUTO: - if(a->sym) - sprint(str, "%s+%d(SP)", a->sym->name, a->offset); - else - sprint(str, "%d(SP)", a->offset); - break; - - case D_PARAM: - if(a->sym) - sprint(str, "%s+%d(FP)", a->sym->name, a->offset); - else - sprint(str, "%d(FP)", a->offset); - break; - - case D_CONST: - sprint(str, "$%d", a->offset); - break; - - case D_CONST2: - if(!(fp->flags & FmtLong)) { - // D_CONST2 outside of ATEXT should not happen - sprint(str, "!!$%d-%d", a->offset, a->offset2); - } - break; - - case D_FCONST: - sprint(str, "$(%.17e)", a->dval); - break; - - case D_SCONST: - sprint(str, "$\"%S\"", a->sval); - break; - - case D_ADDR: - a->type = a->index; - a->index = D_NONE; - sprint(str, "$%D", a); - a->index = a->type; - a->type = D_ADDR; - goto conv; - } -brk: - if(a->index != D_NONE) { - sprint(s, "(%R*%d)", (int)a->index, (int)a->scale); - strcat(str, s); - } -conv: - return fmtstrcpy(fp, str); -} - -char* regstr[] = -{ - "AL", /* [D_AL] */ - "CL", - "DL", - "BL", - "AH", - "CH", - "DH", - "BH", - - "AX", /* [D_AX] */ - "CX", - "DX", - "BX", - "SP", - "BP", - "SI", - "DI", - - "F0", /* [D_F0] */ - "F1", - "F2", - "F3", - "F4", - "F5", - "F6", - "F7", - - "CS", /* [D_CS] */ - "SS", - "DS", - "ES", - "FS", - "GS", - - "GDTR", /* [D_GDTR] */ - "IDTR", /* [D_IDTR] */ - "LDTR", /* [D_LDTR] */ - "MSW", /* [D_MSW] */ - "TASK", /* [D_TASK] */ - - "CR0", /* [D_CR] */ - "CR1", - "CR2", - "CR3", - "CR4", - "CR5", - "CR6", - "CR7", - - "DR0", /* [D_DR] */ - "DR1", - "DR2", - "DR3", - "DR4", - "DR5", - "DR6", - "DR7", - - "TR0", /* [D_TR] */ - "TR1", - "TR2", - "TR3", - "TR4", - "TR5", - "TR6", - "TR7", - - "X0", /* [D_X0] */ - "X1", - "X2", - "X3", - "X4", - "X5", - "X6", - "X7", - - "NONE", /* [D_NONE] */ -}; - -int -Rconv(Fmt *fp) -{ - char str[STRINGSZ]; - int r; - - r = va_arg(fp->args, int); - if(r >= D_AL && r <= D_NONE) - sprint(str, "%s", regstr[r-D_AL]); - else - sprint(str, "gok(%d)", r); - - return fmtstrcpy(fp, str); -} - -int -Sconv(Fmt *fp) -{ - int i, c; - char str[STRINGSZ], *p, *a; - - a = va_arg(fp->args, char*); - p = str; - for(i=0; i<sizeof(double); i++) { - c = a[i] & 0xff; - if(c >= 'a' && c <= 'z' || - c >= 'A' && c <= 'Z' || - c >= '0' && c <= '9') { - *p++ = c; - continue; - } - *p++ = '\\'; - switch(c) { - default: - if(c < 040 || c >= 0177) - break; /* not portable */ - p[-1] = c; - continue; - case 0: - *p++ = 'z'; - continue; - case '\\': - case '"': - *p++ = c; - continue; - case '\n': - *p++ = 'n'; - continue; - case '\t': - *p++ = 't'; - continue; - } - *p++ = (c>>6) + '0'; - *p++ = ((c>>3) & 7) + '0'; - *p++ = (c & 7) + '0'; - } - *p = 0; - return fmtstrcpy(fp, str); + listinit8(); } diff --git a/src/cmd/8c/peep.c b/src/cmd/8c/peep.c index da0127d11..4f58fc05c 100644 --- a/src/cmd/8c/peep.c +++ b/src/cmd/8c/peep.c @@ -217,7 +217,7 @@ uniqs(Reg *r) } int -regtyp(Adr *a) +regtyp(Addr *a) { int t; @@ -245,7 +245,7 @@ int subprop(Reg *r0) { Prog *p; - Adr *v1, *v2; + Addr *v1, *v2; Reg *r; int t; @@ -365,7 +365,7 @@ int copyprop(Reg *r0) { Prog *p; - Adr *v1, *v2; + Addr *v1, *v2; Reg *r; p = r0->prog; @@ -379,7 +379,7 @@ copyprop(Reg *r0) } int -copy1(Adr *v1, Adr *v2, Reg *r, int f) +copy1(Addr *v1, Addr *v2, Reg *r, int f) { int t; Prog *p; @@ -464,7 +464,7 @@ copy1(Adr *v1, Adr *v2, Reg *r, int f) * 0 otherwise (not touched) */ int -copyu(Prog *p, Adr *v, Adr *s) +copyu(Prog *p, Addr *v, Addr *s) { switch(p->as) { @@ -740,7 +740,7 @@ copyu(Prog *p, Adr *v, Adr *s) * semantics */ int -copyas(Adr *a, Adr *v) +copyas(Addr *a, Addr *v) { if(a->type != v->type) return 0; @@ -756,7 +756,7 @@ copyas(Adr *a, Adr *v) * either direct or indirect */ int -copyau(Adr *a, Adr *v) +copyau(Addr *a, Addr *v) { if(copyas(a, v)) @@ -775,7 +775,7 @@ copyau(Adr *a, Adr *v) * return failure to substitute */ int -copysub(Adr *a, Adr *v, Adr *s, int f) +copysub(Addr *a, Addr *v, Addr *s, int f) { int t; diff --git a/src/cmd/8c/reg.c b/src/cmd/8c/reg.c index a3d5d6115..e6ba8bcb3 100644 --- a/src/cmd/8c/reg.c +++ b/src/cmd/8c/reg.c @@ -558,7 +558,7 @@ brk: if(debug['R'] && debug['v']) { print("after pass 7 (peep)\n"); for(r=firstr; r; r=r->link) - print("%04d %P\n", r->pc, r->prog); + print("%04d %P\n", (int)r->pc, r->prog); print("\n"); } @@ -602,8 +602,10 @@ brk: r1 = 0; /* set */ for(r = firstr; r != R; r = r->link) { p = r->prog; - if(p->to.type == D_BRANCH) + if(p->to.type == D_BRANCH) { p->to.offset = r->s2->pc; + p->to.u.branch = r->s2->prog; + } r1 = r; } @@ -638,7 +640,7 @@ void addmove(Reg *r, int bn, int rn, int f) { Prog *p, *p1; - Adr *a; + Addr *a; Var *v; p1 = alloc(sizeof(*p1)); @@ -697,13 +699,13 @@ doregbits(int r) } Bits -mkvar(Reg *r, Adr *a) +mkvar(Reg *r, Addr *a) { Var *v; int i, t, n, et, z; int32 o; Bits bit; - Sym *s; + LSym *s; /* * mark registers used @@ -730,7 +732,7 @@ mkvar(Reg *r, Adr *a) break; } s = a->sym; - if(s == S) + if(s == nil) goto none; if(s->name[0] == '.') goto none; @@ -1121,7 +1123,7 @@ uint32 regset(Reg *r, uint32 bb) { uint32 b, set; - Adr v; + Addr v; int c; set = 0; @@ -1140,7 +1142,7 @@ uint32 reguse(Reg *r, uint32 bb) { uint32 b, set; - Adr v; + Addr v; int c; set = 0; @@ -1287,7 +1289,7 @@ paint3(Reg *r, int bn, int32 rb, int rn) } void -addreg(Adr *a, int rn) +addreg(Addr *a, int rn) { a->sym = 0; @@ -1373,10 +1375,11 @@ fixjmp(Reg *firstr) for(r=firstr; r; r=r->link) { p = r->prog; if(debug['R'] && debug['v']) - print("%04d %P\n", r->pc, p); + print("%04d %P\n", (int)r->pc, p); if(p->as != ACALL && p->to.type == D_BRANCH && r->s2 && r->s2->prog->as == AJMP) { r->s2 = chasejmp(r->s2, &jmploop); p->to.offset = r->s2->pc; + p->to.u.branch = r->s2->prog; if(debug['R'] && debug['v']) print("->%P\n", p); } @@ -1397,7 +1400,7 @@ fixjmp(Reg *firstr) // Let it stay. } else { if(debug['R'] && debug['v']) - print("del %04d %P\n", r->pc, p); + print("del %04d %P\n", (int)r->pc, p); p->as = ANOP; } } @@ -1410,7 +1413,7 @@ fixjmp(Reg *firstr) p = r->prog; if(p->as == AJMP && p->to.type == D_BRANCH && r->s2 == r->link) { if(debug['R'] && debug['v']) - print("del %04d %P\n", r->pc, p); + print("del %04d %P\n", (int)r->pc, p); p->as = ANOP; } } @@ -1431,7 +1434,7 @@ fixjmp(Reg *firstr) if(debug['R'] && debug['v']) { print("\n"); for(r=firstr; r; r=r->link) - print("%04d %P\n", r->pc, r->prog); + print("%04d %P\n", (int)r->pc, r->prog); print("\n"); } } diff --git a/src/cmd/8c/swt.c b/src/cmd/8c/swt.c index b68197447..ae36f84ea 100644 --- a/src/cmd/8c/swt.c +++ b/src/cmd/8c/swt.c @@ -169,7 +169,7 @@ outstring(char *s, int32 n) p->from.offset += nstring - NSNAME; p->from.scale = NSNAME; p->to.type = D_SCONST; - memmove(p->to.sval, string, NSNAME); + memmove(p->to.u.sval, string, NSNAME); mnstring = 0; } n--; @@ -190,7 +190,7 @@ sextern(Sym *s, Node *a, int32 o, int32 w) p->from.offset += o+e; p->from.scale = lw; p->to.type = D_SCONST; - memmove(p->to.sval, a->cstring+e, lw); + memmove(p->to.u.sval, a->cstring+e, lw); } } @@ -220,29 +220,12 @@ gextern(Sym *s, Node *a, int32 o, int32 w) } } -void zname(Biobuf*, Sym*, int); -void zaddr(Biobuf*, Adr*, int); -void outhist(Biobuf*); - void outcode(void) { - struct { Sym *sym; short type; } h[NSYM]; - Prog *p; - Sym *s; - int f, sf, st, t, sym; + int f; Biobuf b; - if(debug['S']) { - for(p = firstp; p != P; p = p->link) - if(p->as != ADATA && p->as != AGLOBL) - pc--; - for(p = firstp; p != P; p = p->link) { - print("%P\n", p); - if(p->as != ADATA && p->as != AGLOBL) - pc++; - } - } f = open(outfile, OWRITE); if(f < 0) { diag(Z, "cannot open %s", outfile); @@ -250,7 +233,7 @@ outcode(void) } Binit(&b, f, OWRITE); - Bprint(&b, "go object %s %s %s\n", getgoos(), thestring, getgoversion()); + Bprint(&b, "go object %s %s %s\n", getgoos(), getgoarch(), getgoversion()); if(pragcgobuf.to > pragcgobuf.start) { Bprint(&b, "\n"); Bprint(&b, "$$ // exports\n\n"); @@ -261,258 +244,12 @@ outcode(void) } Bprint(&b, "!\n"); - outhist(&b); - for(sym=0; sym<NSYM; sym++) { - h[sym].sym = S; - h[sym].type = 0; - } - sym = 1; - for(p = firstp; p != P; p = p->link) { - jackpot: - sf = 0; - s = p->from.sym; - while(s != S) { - sf = s->sym; - if(sf < 0 || sf >= NSYM) - sf = 0; - t = p->from.type; - if(t == D_ADDR) - t = p->from.index; - if(h[sf].type == t) - if(h[sf].sym == s) - break; - s->sym = sym; - zname(&b, s, t); - h[sym].sym = s; - h[sym].type = t; - sf = sym; - sym++; - if(sym >= NSYM) - sym = 1; - break; - } - st = 0; - s = p->to.sym; - while(s != S) { - st = s->sym; - if(st < 0 || st >= NSYM) - st = 0; - t = p->to.type; - if(t == D_ADDR) - t = p->to.index; - if(h[st].type == t) - if(h[st].sym == s) - break; - s->sym = sym; - zname(&b, s, t); - h[sym].sym = s; - h[sym].type = t; - st = sym; - sym++; - if(sym >= NSYM) - sym = 1; - if(st == sf) - goto jackpot; - break; - } - BPUTLE2(&b, p->as); - BPUTLE4(&b, p->lineno); - zaddr(&b, &p->from, sf); - zaddr(&b, &p->to, st); - } + writeobj(ctxt, &b); Bterm(&b); close(f); - firstp = P; lastp = P; } -void -outhist(Biobuf *b) -{ - Hist *h; - char *p, *q, *op, c; - Prog pg; - int n; - char *tofree; - static int first = 1; - static char *goroot, *goroot_final; - - if(first) { - // Decide whether we need to rewrite paths from $GOROOT to $GOROOT_FINAL. - first = 0; - goroot = getenv("GOROOT"); - goroot_final = getenv("GOROOT_FINAL"); - if(goroot == nil) - goroot = ""; - if(goroot_final == nil) - goroot_final = goroot; - if(strcmp(goroot, goroot_final) == 0) { - goroot = nil; - goroot_final = nil; - } - } - - tofree = nil; - pg = zprog; - pg.as = AHISTORY; - c = pathchar(); - for(h = hist; h != H; h = h->link) { - p = h->name; - if(p != nil && goroot != nil) { - n = strlen(goroot); - if(strncmp(p, goroot, strlen(goroot)) == 0 && p[n] == '/') { - tofree = smprint("%s%s", goroot_final, p+n); - p = tofree; - } - } - op = 0; - if(systemtype(Windows) && p && p[1] == ':'){ - c = p[2]; - } else if(p && p[0] != c && h->offset == 0 && pathname){ - if(systemtype(Windows) && pathname[1] == ':') { - op = p; - p = pathname; - c = p[2]; - } else if(pathname[0] == c){ - op = p; - p = pathname; - } - } - while(p) { - q = utfrune(p, c); - if(q) { - n = q-p; - if(n == 0){ - n = 1; /* leading "/" */ - *p = '/'; /* don't emit "\" on windows */ - } - q++; - } else { - n = strlen(p); - q = 0; - } - if(n) { - BPUTLE2(b, ANAME); - BPUTC(b, D_FILE); - BPUTC(b, 1); - BPUTC(b, '<'); - Bwrite(b, p, n); - BPUTC(b, 0); - } - p = q; - if(p == 0 && op) { - p = op; - op = 0; - } - } - pg.lineno = h->line; - pg.to.type = zprog.to.type; - pg.to.offset = h->offset; - if(h->offset) - pg.to.type = D_CONST; - - BPUTLE2(b, pg.as); - BPUTLE4(b, pg.lineno); - zaddr(b, &pg.from, 0); - zaddr(b, &pg.to, 0); - - if(tofree) { - free(tofree); - tofree = nil; - } - } -} - -void -zname(Biobuf *b, Sym *s, int t) -{ - char *n; - uint32 sig; - - if(debug['T'] && t == D_EXTERN && s->sig != SIGDONE && s->type != types[TENUM] && s != symrathole){ - sig = sign(s); - BPUTLE2(b, ASIGNAME); - BPUTLE4(b, sig); - s->sig = SIGDONE; - } - else{ - BPUTLE2(b, ANAME); /* as */ - } - BPUTC(b, t); /* type */ - BPUTC(b, s->sym); /* sym */ - n = s->name; - while(*n) { - BPUTC(b, *n); - n++; - } - BPUTC(b, 0); -} - -void -zaddr(Biobuf *b, Adr *a, int s) -{ - int32 l; - int i, t; - char *n; - Ieee e; - - t = 0; - if(a->index != D_NONE || a->scale != 0) - t |= T_INDEX; - if(s != 0) - t |= T_SYM; - - switch(a->type) { - default: - t |= T_TYPE; - case D_NONE: - if(a->offset != 0) - t |= T_OFFSET; - break; - case D_FCONST: - t |= T_FCONST; - break; - case D_SCONST: - t |= T_SCONST; - break; - case D_CONST2: - t |= T_OFFSET|T_OFFSET2; - break; - } - BPUTC(b, t); - - if(t & T_INDEX) { /* implies index, scale */ - BPUTC(b, a->index); - BPUTC(b, a->scale); - } - if(t & T_OFFSET) { /* implies offset */ - l = a->offset; - BPUTLE4(b, l); - } - if(t & T_OFFSET2) { /* implies offset2 */ - l = a->offset2; - BPUTLE4(b, l); - } - if(t & T_SYM) /* implies sym */ - BPUTC(b, s); - if(t & T_FCONST) { - ieeedtod(&e, a->dval); - BPUTLE4(b, e.l); - BPUTLE4(b, e.h); - return; - } - if(t & T_SCONST) { - n = a->sval; - for(i=0; i<NSNAME; i++) { - BPUTC(b, *n); - n++; - } - return; - } - if(t & T_TYPE) - BPUTC(b, a->type); -} - int32 align(int32 i, Type *t, int op, int32 *maxalign) { diff --git a/src/cmd/8c/txt.c b/src/cmd/8c/txt.c index 5c486af38..25082de05 100644 --- a/src/cmd/8c/txt.c +++ b/src/cmd/8c/txt.c @@ -30,14 +30,23 @@ #include "gc.h" + +int thechar = '8'; +char *thestring = "386"; + +LinkArch *thelinkarch = &link386; + +void +linkarchinit(void) +{ +} + void ginit(void) { int i; Type *t; - thechar = '8'; - thestring = "386"; exregoffset = 0; exfregoffset = 0; listinit(); @@ -48,7 +57,6 @@ ginit(void) breakpc = -1; continpc = -1; cases = C; - firstp = P; lastp = P; tfield = types[TLONG]; @@ -156,17 +164,18 @@ gclean(void) void nextpc(void) { + Plist *pl; p = alloc(sizeof(*p)); *p = zprog; p->lineno = nearln; + p->pc = pc; pc++; - if(firstp == P) { - firstp = p; - lastp = p; - return; - } - lastp->link = p; + if(lastp == nil) { + pl = linknewplist(ctxt); + pl->firstpc = p; + } else + lastp->link = p; lastp = p; } @@ -188,7 +197,8 @@ gargs(Node *n, Node *tn1, Node *tn2) cursafe = regs; } -int nareg(void) +int +nareg(void) { int i, n; @@ -435,7 +445,7 @@ regind(Node *n, Node *nn) } void -naddr(Node *n, Adr *a) +naddr(Node *n, Addr *a) { int32 v; @@ -450,11 +460,11 @@ naddr(Node *n, Adr *a) case OREGISTER: a->type = n->reg; - a->sym = S; + a->sym = nil; break; case OEXREG: - a->type = D_INDIR + D_GS; + a->type = D_INDIR + D_TLS; a->offset = n->reg - 1; break; @@ -495,14 +505,14 @@ naddr(Node *n, Adr *a) case OINDREG: a->type = n->reg+D_INDIR; - a->sym = S; + a->sym = nil; a->offset = n->xoffset; break; case ONAME: a->etype = n->etype; a->type = D_STATIC; - a->sym = n->sym; + a->sym = linksym(n->sym); a->offset = n->xoffset; if(n->class == CSTATIC) break; @@ -523,10 +533,10 @@ naddr(Node *n, Adr *a) case OCONST: if(typefd[n->type->etype]) { a->type = D_FCONST; - a->dval = n->fconst; + a->u.dval = n->fconst; break; } - a->sym = S; + a->sym = nil; a->type = D_CONST; a->offset = n->vconst; break; @@ -1366,9 +1376,10 @@ gbranch(int o) void patch(Prog *op, int32 pc) { - op->to.offset = pc; op->to.type = D_BRANCH; + op->to.u.branch = nil; + op->pcond = nil; } void @@ -1378,7 +1389,7 @@ gpseudo(int a, Sym *s, Node *n) nextpc(); p->as = a; p->from.type = D_EXTERN; - p->from.sym = s; + p->from.sym = linksym(s); switch(a) { case ATEXT: |