Support big- and little-endian lane order with bitcast (#5196)

Add a MemFlags operand to the bitcast instruction, where only the
`big` and `little` flags are accepted.  These define the lane order
to be used when casting between types of different lane counts.

Update all users to pass an appropriate MemFlags argument.

Implement lane swaps where necessary in the s390x back-end.

This is the final part necessary to fix
https://github.com/bytecodealliance/wasmtime/issues/4566.
This commit is contained in:
Ulrich Weigand
2022-11-07 23:41:10 +01:00
committed by GitHub
parent 5cef53537b
commit 3e5938e65a
16 changed files with 295 additions and 51 deletions

View File

@@ -16,7 +16,7 @@ block0(v0: i32x4, v1: i32x4):
function %mask_casted(i64x2, i64x2, i32x4) -> i64x2 {
block0(v0: i64x2, v1: i64x2, v2: i32x4):
v3 = bitcast.i64x2 v2
v3 = bitcast.i64x2 little v2
v4 = bitselect v3, v0, v1
return v4
}

View File

@@ -26,10 +26,10 @@ block0:
function %shuffle_i32x4_in_same_place() -> i32x4 {
block0:
v1 = vconst.i32x4 [0 1 2 3]
v2 = bitcast.i8x16 v1 ; we have to cast because shuffle is type-limited to Tx16
v2 = bitcast.i8x16 little v1 ; we have to cast because shuffle is type-limited to Tx16
; keep each lane in place from the first vector
v3 = shuffle v2, v2, [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
v4 = bitcast.i32x4 v3
v4 = bitcast.i32x4 little v3
return v4
}
; run: %shuffle_in_same_place() == [0 1 2 3]
@@ -37,10 +37,10 @@ block0:
function %shuffle_i32x4_to_all_true() -> i32x4 {
block0:
v1 = vconst.i32x4 [-1 0 -1 0]
v2 = bitcast.i8x16 v1 ; we have to cast because shuffle is type-limited to Tx16
v2 = bitcast.i8x16 little v1 ; we have to cast because shuffle is type-limited to Tx16
; pair up the true values to make the entire vector true
v3 = shuffle v2, v2, [0 1 2 3 0 1 2 3 8 9 10 11 8 9 10 11]
v4 = bitcast.i32x4 v3 ; TODO store.i32x4 is unavailable; see https://github.com/bytecodealliance/wasmtime/issues/2237
v4 = bitcast.i32x4 little v3 ; TODO store.i32x4 is unavailable; see https://github.com/bytecodealliance/wasmtime/issues/2237
return v4
}
; run: %shuffle_i32x4_to_all_true() == [0xffffffff 0xffffffff 0xffffffff 0xffffffff]