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

@@ -3104,6 +3104,7 @@ pub(crate) fn define(
let x = &Operand::new("x", Mem);
let a = &Operand::new("a", MemTo).with_doc("Bits of `x` reinterpreted");
let MemFlags = &Operand::new("MemFlags", &imm.memflags);
ig.push(
Inst::new(
@@ -3113,11 +3114,16 @@ pub(crate) fn define(
The input and output types must be storable to memory and of the same
size. A bitcast is equivalent to storing one type and loading the other
type from the same address.
type from the same address, both using the specified MemFlags.
Note that this operation only supports the `big` or `little` MemFlags.
The specified byte order only affects the result in the case where
input and output types differ in lane count/size. In this case, the
operation is only valid if a byte order specifier is provided.
"#,
&formats.unary,
&formats.load_no_offset,
)
.operands_in(vec![x])
.operands_in(vec![MemFlags, x])
.operands_out(vec![a]),
);