Skip to content

Commit a9c19f2

Browse files
committed
initial i64.extend_i32_u translation
We can go 2 ways from here: either encode a copy for local inputs; OR allow to overwrite local operand types, ignoring the type of the local. The first solution is inefficient, the second hacky. Maybe there is a third option?
1 parent 85b0e75 commit a9c19f2

File tree

1 file changed

+18
-2
lines changed
  • crates/wasmi/src/engine/translator/func2

1 file changed

+18
-2
lines changed

crates/wasmi/src/engine/translator/func2/visit.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{ControlFrame, ControlFrameKind, FuncTranslator, LocalIdx};
22
use crate::{
3-
core::{wasm, TrapCode, F32, F64},
3+
core::{wasm, TrapCode, F32, F64, ValType},
44
engine::{
55
translator::func2::{
66
stack::{AcquiredTarget, IfReachability},
@@ -1093,7 +1093,23 @@ impl<'a> VisitOperator<'a> for FuncTranslator {
10931093
}
10941094

10951095
fn visit_i64_extend_i32_u(&mut self) -> Self::Output {
1096-
todo!()
1096+
bail_unreachable!(self);
1097+
// Note: this Wasm operation is a no-op, we only have to change the types on the stack.
1098+
match self.stack.pop() {
1099+
Operand::Local(input) => {
1100+
debug_assert!(matches!(input.ty(), ValType::I32));
1101+
todo!() // do we need a copy or should we allow to manipulate a local's type?
1102+
}
1103+
Operand::Temp(input) => {
1104+
debug_assert!(matches!(input.ty(), ValType::I32));
1105+
self.stack.push_temp(ValType::I64, None)?;
1106+
}
1107+
Operand::Immediate(input) => {
1108+
let input = u32::from(input.val());
1109+
self.stack.push_immediate(u64::from(input))?;
1110+
}
1111+
}
1112+
Ok(())
10971113
}
10981114

10991115
fn visit_i64_trunc_f32_s(&mut self) -> Self::Output {

0 commit comments

Comments
 (0)