qbe

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

commit 349794f3e4f11e4cc34a501ba935a2a305229738
parent 3d294346ab168fd0b12761711fbe667e47fd644e
Author: Quentin Carbonneaux <quentin@c9x.me>
Date:   Tue,  8 Mar 2022 15:33:21 +0100

cosmetics

Diffstat:
Mall.h | 3++-
Mamd64/sysv.c | 4++--
Marm64/abi.c | 10+++++++---
Mdoc/rv64.txt | 2+-
Mlive.c | 2+-
Mrv64/abi.c | 6+++---
Mutil.c | 12+++++++++---
7 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/all.h b/all.h @@ -441,7 +441,8 @@ void chuse(Ref, int, Fn *); Ref newcon(Con *, Fn *); Ref getcon(int64_t, Fn *); int addcon(Con *, Con *); -void blit(Ref, uint, Ref, uint, Fn *); +void blit(Ref, uint, Ref, uint, uint, Fn *); +void blit0(Ref, Ref, uint, Fn *); void dumpts(BSet *, Tmp *, FILE *); void bsinit(BSet *, uint); diff --git a/amd64/sysv.c b/amd64/sysv.c @@ -127,7 +127,7 @@ selret(Blk *b, Fn *fn) if (aret.inmem) { assert(rtype(fn->retr) == RTmp); emit(Ocopy, Kl, TMP(RAX), fn->retr, R); - blit(fn->retr, 0, r0, aret.type->size, fn); + blit0(fn->retr, r0, aret.type->size, fn); ca = 1; } else { ca = retr(reg, &aret); @@ -413,7 +413,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, RAlloc **rap) if (i->op == Oargc) { if (a->align == 4) off += off & 15; - blit(r, off, i->arg[1], a->type->size, fn); + blit(r, off, i->arg[1], 0, a->type->size, fn); } else { r1 = newtmp("abi", Kl, fn); emit(Ostorel, 0, R, i->arg[0], r1); diff --git a/arm64/abi.c b/arm64/abi.c @@ -181,7 +181,7 @@ selret(Blk *b, Fn *fn) cty = (cr.nfp << 2) | cr.ngp; if (cr.class & Cptr) { assert(rtype(fn->retr) == RTmp); - blit(fn->retr, 0, r, cr.t->size, fn); + blit0(fn->retr, r, cr.t->size, fn); } else ldregs(cr.reg, cr.cls, cr.nreg, r, fn); } else { @@ -359,6 +359,10 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) stkblob(i1->to, &cr, fn, ilp); cty |= (cr.nfp << 2) | cr.ngp; if (cr.class & Cptr) { + /* spill & rega expect calls to be + * followed by copies from regs, + * so we emit a dummy + */ cty |= 1 << 13 | 1; emit(Ocopy, Kw, R, TMP(R0), R); } else { @@ -407,7 +411,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) emit(Oadd, Kl, r, TMP(SP), getcon(off, fn)); } if (i->op == Oargc) - blit(TMP(SP), off, i->arg[1], c->size, fn); + blit(TMP(SP), off, i->arg[1], 0, c->size, fn); off += c->size; } if (stk) @@ -415,7 +419,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) for (i=i0, c=ca; i<i1; i++, c++) if (c->class & Cptr) - blit(i->arg[0], 0, i->arg[1], c->t->size, fn); + blit0(i->arg[0], i->arg[1], c->t->size, fn); } static Params diff --git a/doc/rv64.txt b/doc/rv64.txt @@ -17,4 +17,4 @@ rv64_isel() could turn compare used only with jnz into b{lt,ge}[u]. RISC-V spec: https://github.com/riscv/riscv-isa-manual/releases/latest/download/riscv-spec.pdf ASM manual: https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md -psABI: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc +ABI: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc diff --git a/live.c b/live.c @@ -103,7 +103,7 @@ Again: if (!req(i->to, R)) { assert(rtype(i->to) == RTmp); t = i->to.val; - if (bshas(b->in, i->to.val)) + if (bshas(b->in, t)) nlv[KBASE(f->tmp[t].cls)]--; bsset(b->gen, t); bsclr(b->in, t); diff --git a/rv64/abi.c b/rv64/abi.c @@ -185,7 +185,7 @@ selret(Blk *b, Fn *fn) cty = (cr.nfp << 2) | cr.ngp; if (cr.class & Cptr) { assert(rtype(fn->retr) == RTmp); - blit(fn->retr, 0, r, cr.t->size, fn); + blit0(fn->retr, r, cr.t->size, fn); } else { ldregs(cr.reg, cr.cls, cr.nreg, r, fn); } @@ -383,7 +383,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) emit(Ocast, k, TMP(*c->reg), i->arg[0], R); } if (c->class & Cptr) - blit(i->arg[0], 0, i->arg[1], c->t->size, fn); + blit0(i->arg[0], i->arg[1], c->t->size, fn); } if (!stk) @@ -419,7 +419,7 @@ selcall(Fn *fn, Ins *i0, Ins *i1, Insl **ilp) } emit(Oadd, Kl, r1, r, getcon(off, fn)); } else - blit(r, off, i->arg[1], c->t->size, fn); + blit(r, off, i->arg[1], 0, c->t->size, fn); off += c->size; } emit(Osalloc, Kl, r, getcon(stk, fn), R); diff --git a/util.c b/util.c @@ -399,7 +399,7 @@ addcon(Con *c0, Con *c1) } void -blit(Ref rdst, uint doff, Ref rsrc, uint sz, Fn *fn) +blit(Ref rdst, uint doff, Ref rsrc, uint boff, uint sz, Fn *fn) { struct { int st, ld, cls, size; } *p, tbl[] = { { Ostorel, Oload, Kl, 8 }, @@ -408,9 +408,9 @@ blit(Ref rdst, uint doff, Ref rsrc, uint sz, Fn *fn) { Ostoreb, Oloadub, Kw, 1 } }; Ref r, r1; - uint boff, s; + uint s; - for (boff=0, p=tbl; sz; p++) + for (p=tbl; sz; p++) for (s=p->size; sz>=s; sz-=s, doff+=s, boff+=s) { r = newtmp("blt", Kl, fn); r1 = newtmp("blt", Kl, fn); @@ -423,6 +423,12 @@ blit(Ref rdst, uint doff, Ref rsrc, uint sz, Fn *fn) } void +blit0(Ref rdst, Ref rsrc, uint sz, Fn *fn) +{ + blit(rdst, 0, rsrc, 0, sz, fn); +} + +void bsinit(BSet *bs, uint n) { n = (n + NBit-1) / NBit;