Merge pull request #3317 from dheaton-arm/implement-swiden

Implement `SwidenLow` and `SwidenHigh` for the interpreter
This commit is contained in:
Chris Fallin
2021-09-14 08:57:57 -07:00
committed by GitHub
4 changed files with 82 additions and 25 deletions

View File

@@ -863,24 +863,29 @@ where
V::bool(true, types::B1)?,
|acc, lane| acc.and(lane),
)?),
Opcode::SwidenLow => unimplemented!("SwidenLow"),
Opcode::SwidenHigh => unimplemented!("SwidenHigh"),
Opcode::UwidenLow => {
Opcode::SwidenLow | Opcode::SwidenHigh | Opcode::UwidenLow | Opcode::UwidenHigh => {
let new_type = ctrl_ty.merge_lanes().unwrap();
let new_vec = extractlanes(&arg(0)?, ctrl_ty.lane_type())?
.into_iter()
.take(new_type.lane_count() as usize)
.map(|lane| lane.convert(ValueConversionKind::ZeroExtend(new_type.lane_type())))
.collect::<ValueResult<Vec<_>>>()?;
assign(vectorizelanes(&new_vec, new_type)?)
}
Opcode::UwidenHigh => {
let new_type = ctrl_ty.merge_lanes().unwrap();
let new_vec = extractlanes(&arg(0)?, ctrl_ty.lane_type())?
.into_iter()
.skip(new_type.lane_count() as usize)
.map(|lane| lane.convert(ValueConversionKind::ZeroExtend(new_type.lane_type())))
.collect::<ValueResult<Vec<_>>>()?;
let conv_type = match inst.opcode() {
Opcode::SwidenLow | Opcode::SwidenHigh => {
ValueConversionKind::SignExtend(new_type.lane_type())
}
Opcode::UwidenLow | Opcode::UwidenHigh => {
ValueConversionKind::ZeroExtend(new_type.lane_type())
}
_ => unreachable!(),
};
let vec_iter = extractlanes(&arg(0)?, ctrl_ty.lane_type())?.into_iter();
let new_vec = match inst.opcode() {
Opcode::SwidenLow | Opcode::UwidenLow => vec_iter
.take(new_type.lane_count() as usize)
.map(|lane| lane.convert(conv_type.clone()))
.collect::<ValueResult<Vec<_>>>()?,
Opcode::SwidenHigh | Opcode::UwidenHigh => vec_iter
.skip(new_type.lane_count() as usize)
.map(|lane| lane.convert(conv_type.clone()))
.collect::<ValueResult<Vec<_>>>()?,
_ => unreachable!(),
};
assign(vectorizelanes(&new_vec, new_type)?)
}
Opcode::FcvtToUint => unimplemented!("FcvtToUint"),