Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: amd64 addressing modes are unwieldy #36468
There are many amd64 instructions that accept a full range of memory addressing modes. It would be nice to make use of them all.
The current approach is to give each its own op, such as
Such additions have steady incremental improvements in generated code, at the cost of developer time, reviewer time, compiler binary size, and time and memory required to build the compiler (which has proved to be an ongoing problem).
I wonder whether we can find a way to factor out some of this commonality, so we can hoover up all the incremental improvements at much less cost.
One idea is to encode the scale into AuxInt, so we'd have just
Another (vague) idea is to have a separate handwritten pass after lower that does nothing but addressing modes. We'd mark ops with what kind of address modes they support in which argument slots and then do all combining then. We'd still have a combinatorial number of ops, but many fewer rules.
This is actually an instance of a broader amd64 problem around having a combinatorial number of ops (base X const? X load/store/modify X addressingmode). Maybe if we structured this all appropriately, we could generate (rather than hand code) all the ops and their encodings in amd64/ssa.go and their generated rules (like we did for commutativity).
For discussion and ideas.