From: Austin Clements Date: Fri, 14 Nov 2014 17:08:46 +0000 (-0500) Subject: [dev.power64] liblink: generate dnames[5689] for D_* constants X-Git-Tag: go1.5beta1~2688^2~24^2~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a11f256436a386c81e3a34378b37bc51fb2d5f61;p=gostls13.git [dev.power64] liblink: generate dnames[5689] for D_* constants This is more complicated than the other enums because the D_* enums are full of explicit initializers and repeated values. This tries its best. (This will get much cleaner once we tease these constants apart better.) LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/166700043 --- diff --git a/include/link.h b/include/link.h index 06f3ebb489..225c6f95df 100644 --- a/include/link.h +++ b/include/link.h @@ -626,6 +626,11 @@ extern char* anames9[]; extern char* cnames5[]; extern char* cnames9[]; +extern char* dnames5[]; +extern char* dnames6[]; +extern char* dnames8[]; +extern char* dnames9[]; + extern LinkArch link386; extern LinkArch linkamd64; extern LinkArch linkamd64p32; diff --git a/src/cmd/dist/buildgc.c b/src/cmd/dist/buildgc.c index 1c33297587..39679fb724 100644 --- a/src/cmd/dist/buildgc.c +++ b/src/cmd/dist/buildgc.c @@ -63,22 +63,36 @@ gcopnames(char *dir, char *file) vfree(&fields); } +static int +xatoi(char *s, char **end) +{ + int val = 0; + for(; *s && *s >= '0' && *s <= '9'; ++s) + val = val * 10 + (*s - '0'); + *end = s; + return val; +} + // mkanames reads [5689].out.h and writes anames[5689].c // The format is much the same as the Go opcodes above. -// it also writes out cnames array for C_* constants. +// It also writes out cnames array for C_* constants and the dnames +// array for D_* constants. void mkanames(char *dir, char *file) { - int i, j, ch; + int i, j, ch, n, unknown; Buf in, b, out, out2; Vec lines; - char *p; + char *p, *p2; + Vec dnames[128]; binit(&b); binit(&in); binit(&out); binit(&out2); vinit(&lines); + for(i=0; i\n")); bwritestr(&out, bprintf(&b, "#include \n")); bwritestr(&out, bprintf(&b, "#include \n")); bwritestr(&out, bprintf(&b, "#include \n")); + bwritestr(&out, bprintf(&b, "#include \"../cmd/%cl/%c.out.h\"\n", ch, ch)); bwritestr(&out, bprintf(&b, "\n")); bwritestr(&out, bprintf(&b, "char* anames%c[] = {\n", ch)); @@ -127,6 +143,67 @@ mkanames(char *dir, char *file) if(j>0) bwriteb(&out, &out2); + j=unknown=0; + n=-1; + for(i=0; i