From 2007ec8da62245553c770b18b591d14430e17218 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 11 Dec 2024 12:15:36 -0800 Subject: [PATCH] pulley: Fill out `bnot` lowering Gets some `embenchen_*.wast` tests passing. cc #9783 --- cranelift/codegen/src/isa/pulley_shared/lower.isle | 8 ++++++++ crates/wast-util/src/lib.rs | 4 ---- pulley/src/interp.rs | 12 ++++++++++++ pulley/src/lib.rs | 5 +++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/cranelift/codegen/src/isa/pulley_shared/lower.isle b/cranelift/codegen/src/isa/pulley_shared/lower.isle index 41d93ad7fc7f..57ff450fafc6 100644 --- a/cranelift/codegen/src/isa/pulley_shared/lower.isle +++ b/cranelift/codegen/src/isa/pulley_shared/lower.isle @@ -232,6 +232,14 @@ (rule 1 (lower (has_type $I64 (bxor a b))) (pulley_xbxor64 a b)) +;;;; Rules for `bnot` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule 0 (lower (has_type (fits_in_32 _) (bnot a))) + (pulley_xbnot32 a)) + +(rule 1 (lower (has_type $I64 (bnot a))) + (pulley_xbnot64 a)) + ;;;; Rules for `ctz` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $I32 (ctz a))) (pulley_xctz32 a)) diff --git a/crates/wast-util/src/lib.rs b/crates/wast-util/src/lib.rs index 0db9b41fb500..321154f92fd9 100644 --- a/crates/wast-util/src/lib.rs +++ b/crates/wast-util/src/lib.rs @@ -395,10 +395,6 @@ impl WastTest { // features in Pulley are implemented. if config.compiler == Compiler::CraneliftPulley { let unsupported = [ - "misc_testsuite/embenchen_fannkuch.wast", - "misc_testsuite/embenchen_fasta.wast", - "misc_testsuite/embenchen_ifs.wast", - "misc_testsuite/embenchen_primes.wast", "misc_testsuite/int-to-float-splat.wast", "misc_testsuite/issue6562.wast", "misc_testsuite/memory-combos.wast", diff --git a/pulley/src/interp.rs b/pulley/src/interp.rs index 861e176dd41c..7ce53e8837aa 100644 --- a/pulley/src/interp.rs +++ b/pulley/src/interp.rs @@ -1802,6 +1802,18 @@ impl OpVisitor for Interpreter<'_> { ControlFlow::Continue(()) } + fn xbnot32(&mut self, dst: XReg, src: XReg) -> ControlFlow { + let a = self.state[src].get_u32(); + self.state[dst].set_u32(!a); + ControlFlow::Continue(()) + } + + fn xbnot64(&mut self, dst: XReg, src: XReg) -> ControlFlow { + let a = self.state[src].get_u64(); + self.state[dst].set_u64(!a); + ControlFlow::Continue(()) + } + fn fconst32(&mut self, dst: FReg, bits: u32) -> ControlFlow { self.state[dst].set_f32(f32::from_bits(bits)); ControlFlow::Continue(()) diff --git a/pulley/src/lib.rs b/pulley/src/lib.rs index 534e8ef14585..69b50176743d 100644 --- a/pulley/src/lib.rs +++ b/pulley/src/lib.rs @@ -396,6 +396,11 @@ macro_rules! for_each_op { /// `dst = src1 ^ src2` xbxor64 = XBxor64 { operands: BinaryOperands }; + /// `low32(dst) = !low32(src1)` + xbnot32 = XBnot32 { dst: XReg, src: XReg }; + /// `dst = !src1` + xbnot64 = XBnot64 { dst: XReg, src: XReg }; + /// `low32(dst) = bits` fconst32 = FConst32 { dst: FReg, bits: u32 }; /// `dst = bits`