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:
@@ -67,7 +67,7 @@ use crate::ir::entities::AnyEntity;
|
||||
use crate::ir::instructions::{BranchInfo, CallInfo, InstructionFormat, ResolvedConstraint};
|
||||
use crate::ir::{
|
||||
types, ArgumentPurpose, Block, Constant, DynamicStackSlot, FuncRef, Function, GlobalValue,
|
||||
Inst, JumpTable, Opcode, SigRef, StackSlot, Type, Value, ValueDef, ValueList,
|
||||
Inst, JumpTable, MemFlags, Opcode, SigRef, StackSlot, Type, Value, ValueDef, ValueList,
|
||||
};
|
||||
use crate::isa::TargetIsa;
|
||||
use crate::iterators::IteratorExtras;
|
||||
@@ -729,11 +729,12 @@ impl<'a> Verifier<'a> {
|
||||
));
|
||||
}
|
||||
}
|
||||
Unary {
|
||||
LoadNoOffset {
|
||||
opcode: Opcode::Bitcast,
|
||||
flags,
|
||||
arg,
|
||||
} => {
|
||||
self.verify_bitcast(inst, arg, errors)?;
|
||||
self.verify_bitcast(inst, flags, arg, errors)?;
|
||||
}
|
||||
UnaryConst {
|
||||
opcode: Opcode::Vconst,
|
||||
@@ -1070,6 +1071,7 @@ impl<'a> Verifier<'a> {
|
||||
fn verify_bitcast(
|
||||
&self,
|
||||
inst: Inst,
|
||||
flags: MemFlags,
|
||||
arg: Value,
|
||||
errors: &mut VerifierErrors,
|
||||
) -> VerifierStepResult<()> {
|
||||
@@ -1086,6 +1088,19 @@ impl<'a> Verifier<'a> {
|
||||
typ.bits()
|
||||
),
|
||||
))
|
||||
} else if flags != MemFlags::new()
|
||||
&& flags != MemFlags::new().with_endianness(ir::Endianness::Little)
|
||||
&& flags != MemFlags::new().with_endianness(ir::Endianness::Big)
|
||||
{
|
||||
errors.fatal((
|
||||
inst,
|
||||
"The bitcast instruction only accepts the `big` or `little` memory flags",
|
||||
))
|
||||
} else if flags == MemFlags::new() && typ.lane_count() != value_type.lane_count() {
|
||||
errors.fatal((
|
||||
inst,
|
||||
"Byte order specifier required for bitcast instruction changing lane count",
|
||||
))
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user