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.
pulley: Support big-endian targets (bytecodealliance#9759)
* pulley: Support big-endian targets This commit fixes the Pulley interpreter and Cranelift backend to properly support big-endian targets. The problem beforehand was that loads/stores in Pulley were defined as the native endianness which means that big and little-endian platforms differed. Additionally the previously set of understood pulley targets were implicitly always little-endian which was not appropriate for a big-endian host where JIT data structures are stored in big-endian format. This commit fixes all of these issues with a few changes: * Pulley loads/stores are always little-endian now. * Pulley now has bswap32/bswap64 instructions. * Wasmtime/Cranelift now understand big-endian pulley targets (e.g. `pulley32be`). * CLIF translation of loads/stores now properly handles the endianness flags on `MemFlags`. In the future if necessary we could natively add a macro-op for big-endian loads/stores to Pulley but for now it's more minimal to just have `bswap32` and `bswap64`. The result of this commit is that Pulley tests are now run and executed on s390x like all other platforms. * Fix fuzz build * Review comments * Fix fuzz build
- Loading branch information
1 parent
019078a
commit 0a894cb
Showing
24 changed files
with
413 additions
and
160 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,71 @@ | ||
test compile precise-output | ||
target pulley64 big_endian | ||
|
||
function %load_i32(i64) -> i32 { | ||
block0(v0: i64): | ||
v1 = load.i32 v0 | ||
return v1 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; x2 = load32_u x0+0 // flags = | ||
; bswap32 x0, x2 | ||
; ret | ||
; | ||
; Disassembled: | ||
; load32_u x2, x0 | ||
; bswap32 x0, x2 | ||
; ret | ||
|
||
function %load_i64(i64) -> i64 { | ||
block0(v0: i64): | ||
v1 = load.i64 v0 | ||
return v1 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; x2 = load64_u x0+0 // flags = | ||
; bswap64 x0, x2 | ||
; ret | ||
; | ||
; Disassembled: | ||
; load64 x2, x0 | ||
; bswap64 x0, x2 | ||
; ret | ||
|
||
function %load_i32_with_offset(i64) -> i32 { | ||
block0(v0: i64): | ||
v1 = load.i32 v0+4 | ||
return v1 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; x2 = load32_u x0+4 // flags = | ||
; bswap32 x0, x2 | ||
; ret | ||
; | ||
; Disassembled: | ||
; load32_u_offset8 x2, x0, 4 | ||
; bswap32 x0, x2 | ||
; ret | ||
|
||
function %load_i64_with_offset(i64) -> i64 { | ||
block0(v0: i64): | ||
v1 = load.i64 v0+8 | ||
return v1 | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; x2 = load64_u x0+8 // flags = | ||
; bswap64 x0, x2 | ||
; ret | ||
; | ||
; Disassembled: | ||
; load64_offset8 x2, x0, 8 | ||
; bswap64 x0, x2 | ||
; ret | ||
|
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,71 @@ | ||
test compile precise-output | ||
target pulley64 big_endian | ||
|
||
function %store_i32(i32, i64) { | ||
block0(v0: i32, v1: i64): | ||
store v0, v1 | ||
return | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; bswap32 x3, x0 | ||
; store32 x1+0, x3 // flags = | ||
; ret | ||
; | ||
; Disassembled: | ||
; bswap32 x3, x0 | ||
; store32 x1, x3 | ||
; ret | ||
|
||
function %store_i64(i64, i64) { | ||
block0(v0: i64, v1: i64): | ||
store v0, v1 | ||
return | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; bswap64 x3, x0 | ||
; store64 x1+0, x3 // flags = | ||
; ret | ||
; | ||
; Disassembled: | ||
; bswap64 x3, x0 | ||
; store64 x1, x3 | ||
; ret | ||
|
||
function %store_i32_with_offset(i32, i64) { | ||
block0(v0: i32, v1: i64): | ||
store v0, v1+4 | ||
return | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; bswap32 x3, x0 | ||
; store32 x1+4, x3 // flags = | ||
; ret | ||
; | ||
; Disassembled: | ||
; bswap32 x3, x0 | ||
; store32_offset8 x1, 4, x3 | ||
; ret | ||
|
||
function %store_i64_with_offset(i64, i64) { | ||
block0(v0: i64, v1: i64): | ||
store v0, v1+8 | ||
return | ||
} | ||
|
||
; VCode: | ||
; block0: | ||
; bswap64 x3, x0 | ||
; store64 x1+8, x3 // flags = | ||
; ret | ||
; | ||
; Disassembled: | ||
; bswap64 x3, x0 | ||
; store64_offset8 x1, 8, x3 | ||
; ret | ||
|
Oops, something went wrong.