Browse Source

Add support for vector in DataValueExt::int() (#6844)

* Add support for vector in DataValueExt::int()

Fixes #6827

* Replace `if` with `match`

* Enable interpreter test for simd ineg

Issue #6827

* Format code with `cargo fmt`

and also improve comment
pull/6845/head
Gurinder Singh 1 year ago
committed by GitHub
parent
commit
76f1cb251d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      cranelift/filetests/filetests/runtests/simd-ineg.clif
  2. 9
      cranelift/interpreter/src/value.rs

1
cranelift/filetests/filetests/runtests/simd-ineg.clif

@ -1,3 +1,4 @@
test interpret
test run
target aarch64
target s390x

9
cranelift/interpreter/src/value.rs

@ -263,7 +263,14 @@ macro_rules! bitop {
impl DataValueExt for DataValue {
fn int(n: i128, ty: Type) -> ValueResult<Self> {
if ty.is_int() && !ty.is_vector() {
if ty.is_vector() {
// match ensures graceful failure since read_from_slice_ne()
// panics on anything other than 8 and 16 bytes
match ty.bytes() {
8 | 16 => Ok(DataValue::read_from_slice_ne(&n.to_ne_bytes(), ty)),
_ => Err(ValueError::InvalidType(ValueTypeClass::Vector, ty)),
}
} else if ty.is_int() {
DataValue::from_integer(n, ty).map_err(|_| ValueError::InvalidValue(ty))
} else {
Err(ValueError::InvalidType(ValueTypeClass::Integer, ty))

Loading…
Cancel
Save