Implement vsplit in cranelift interpreter (#5462)

* Add vsplit testfile

* Add vsplit implementation
This commit is contained in:
Ayomide Bamidele
2022-12-16 23:14:56 +00:00
committed by GitHub
parent 22439f7b39
commit 93ae9078c5
2 changed files with 40 additions and 1 deletions

View File

@@ -0,0 +1,31 @@
test interpret
function %vsplit_i32x4_hi(i32x4) -> i32x2 {
block0(v0: i32x4):
v1, v2 = vsplit.i32x4 v0
return v1
}
; run: %vsplit_i32x4_hi([1 2 3 4]) == [1 2]
function %vsplit_i32x4_lo(i32x4) -> i32x2 {
block0(v0: i32x4):
v1, v2 = vsplit.i32x4 v0
return v2
}
; run: %vsplit_i32x4_lo([1 2 3 4]) == [3 4]
function %vsplit_scalar_i64x2_hi(i64x2) -> i64 {
block0(v0: i64x2):
v1, v2 = vsplit.i64x2 v0
return v1
}
; run: %vsplit_scalar_i64x2_hi([1 2]) == 1
function %vsplit_scalar_i64x2_lo(i64x2) -> i64 {
block0(v0: i64x2):
v1, v2 = vsplit.i64x2 v0
return v2
}
; run: %vsplit_scalar_i64x2_lo([3 4]) == 4

View File

@@ -985,7 +985,15 @@ where
}
assign(Value::int(result, ctrl_ty)?)
}
Opcode::Vsplit => unimplemented!("Vsplit"),
Opcode::Vsplit => {
let new_type = ctrl_ty.half_vector().unwrap();
let vector = extractlanes(&arg(0)?, ctrl_ty)?;
let (high, low) = vector.split_at((ctrl_ty.lane_count() / 2) as usize);
assign_multiple(&[
vectorizelanes(high, new_type)?,
vectorizelanes(low, new_type)?,
])
}
Opcode::Vconcat => unimplemented!("Vconcat"),
Opcode::Vselect => assign(vselect(&arg(0)?, &arg(1)?, &arg(2)?, ctrl_ty)?),
Opcode::VanyTrue => {