forked from bytecodealliance/wasmtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the wide-arithmetic proposal
This commit implements the [wide-arithmetic] proposal in Wasmtime. This is a pretty easy proposal to implement due to Cranelift already having support for all the various instructions. The features implemented here are: * Cranelift support for the four new instructions. * A new `Config::wasm_wide_arithmetic` option. * A new `-Wwide-arithmetic` CLI flag. * A new `wasmtime_config_wasm_wide_arithmetic_set` C API function. * Support for fuzzing this proposal * Generation is implemented in `wasm-smith` . * While it's off-by-default in `wasm-smith` it's enabled-by-default here. * Differential execution is only possible against Wasmtime right now. * Single-instruction module support was added for these new instructions. * Tests for some simple cases plus randomly-generated tests. * Example disassemblies for new instructions on Cranelift architectures. [wide-arithmetic]: https://github.com/WebAssembly/wide-arithmetic
- Loading branch information
1 parent
d51a921
commit 51e8a10
Showing
18 changed files
with
884 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
;;! target = "aarch64" | ||
;;! test = "compile" | ||
;;! flags = "-Wwide-arithmetic" | ||
|
||
(module | ||
(func $add128 (param i64 i64 i64 i64) (result i64 i64) | ||
local.get 0 | ||
local.get 1 | ||
local.get 2 | ||
local.get 3 | ||
i64.add128) | ||
|
||
(func $sub128 (param i64 i64 i64 i64) (result i64 i64) | ||
local.get 0 | ||
local.get 1 | ||
local.get 2 | ||
local.get 3 | ||
i64.sub128) | ||
|
||
(func $signed (param i64 i64) (result i64 i64) | ||
local.get 0 | ||
local.get 1 | ||
i64.mul_wide_s) | ||
|
||
(func $unsigned (param i64 i64) (result i64 i64) | ||
local.get 0 | ||
local.get 1 | ||
i64.mul_wide_u) | ||
|
||
(func $signed_only_high (param i64 i64) (result i64) | ||
local.get 0 | ||
local.get 1 | ||
i64.mul_wide_s | ||
local.set 0 | ||
drop | ||
local.get 0) | ||
|
||
(func $unsigned_only_high (param i64 i64) (result i64) | ||
local.get 0 | ||
local.get 1 | ||
i64.mul_wide_u | ||
local.set 0 | ||
drop | ||
local.get 0) | ||
) | ||
|
||
;; wasm[0]::function[0]::add128: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; adds x2, x4, x6 | ||
;; adc x3, x5, x7 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret | ||
;; | ||
;; wasm[0]::function[1]::sub128: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; subs x2, x4, x6 | ||
;; sbc x3, x5, x7 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret | ||
;; | ||
;; wasm[0]::function[2]::signed: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; mul x2, x4, x5 | ||
;; smulh x3, x4, x5 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret | ||
;; | ||
;; wasm[0]::function[3]::unsigned: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; mul x2, x4, x5 | ||
;; umulh x3, x4, x5 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret | ||
;; | ||
;; wasm[0]::function[4]::signed_only_high: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; smulh x2, x4, x5 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret | ||
;; | ||
;; wasm[0]::function[5]::unsigned_only_high: | ||
;; stp x29, x30, [sp, #-0x10]! | ||
;; mov x29, sp | ||
;; umulh x2, x4, x5 | ||
;; ldp x29, x30, [sp], #0x10 | ||
;; ret |
Oops, something went wrong.