cranelift: Implement ineg.i128 for everyone (#5129)

* cranelift: Add `ineg` runtests

* aarch64: Implement `ineg.i128`

* x64: Implement `ineg.i128`

* riscv: Implement `ineg.i128`

* fuzzgen: Enable `ineg.i128`
This commit is contained in:
Afonso Bordado
2022-10-29 00:10:00 +01:00
committed by GitHub
parent 81f7ef7fbe
commit 879b52825f
9 changed files with 127 additions and 20 deletions

View File

@@ -2917,6 +2917,14 @@
(size OperandSize (operand_size_of_type_32_64 ty))
(_ Unit (emit (MInst.Neg size src dst))))
dst))
;; Helper for creating `neg` instructions whose flags are also used.
(decl x64_neg_paired (Type Gpr) ProducesFlags)
(rule (x64_neg_paired ty src)
(let ((dst WritableGpr (temp_writable_gpr))
(size OperandSize (operand_size_of_type_32_64 ty))
(inst MInst (MInst.Neg size src dst)))
(ProducesFlags.ProducesFlagsReturnsResultWithConsumer inst dst)))
(decl x64_lea (SyntheticAmode) Gpr)
(rule (x64_lea addr)

View File

@@ -777,6 +777,15 @@
(rule -1 (lower (has_type (fits_in_64 ty) (ineg x)))
(x64_neg ty x))
(rule -2 (lower (has_type $I128 (ineg x)))
;; Get the high/low registers for `x`.
(let ((regs ValueRegs x)
(lo Gpr (value_regs_get_gpr regs 0))
(hi Gpr (value_regs_get_gpr regs 1)))
;; Do a neg followed by an sub-with-borrow.
(with_flags (x64_neg_paired $I64 lo)
(x64_sbb_paired $I64 (imm $I64 0) hi))))
;; SSE.
(rule (lower (has_type $I8X16 (ineg x)))