Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cranelift/filetests/filetests/runtests/simd-ineg.clif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
test interpret
test run
target aarch64
target s390x
Expand Down
9 changes: 8 additions & 1 deletion cranelift/interpreter/src/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down