diff options
Diffstat (limited to 'src/cmd/gc/export.c')
-rw-r--r-- | src/cmd/gc/export.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/cmd/gc/export.c b/src/cmd/gc/export.c index da5984ceb..aeee55236 100644 --- a/src/cmd/gc/export.c +++ b/src/cmd/gc/export.c @@ -7,6 +7,8 @@ #include "go.h" #include "y.tab.h" +static NodeList *asmlist; + static void dumpexporttype(Type *t); // Mark n's symbol as exported @@ -68,6 +70,11 @@ autoexport(Node *n, int ctxt) // -A is for cmd/gc/mkbuiltin script, so export everything if(debug['A'] || exportname(n->sym->name) || initname(n->sym->name)) exportsym(n); + if(asmhdr && n->sym->pkg == localpkg && !(n->sym->flags & SymAsm)) { + n->sym->flags |= SymAsm; + asmlist = list(asmlist, n); + } + } static void @@ -519,3 +526,37 @@ importtype(Type *pt, Type *t) if(debug['E']) print("import type %T %lT\n", pt, t); } + +void +dumpasmhdr(void) +{ + Biobuf *b; + NodeList *l; + Node *n; + Type *t; + + b = Bopen(asmhdr, OWRITE); + if(b == nil) + fatal("open %s: %r", asmhdr); + Bprint(b, "// generated by %cg -asmhdr from package %s\n\n", thechar, localpkg->name); + for(l=asmlist; l; l=l->next) { + n = l->n; + if(isblanksym(n->sym)) + continue; + switch(n->op) { + case OLITERAL: + Bprint(b, "#define const_%s %#V\n", n->sym->name, &n->val); + break; + case OTYPE: + t = n->type; + if(t->etype != TSTRUCT || t->map != T || t->funarg) + break; + for(t=t->type; t != T; t=t->down) + if(!isblanksym(t->sym)) + Bprint(b, "#define %s_%s %d\n", n->sym->name, t->sym->name, (int)t->width); + break; + } + } + + Bterm(b); +} |