cranelift: Add support for bswap.i128 (#5186)

* fuzzgen: Request only one variable for bswap

This was included by accident. Bswap only has one input, instead of two.

* cranelift: Add `bswap.i128` support

Adds support only for x86, AArch64, S390X.

RISCV does not yet have bswap.
This commit is contained in:
Afonso Bordado
2022-11-03 18:03:37 +00:00
committed by GitHub
parent 22159848c5
commit 2c69b94744
5 changed files with 21 additions and 16 deletions

View File

@@ -1528,6 +1528,11 @@
(rule (lower (has_type $I64 (bswap x)))
(a64_rev64 $I64 x))
(rule (lower (has_type $I128 (bswap x)))
(value_regs
(a64_rev64 $I64 (value_regs_get x 1))
(a64_rev64 $I64 (value_regs_get x 0))))
;;;; Rules for `bmask` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Bmask tests the value against zero, and uses `csetm` to assert the result.

View File

@@ -1190,15 +1190,8 @@
;;;; Rules for `bswap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (has_type $I16 (bswap x)))
(lshr_imm $I32 (bswap_reg $I32 x) 16))
(rule (lower (has_type $I32 (bswap x)))
(bswap_reg $I32 x))
(rule (lower (has_type $I64 (bswap x)))
(bswap_reg $I64 x))
(rule (lower (has_type ty (bswap x)))
(bitrev_bytes ty x))
;;;; Rules for `clz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View File

@@ -2060,6 +2060,11 @@
(rule (lower (has_type $I64 (bswap src)))
(x64_bswap $I64 src))
(rule (lower (has_type $I128 (bswap src)))
(value_regs
(x64_bswap $I64 (value_regs_get_gpr src 1))
(x64_bswap $I64 (value_regs_get_gpr src 0))))
;; Rules for `is_null` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Null references are represented by the constant value `0`.