Browse Source

A couple small Winch cleanups (#6526)

* Winch: remove tabs, use spaces

* Winch: remove unnecessary mutable references
pull/6533/head
Nick Fitzgerald 1 year ago
committed by GitHub
parent
commit
81cd998350
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      winch/codegen/src/codegen/context.rs
  2. 69
      winch/codegen/src/visitor.rs

4
winch/codegen/src/codegen/context.rs

@ -136,7 +136,7 @@ impl<'a> CodeGenContext<'a> {
} }
/// Prepares arguments for emitting an i32 binary operation. /// Prepares arguments for emitting an i32 binary operation.
pub fn i32_binop<F, M>(&mut self, masm: &mut M, emit: &mut F) pub fn i32_binop<F, M>(&mut self, masm: &mut M, mut emit: F)
where where
F: FnMut(&mut M, RegImm, RegImm, OperandSize), F: FnMut(&mut M, RegImm, RegImm, OperandSize),
M: MacroAssembler, M: MacroAssembler,
@ -166,7 +166,7 @@ impl<'a> CodeGenContext<'a> {
} }
/// Prepares arguments for emitting an i64 binary operation. /// Prepares arguments for emitting an i64 binary operation.
pub fn i64_binop<F, M>(&mut self, masm: &mut M, emit: &mut F) pub fn i64_binop<F, M>(&mut self, masm: &mut M, mut emit: F)
where where
F: FnMut(&mut M, RegImm, RegImm, OperandSize), F: FnMut(&mut M, RegImm, RegImm, OperandSize),
M: MacroAssembler, M: MacroAssembler,

69
winch/codegen/src/visitor.rs

@ -19,15 +19,15 @@ use wasmtime_environ::{FuncIndex, WasmType};
macro_rules! def_unsupported { macro_rules! def_unsupported {
($( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => { ($( @$proposal:ident $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident)*) => {
$( $(
def_unsupported!( def_unsupported!(
emit emit
$op $op
fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output { fn $visit(&mut self $($(,$arg: $argty)*)?) -> Self::Output {
$($(let _ = $arg;)*)? $($(let _ = $arg;)*)?
todo!(stringify!($op)) todo!(stringify!($op))
} }
); );
)* )*
}; };
@ -93,45 +93,39 @@ where
} }
fn visit_i32_add(&mut self) { fn visit_i32_add(&mut self) {
self.context self.context.i32_binop(self.masm, |masm, dst, src, size| {
.i32_binop(self.masm, &mut |masm, dst, src, size| { masm.add(dst, dst, src, size);
masm.add(dst, dst, src, size); });
});
} }
fn visit_i64_add(&mut self) { fn visit_i64_add(&mut self) {
self.context self.context.i64_binop(self.masm, |masm, dst, src, size| {
.i64_binop(self.masm, &mut |masm, dst, src, size| { masm.add(dst, dst, src, size);
masm.add(dst, dst, src, size); });
});
} }
fn visit_i32_sub(&mut self) { fn visit_i32_sub(&mut self) {
self.context self.context.i32_binop(self.masm, |masm, dst, src, size| {
.i32_binop(self.masm, &mut |masm, dst, src, size| { masm.sub(dst, dst, src, size);
masm.sub(dst, dst, src, size); });
});
} }
fn visit_i64_sub(&mut self) { fn visit_i64_sub(&mut self) {
self.context self.context.i64_binop(self.masm, |masm, dst, src, size| {
.i64_binop(self.masm, &mut |masm, dst, src, size| { masm.sub(dst, dst, src, size);
masm.sub(dst, dst, src, size); });
});
} }
fn visit_i32_mul(&mut self) { fn visit_i32_mul(&mut self) {
self.context self.context.i32_binop(self.masm, |masm, dst, src, size| {
.i32_binop(self.masm, &mut |masm, dst, src, size| { masm.mul(dst, dst, src, size);
masm.mul(dst, dst, src, size); });
});
} }
fn visit_i64_mul(&mut self) { fn visit_i64_mul(&mut self) {
self.context self.context.i64_binop(self.masm, |masm, dst, src, size| {
.i64_binop(self.masm, &mut |masm, dst, src, size| { masm.mul(dst, dst, src, size);
masm.mul(dst, dst, src, size); });
});
} }
fn visit_i32_div_s(&mut self) { fn visit_i32_div_s(&mut self) {
@ -328,15 +322,14 @@ where
M: MacroAssembler, M: MacroAssembler,
{ {
fn cmp_i32s(&mut self, kind: CmpKind) { fn cmp_i32s(&mut self, kind: CmpKind) {
self.context self.context.i32_binop(self.masm, |masm, dst, src, size| {
.i32_binop(self.masm, &mut |masm, dst, src, size| { masm.cmp_with_set(src, dst, kind, size);
masm.cmp_with_set(src, dst, kind, size); });
});
} }
fn cmp_i64s(&mut self, kind: CmpKind) { fn cmp_i64s(&mut self, kind: CmpKind) {
self.context self.context
.i64_binop(self.masm, &mut move |masm, dst, src, size| { .i64_binop(self.masm, move |masm, dst, src, size| {
masm.cmp_with_set(src, dst, kind, size); masm.cmp_with_set(src, dst, kind, size);
}); });
} }

Loading…
Cancel
Save