diff options
-rw-r--r-- | include/link.h | 7 | ||||
-rw-r--r-- | src/cmd/5l/5.out.h | 51 | ||||
-rw-r--r-- | src/cmd/5l/l.h | 46 | ||||
-rw-r--r-- | src/cmd/dist/buildgc.c | 22 | ||||
-rw-r--r-- | src/liblink/asm5.c | 50 | ||||
-rw-r--r-- | src/liblink/list5.c | 17 |
6 files changed, 96 insertions, 97 deletions
diff --git a/include/link.h b/include/link.h index c5f4841d3..2b4de789d 100644 --- a/include/link.h +++ b/include/link.h @@ -107,7 +107,7 @@ struct Prog uchar back; // 6l, 8l uchar ft; /* 6l, 8l oclass cache */ uchar tt; // 6l, 8l - uchar optab; // 5l + uint16 optab; // 5l uchar isize; // 6l, 8l char width; /* fake for DATA */ @@ -405,7 +405,7 @@ struct Link int asmode; uchar* andptr; uchar and[100]; - int32 instoffset; + int64 instoffset; int32 autosize; int32 armsize; @@ -608,6 +608,8 @@ extern char* anames5[]; extern char* anames6[]; extern char* anames8[]; +extern char* cnames5[]; + extern LinkArch link386; extern LinkArch linkamd64; extern LinkArch linkamd64p32; @@ -618,6 +620,7 @@ extern LinkArch linkarm; #pragma varargck type "lD" Addr* #pragma varargck type "P" Prog* #pragma varargck type "R" int +#pragma varargck type "^" int // TODO(ality): remove this workaround. // It's here because Pconv in liblink/list?.c references %L. diff --git a/src/cmd/5l/5.out.h b/src/cmd/5l/5.out.h index 7099c2769..7b16ac446 100644 --- a/src/cmd/5l/5.out.h +++ b/src/cmd/5l/5.out.h @@ -66,6 +66,57 @@ enum enum { + C_NONE, + C_REG, + C_REGREG, + C_REGREG2, + C_SHIFT, + C_FREG, + C_PSR, + C_FCR, + + C_RCON, /* 0xff rotated */ + C_NCON, /* ~RCON */ + C_SCON, /* 0xffff */ + C_LCON, + C_LCONADDR, + C_ZFCON, + C_SFCON, + C_LFCON, + + C_RACON, + C_LACON, + + C_SBRA, + C_LBRA, + + C_HAUTO, /* halfword insn offset (-0xff to 0xff) */ + C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */ + C_HFAUTO, /* both H and F */ + C_SAUTO, /* -0xfff to 0xfff */ + C_LAUTO, + + C_HOREG, + C_FOREG, + C_HFOREG, + C_SOREG, + C_ROREG, + C_SROREG, /* both nil and R */ + C_LOREG, + + C_PC, + C_SP, + C_HREG, + + C_ADDR, /* reference to relocatable address */ + + C_GOK, + + C_NCLASS, /* must be the last */ +}; + +enum +{ AXXX, AAND, diff --git a/src/cmd/5l/l.h b/src/cmd/5l/l.h index 2a7200e75..c881a544a 100644 --- a/src/cmd/5l/l.h +++ b/src/cmd/5l/l.h @@ -59,52 +59,6 @@ enum LEAF = 1<<2, MINLC = 4, - - C_NONE = 0, - C_REG, - C_REGREG, - C_REGREG2, - C_SHIFT, - C_FREG, - C_PSR, - C_FCR, - - C_RCON, /* 0xff rotated */ - C_NCON, /* ~RCON */ - C_SCON, /* 0xffff */ - C_LCON, - C_LCONADDR, - C_ZFCON, - C_SFCON, - C_LFCON, - - C_RACON, - C_LACON, - - C_SBRA, - C_LBRA, - - C_HAUTO, /* halfword insn offset (-0xff to 0xff) */ - C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */ - C_HFAUTO, /* both H and F */ - C_SAUTO, /* -0xfff to 0xfff */ - C_LAUTO, - - C_HOREG, - C_FOREG, - C_HFOREG, - C_SOREG, - C_ROREG, - C_SROREG, /* both nil and R */ - C_LOREG, - - C_PC, - C_SP, - C_HREG, - - C_ADDR, /* reference to relocatable address */ - - C_GOK, }; EXTERN int32 autosize; diff --git a/src/cmd/dist/buildgc.c b/src/cmd/dist/buildgc.c index 3bb0a9da1..178fbf913 100644 --- a/src/cmd/dist/buildgc.c +++ b/src/cmd/dist/buildgc.c @@ -65,17 +65,19 @@ gcopnames(char *dir, char *file) // mkanames reads [568].out.h and writes anames[568].c // The format is much the same as the Go opcodes above. +// it also writes out cnames array for C_* constants. void mkanames(char *dir, char *file) { int i, ch; - Buf in, b, out; + Buf in, b, out, out2; Vec lines; char *p; binit(&b); binit(&in); binit(&out); + binit(&out2); vinit(&lines); ch = file[xstrlen(file)-3]; @@ -105,10 +107,28 @@ mkanames(char *dir, char *file) } } bwritestr(&out, "};\n"); + + bprintf(&out2, "char* cnames%c[] = {\n", ch); + for(i=0; i<lines.len; i++) { + if(hasprefix(lines.p[i], "\tC_")) { + p = xstrstr(lines.p[i], ","); + if(p) + *p = '\0'; + p = xstrstr(lines.p[i], "\n"); + if(p) + *p = '\0'; + p = lines.p[i] + 3; + bwritestr(&out2, bprintf(&b, "\t\"%s\",\n", p)); + } + } + bwritestr(&out2, "};\n"); + bwriteb(&out, &out2); + writefile(&out, file, 0); bfree(&b); bfree(&in); bfree(&out); + bfree(&out2); vfree(&lines); } diff --git a/src/liblink/asm5.c b/src/liblink/asm5.c index 73a31862f..46aa1c1e3 100644 --- a/src/liblink/asm5.c +++ b/src/liblink/asm5.c @@ -65,52 +65,6 @@ enum LTO = 1<<1, LPOOL = 1<<2, LPCREL = 1<<3, - - C_NONE = 0, - C_REG, - C_REGREG, - C_REGREG2, - C_SHIFT, - C_FREG, - C_PSR, - C_FCR, - - C_RCON, /* 0xff rotated */ - C_NCON, /* ~RCON */ - C_SCON, /* 0xffff */ - C_LCON, - C_LCONADDR, - C_ZFCON, - C_SFCON, - C_LFCON, - - C_RACON, - C_LACON, - - C_SBRA, - C_LBRA, - - C_HAUTO, /* halfword insn offset (-0xff to 0xff) */ - C_FAUTO, /* float insn offset (0 to 0x3fc, word aligned) */ - C_HFAUTO, /* both H and F */ - C_SAUTO, /* -0xfff to 0xfff */ - C_LAUTO, - - C_HOREG, - C_FOREG, - C_HFOREG, - C_SOREG, - C_ROREG, - C_SROREG, /* both nil and R */ - C_LOREG, - - C_PC, - C_SP, - C_HREG, - - C_ADDR, /* reference to relocatable address */ - - C_GOK, }; static Optab optab[] = @@ -1264,7 +1218,7 @@ oplook(Link *ctxt, Prog *p) o = oprange[r].stop; /* just generate an error */ } if(0 /*debug['O']*/) { - print("oplook %A %d %d %d\n", + print("oplook %A %^ %^ %^\n", (int)p->as, a1, a2, a3); print(" %d %d\n", p->from.type, p->to.type); } @@ -1278,7 +1232,7 @@ oplook(Link *ctxt, Prog *p) p->optab = (o-optab)+1; return o; } - ctxt->diag("illegal combination %P; %d %d %d, %d %d", + ctxt->diag("illegal combination %P; %^ %^ %^, %d %d", p, a1, a2, a3, p->from.type, p->to.type); ctxt->diag("from %d %d to %d %d\n", p->from.type, p->from.name, p->to.type, p->to.name); prasm(p); diff --git a/src/liblink/list5.c b/src/liblink/list5.c index 4a4e8c71f..a91df55e6 100644 --- a/src/liblink/list5.c +++ b/src/liblink/list5.c @@ -46,6 +46,7 @@ static int Pconv(Fmt *fp); static int Rconv(Fmt *fp); static int RAconv(Fmt *fp); static int DSconv(Fmt *fp); +static int DRconv(Fmt*); #pragma varargck type "$" char* #pragma varargck type "M" Addr* @@ -59,6 +60,9 @@ listinit5(void) fmtinstall('P', Pconv); fmtinstall('R', Rconv); + // for liblink internal use + fmtinstall('^', DRconv); + // for internal use fmtinstall('$', DSconv); fmtinstall('M', Mconv); @@ -314,6 +318,19 @@ Rconv(Fmt *fp) } static int +DRconv(Fmt *fp) +{ + char *s; + int a; + + a = va_arg(fp->args, int); + s = "C_??"; + if(a >= C_NONE && a <= C_NCLASS) + s = cnames5[a]; + return fmtstrcpy(fp, s); +} + +static int Mconv(Fmt *fp) { char str[STRINGSZ]; |