Skip to content

Commit

Permalink
Add nop instruction to Winch (#6449)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffcharles authored May 24, 2023
1 parent 797e769 commit 5a6ea32
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions fuzz/fuzz_targets/differential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ fn winch_supports_module(module: &[u8]) -> bool {
| LocalGet { .. }
| LocalSet { .. }
| Call { .. }
| Nop { .. }
| End { .. } => {}
_ => {
supported = false;
Expand Down
3 changes: 3 additions & 0 deletions winch/codegen/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ macro_rules! def_unsupported {
(emit LocalSet $($rest:tt)*) => {};
(emit Call $($rest:tt)*) => {};
(emit End $($rest:tt)*) => {};
(emit Nop $($rest:tt)*) => {};

(emit $unsupported:tt $($rest:tt)*) => {$($rest)*};
}
Expand Down Expand Up @@ -203,6 +204,8 @@ where
self.emit_call(FuncIndex::from_u32(index));
}

fn visit_nop(&mut self) {}

wasmparser::for_each_operator!(def_unsupported);
}

Expand Down
17 changes: 17 additions & 0 deletions winch/filetests/filetests/aarch64/nop/nop.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
;;! target = "aarch64"

(module
(func
nop
)
)
;; 0: fd7bbfa9 stp x29, x30, [sp, #-0x10]!
;; 4: fd030091 mov x29, sp
;; 8: fc030091 mov x28, sp
;; c: ff2300d1 sub sp, sp, #8
;; 10: fc030091 mov x28, sp
;; 14: 890300f8 stur x9, [x28]
;; 18: ff230091 add sp, sp, #8
;; 1c: fc030091 mov x28, sp
;; 20: fd7bc1a8 ldp x29, x30, [sp], #0x10
;; 24: c0035fd6 ret
15 changes: 15 additions & 0 deletions winch/filetests/filetests/x64/nop/nop.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
;;! target = "x86_64"

(module
(func
nop
)
)

;; 0: 55 push rbp
;; 1: 4889e5 mov rbp, rsp
;; 4: 4883ec08 sub rsp, 8
;; 8: 4c893424 mov qword ptr [rsp], r14
;; c: 4883c408 add rsp, 8
;; 10: 5d pop rbp
;; 11: c3 ret

0 comments on commit 5a6ea32

Please sign in to comment.