qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

commit 6ca9399ed6bec1a448aef79236670cd3daeb7daf
parent 7a7a5f480312b997dcac0e4cc3befb502e54c836
Author: Quentin Carbonneaux <quentin@c9x.me>
Date:   Mon, 14 Mar 2022 10:58:55 +0100

output symbol type and size

That is not available on osx
so I tweaked the gas.c api
a little to conditionally
output the two directives.

Diffstat:
Mall.h | 6++++++
Mgas.c | 26++++++++++++++++++++++++++
Mmain.c | 17++---------------
3 files changed, 34 insertions(+), 15 deletions(-)

diff --git a/all.h b/all.h @@ -523,9 +523,15 @@ void spill(Fn *); void rega(Fn *); /* gas.c */ +enum Asm { + Gasmacho, + Gaself, +}; extern char *gasloc; extern char *gassym; +void gasinit(enum Asm); void gasemitlnk(char *, Lnk *, char *, FILE *); +void gasemitfntail(char *, FILE *); void gasemitdat(Dat *, FILE *); int gasstash(void *, int); void gasemitfin(FILE *); diff --git a/gas.c b/gas.c @@ -2,6 +2,23 @@ char *gasloc, *gassym; +static int gasasm; + +void +gasinit(enum Asm asmmode) +{ + gasasm = asmmode; + switch (gasasm) { + case Gaself: + gasloc = ".L"; + gassym = ""; + break; + case Gasmacho: + gasloc = "L"; + gassym = "_"; + break; + } +} void gasemitlnk(char *n, Lnk *l, char *s, FILE *f) @@ -25,6 +42,15 @@ gasemitlnk(char *n, Lnk *l, char *s, FILE *f) } void +gasemitfntail(char *fn, FILE *f) +{ + if (gasasm == Gaself) { + fprintf(f, ".type %s, @function\n", fn); + fprintf(f, ".size %s, .-%s\n", fn, fn); + } +} + +void gasemitdat(Dat *d, FILE *f) { static char *dtoa[] = { diff --git a/main.c b/main.c @@ -19,11 +19,6 @@ static struct TMap { { 0, 0 } }; -enum Asm { - Gasmacho, - Gaself, -}; - char debug['Z'+1] = { ['P'] = 0, /* parsing */ ['M'] = 0, /* memory optimization */ @@ -101,6 +96,7 @@ func(Fn *fn) fn->rpo[n]->link = fn->rpo[n+1]; if (!dbg) { T.emitfn(fn, outf); + gasemitfntail(fn->name, outf); fprintf(outf, "/* end function %s */\n\n", fn->name); } else fprintf(stderr, "\n"); @@ -174,16 +170,7 @@ main(int ac, char *av[]) exit(c != 'h'); } - switch (asmmode) { - case Gaself: - gasloc = ".L"; - gassym = ""; - break; - case Gasmacho: - gasloc = "L"; - gassym = "_"; - break; - } + gasinit(asmmode); do { f = av[optind];