Merge pull request #3279 from dheaton-arm/implement-insertlane

Implement `Insertlane` for the Cranelift interpreter
This commit is contained in:
Chris Fallin
2021-09-02 09:44:59 -07:00
committed by GitHub
3 changed files with 39 additions and 1 deletions

View File

@@ -298,6 +298,7 @@ impl InstructionData {
&InstructionData::UnaryBool { imm, .. } => Some(DataValue::from(imm)), &InstructionData::UnaryBool { imm, .. } => Some(DataValue::from(imm)),
// 8-bit. // 8-bit.
&InstructionData::BinaryImm8 { imm, .. } &InstructionData::BinaryImm8 { imm, .. }
| &InstructionData::TernaryImm8 { imm, .. }
| &InstructionData::BranchTableEntry { imm, .. } => Some(DataValue::from(imm as i8)), // Note the switch from unsigned to signed. | &InstructionData::BranchTableEntry { imm, .. } => Some(DataValue::from(imm as i8)), // Note the switch from unsigned to signed.
// 32-bit // 32-bit
&InstructionData::UnaryIeee32 { imm, .. } => Some(DataValue::from(imm)), &InstructionData::UnaryIeee32 { imm, .. } => Some(DataValue::from(imm)),

View File

@@ -0,0 +1,33 @@
test interpret
test run
target aarch64
set enable_simd
target x86_64
function %insertlane_15(i8x16, i8) -> i8x16 {
block0(v0: i8x16, v1: i8):
v2 = insertlane v0, v1, 15
return v2
}
; run: %insertlane_15([1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], 120) == [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 120]
function %insertlane_5(i16x8, i16) -> i16x8 {
block0(v0: i16x8, v1: i16):
v2 = insertlane v0, v1, 5
return v2
}
; run: %insertlane_5([1 1 1 1 1 1 1 1], 10000) == [1 1 1 1 1 10000 1 1]
function %insertlane_2(i32x4, i32) -> i32x4 {
block0(v0: i32x4, v1: i32):
v2 = insertlane v0, v1, 2
return v2
}
; run: %insertlane_2([1 1 1 1], 100000) == [1 1 100000 1]
function %insertlane_0(i64x2, i64) -> i64x2 {
block0(v0: i64x2, v1: i64):
v2 = insertlane v0, v1, 0
return v2
}
; run: %insertlane_0([1 1], 5000000000) == [5000000000 1]

View File

@@ -704,7 +704,11 @@ where
Opcode::Shuffle => unimplemented!("Shuffle"), Opcode::Shuffle => unimplemented!("Shuffle"),
Opcode::Swizzle => unimplemented!("Swizzle"), Opcode::Swizzle => unimplemented!("Swizzle"),
Opcode::Splat => unimplemented!("Splat"), Opcode::Splat => unimplemented!("Splat"),
Opcode::Insertlane => unimplemented!("Insertlane"), Opcode::Insertlane => {
let mut vector = extractlanes(&arg(0)?, ctrl_ty.lane_type())?;
vector[Value::into_int(imm())? as usize] = arg(1)?.into_int()?;
assign(vectorizelanes(&vector, ctrl_ty)?)
}
Opcode::Extractlane => { Opcode::Extractlane => {
let value = let value =
extractlanes(&arg(0)?, ctrl_ty.lane_type())?[Value::into_int(imm())? as usize]; extractlanes(&arg(0)?, ctrl_ty.lane_type())?[Value::into_int(imm())? as usize];