ISLE rule cleanups (#5389)
* cranelift-codegen: Use ISLE matching, not same_value The `same_value` function just wrapped an equality test into an external constructor, but we can do that with ISLE's equality constraints instead. * riscv64: Remove custom condition-code tests The `lower_icmp` term exists solely to decide whether to sign-extend or zero-extend the comparison operands, based on whether the condition code requires a signed comparison. It additionally tested whether the condition code was == or !=, but produced the same result as for other unsigned comparisons. We already have `signed_cond_code` in the ISLE prelude, which classifies the total-ordering condition codes according to whether they're signed. It also lumps == and != in the "unsigned" camp, as desired. So this commit uses the existing method from the prelude instead of riscv64-local definitions. Because this version has no constraints on the left-hand side of the rule in the unsigned case, ISLE generates Rust that always returns `Some`. That shows that the current use of `unwrap` is justified, at the only Rust-side call-site of `constructor_lower_icmp`, which is in cranelift/codegen/src/isa/riscv64/lower/isle.rs. * ISLE prelude: make offset32 infallible This extractor always returns `Some`, so it doesn't need to be fallible.
This commit is contained in:
@@ -1766,29 +1766,13 @@
|
||||
(value_regs_get x 0))
|
||||
(convert ValueRegs Reg convert_valueregs_reg)
|
||||
|
||||
;;; intcc is not equal nor ne.
|
||||
;;; intcc is >= <= ...
|
||||
;;; return alongside with if signed.
|
||||
(decl intcc_is_gt_etc (IntCC bool) IntCC)
|
||||
(extern extractor intcc_is_gt_etc intcc_is_gt_etc)
|
||||
|
||||
(decl intcc_is_eq_or_ne (IntCC) IntCC)
|
||||
(extern extractor intcc_is_eq_or_ne intcc_is_eq_or_ne)
|
||||
|
||||
;;; lower icmp
|
||||
(decl lower_icmp (IntCC ValueRegs ValueRegs Type) Reg)
|
||||
;;; eq or ne.
|
||||
(rule -1
|
||||
(lower_icmp (intcc_is_eq_or_ne cc) x y ty)
|
||||
(gen_icmp cc (ext_int_if_need $false x ty) (ext_int_if_need $false y ty) ty))
|
||||
;;;; singed >= ...
|
||||
(rule
|
||||
(lower_icmp (intcc_is_gt_etc cc $true) x y ty)
|
||||
(rule 1 (lower_icmp cc x y ty)
|
||||
(if (signed_cond_code cc))
|
||||
(gen_icmp cc (ext_int_if_need $true x ty) (ext_int_if_need $true y ty) ty))
|
||||
;;;; unsigned >= ...
|
||||
(rule
|
||||
(lower_icmp (intcc_is_gt_etc cc $false) x y ty)
|
||||
(gen_icmp cc (ext_int_if_need $false x ty ) (ext_int_if_need $false y ty) ty))
|
||||
(rule (lower_icmp cc x y ty)
|
||||
(gen_icmp cc (ext_int_if_need $false x ty) (ext_int_if_need $false y ty) ty))
|
||||
|
||||
(decl lower_icmp_over_flow (ValueRegs ValueRegs Type) Reg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user