11 Commits

Author SHA1 Message Date
33208a2356 update 2026-03-06 20:14:02 +00:00
Michael McLoughlin
c32f24fb1e pass: de-prioritize base pointer in register allocation (#184)
Updates #156
2021-04-18 19:22:09 -07:00
Michael McLoughlin
f295bde84c pass: ensure frame pointer register is saved (#174)
Currently `avo` uses `BP` as a standard general-purpose register. However, `BP` is used for the frame pointer and should be callee-save. Under some circumstances, the Go assembler will do this automatically, but not always. At the moment `avo` can produce code that clobbers the `BP` register. Since Go 1.16 this code will also fail a new `go vet` check.

This PR provides a (currently sub-optimal) fix for the issue. It introduces an `EnsureBasePointerCalleeSaved` pass which will check if the base pointer is written to by a function, and if so will artificially ensure that the function has a non-zero frame size. This will trigger the Go assembler to automatically save and restore the BP register.

In addition, we update the `asmdecl` tool to `asmvet`, which includes the `framepointer` vet check.

Updates #156
2021-04-18 18:37:56 -07:00
Michael McLoughlin
f40d602170 reg,pass: refactor allocation of aliased registers (#121)
Issue #100 demonstrated that register allocation for aliased registers is
fundamentally broken. The root of the issue is that currently accesses to the
same virtual register with different masks are treated as different registers.
This PR takes a different approach:

* Liveness analysis is masked: we now properly consider which parts of a register are live
* Register allocation produces a mapping from virtual to physical ID, and aliasing is applied later

In addition, a new pass ZeroExtend32BitOutputs accounts for the fact that 32-bit writes in 64-bit mode should actually be treated as 64-bit writes (the result is zero-extended).

Closes #100
2020-01-22 22:50:40 -08:00
Michael McLoughlin
0f63e0906d ast: move "ast" types from root to ir sub-package
Closes #32
2019-01-06 14:21:10 -08:00
Michael McLoughlin
816cf06a08 pass: doc exported symbols (#9) 2019-01-04 20:00:22 -08:00
Michael McLoughlin
b3644ec7fc pass: tweak ordering in liveness analysis
Previously we updated the set of live in registers before live out. This
was extremely inefficient, since on each pass through live in depends on
live out.

We also change to processing the instructions in reverse order, which is
more likely to be efficient, although we should replace this with
topological sort order soon.
2018-12-24 12:48:29 -08:00
Michael McLoughlin
b89d211ff4 examples/complex: and bugfixes 2018-12-12 00:02:22 -08:00
Michael McLoughlin
022cbb7792 pass: first attempt at register allocation 2018-12-05 00:05:57 -08:00
Michael McLoughlin
9376a230cf refactor to use reg.Set 2018-12-03 22:39:43 -08:00
Michael McLoughlin
b52c67f3fb pass: naive implementation of liveness 2018-12-02 23:59:29 -08:00