ABI: implement register arguments with constraints. (#4858)

* ABI: implement register arguments with constraints.

Currently, Cranelift's ABI code emits a sequence of moves from physical
registers into vregs at the top of the function body, one for every
register-carried argument.

For a number of reasons, we want to move to operand constraints instead,
and remove the use of explicitly-named "pinned vregs"; this allows for
better regalloc in theory, as it removes the need to "reverse-engineer"
the sequence of moves.

This PR alters the ABI code so that it generates a single "args"
pseudo-instruction as the first instruction in the function body. This
pseudo-inst defs all register arguments, and constrains them to the
appropriate registers at the def-point. Subsequently the regalloc can
move them wherever it needs to.

Some care was taken not to have this pseudo-inst show up in
post-regalloc disassemblies, but the change did cause a general regalloc
"shift" in many tests, so the precise-output updates are a bit noisy.
Sorry about that!

A subsequent PR will handle the other half of the ABI code, namely, the
callsite case, with a similar preg-to-constraint conversion.

* Update based on review feedback.

* Review feedback.
This commit is contained in:
Chris Fallin
2022-09-08 20:03:14 -05:00
committed by GitHub
parent 13c7846815
commit 2986f6b0ff
101 changed files with 2688 additions and 2441 deletions

View File

@@ -11,8 +11,8 @@ block0(v0: i8, v1: i64, v2: i64):
}
; block0:
; uxtb w8, w0
; subs wzr, w8, #42
; uxtb w6, w0
; subs wzr, w6, #42
; csel x0, x1, x2, eq
; ret
@@ -37,9 +37,9 @@ block0(v0: i8, v1: i8, v2: i8):
}
; block0:
; and w7, w1, w0
; bic w9, w2, w0
; orr w0, w7, w9
; and w5, w1, w0
; bic w7, w2, w0
; orr w0, w5, w7
; ret
function %i(b1, i8, i8) -> i8 {
@@ -49,8 +49,8 @@ block0(v0: b1, v1: i8, v2: i8):
}
; block0:
; and w8, w0, #1
; subs wzr, w8, wzr
; and w6, w0, #1
; subs wzr, w6, wzr
; csel x0, x1, x2, ne
; ret
@@ -74,8 +74,8 @@ block0(v0: b1, v1: i128, v2: i128):
}
; block0:
; and w14, w0, #1
; subs wzr, w14, wzr
; and w10, w0, #1
; subs wzr, w10, wzr
; csel x0, x2, x4, ne
; csel x1, x3, x5, ne
; ret