Skip to content

Commit

Permalink
test: temporarily translate unsupported call_indirect, ctz, clz
Browse files Browse the repository at this point in the history
to get dlmalloc code translation further.
  • Loading branch information
greenhat committed Sep 18, 2023
1 parent 4a9e303 commit 633fc04
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 14 additions & 0 deletions frontend-wasm/src/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ pub fn translate_operator(
Operator::Call { function_index } => {
translate_call(state, builder, function_index, mod_info, span, diagnostics)?;
}
Operator::CallIndirect {
type_index: _,
table_index: _,
table_byte: _,
} => {
builder.ins().unreachable(span);
state.reachable = false;
}
/******************************* Memory management *********************************/
Operator::MemoryGrow { .. } => {
// Do nothing and return total Miden memory size
Expand Down Expand Up @@ -196,6 +204,12 @@ pub fn translate_operator(
let val = state.pop1();
state.push1(builder.ins().trunc(val, I32, span));
}
Operator::I32Clz | Operator::I32Ctz => {
let val = state.pop1();
// Using popcnt (same sig as ctz/clz) to get dlmalloc code processed further
// TODO: use proper instructions when available
state.push1(builder.ins().popcnt(val, span));
}
/****************************** Binary Operators ************************************/
Operator::I32Add | Operator::I64Add => {
let (arg1, arg2) = state.pop2();
Expand Down
14 changes: 7 additions & 7 deletions frontend-wasm/src/code_translator/tests_unsupported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ fn check_unsupported(op: &Operator) {

// Wasm Spec v1.0
const UNSUPPORTED_WASM_V1_OPS: &[Operator] = &[
CallIndirect {
type_index: 0,
table_index: 0,
table_byte: 0,
},
// CallIndirect {
// type_index: 0,
// table_index: 0,
// table_byte: 0,
// },
/****************************** Memory Operators ************************************/
F32Load {
memarg: MemArg {
Expand All @@ -89,8 +89,8 @@ const UNSUPPORTED_WASM_V1_OPS: &[Operator] = &[
// },

/****************************** Unary Operators ************************************/
I32Ctz,
I32Clz,
// I32Ctz,
// I32Clz,
I64Ctz,
I64Clz,
F32Sqrt,
Expand Down

0 comments on commit 633fc04

Please sign in to comment.