Skip to content

Commit

Permalink
pulley: Fill out bnot lowering
Browse files Browse the repository at this point in the history
Gets some `embenchen_*.wast` tests passing.

cc bytecodealliance#9783
  • Loading branch information
alexcrichton committed Dec 13, 2024
1 parent 51ea980 commit 2007ec8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
8 changes: 8 additions & 0 deletions cranelift/codegen/src/isa/pulley_shared/lower.isle
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
4 changes: 0 additions & 4 deletions crates/wast-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions pulley/src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,6 +1802,18 @@ impl OpVisitor for Interpreter<'_> {
ControlFlow::Continue(())
}

fn xbnot32(&mut self, dst: XReg, src: XReg) -> ControlFlow<Done> {
let a = self.state[src].get_u32();
self.state[dst].set_u32(!a);
ControlFlow::Continue(())
}

fn xbnot64(&mut self, dst: XReg, src: XReg) -> ControlFlow<Done> {
let a = self.state[src].get_u64();
self.state[dst].set_u64(!a);
ControlFlow::Continue(())
}

fn fconst32(&mut self, dst: FReg, bits: u32) -> ControlFlow<Done> {
self.state[dst].set_f32(f32::from_bits(bits));
ControlFlow::Continue(())
Expand Down
5 changes: 5 additions & 0 deletions pulley/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,11 @@ macro_rules! for_each_op {
/// `dst = src1 ^ src2`
xbxor64 = XBxor64 { operands: BinaryOperands<XReg> };

/// `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`
Expand Down

0 comments on commit 2007ec8

Please sign in to comment.