Basic i128 support

This commit is contained in:
bjorn3
2019-06-12 19:24:47 +02:00
committed by Dan Gohman
parent 3b0e244316
commit c9a25abbc4
7 changed files with 26 additions and 9 deletions

View File

@@ -219,8 +219,9 @@ impl LaneType {
LaneType::IntType(shared_types::Int::I16) => 6,
LaneType::IntType(shared_types::Int::I32) => 7,
LaneType::IntType(shared_types::Int::I64) => 8,
LaneType::FloatType(shared_types::Float::F32) => 9,
LaneType::FloatType(shared_types::Float::F64) => 10,
LaneType::IntType(shared_types::Int::I128) => 9,
LaneType::FloatType(shared_types::Float::F32) => 10,
LaneType::FloatType(shared_types::Float::F64) => 11,
}
}
@@ -241,6 +242,7 @@ impl LaneType {
16 => shared_types::Int::I16,
32 => shared_types::Int::I32,
64 => shared_types::Int::I64,
128 => shared_types::Int::I128,
_ => unreachable!("unxpected num bits for int"),
})
}

View File

@@ -9,7 +9,7 @@ use std::rc::Rc;
use crate::cdsl::types::{BVType, LaneType, ReferenceType, SpecialType, ValueType};
const MAX_LANES: u16 = 256;
const MAX_BITS: u16 = 64;
const MAX_BITS: u16 = 128;
const MAX_BITVEC: u16 = MAX_BITS * MAX_LANES;
/// Type variables can be used in place of concrete types when defining

View File

@@ -3143,7 +3143,7 @@ pub(crate) fn define(
"WideInt",
"An integer type with lanes from `i16` upwards",
TypeSetBuilder::new()
.ints(16..64)
.ints(16..128)
.simd_lanes(Interval::All)
.build(),
);
@@ -3171,9 +3171,9 @@ pub(crate) fn define(
let NarrowInt = &TypeVar::new(
"NarrowInt",
"An integer type with lanes type to `i32`",
"An integer type with lanes type to `i64`",
TypeSetBuilder::new()
.ints(8..32)
.ints(8..64)
.simd_lanes(Interval::All)
.build(),
);

View File

@@ -51,6 +51,8 @@ pub enum Int {
I32 = 32,
/// 64-bit int.
I64 = 64,
/// 128-bit int.
I128 = 128,
}
/// This provides an iterator through all of the supported int variants.
@@ -72,6 +74,7 @@ impl Iterator for IntIterator {
1 => Some(Int::I16),
2 => Some(Int::I32),
3 => Some(Int::I64),
4 => Some(Int::I128),
_ => return None,
};
self.index += 1;
@@ -199,6 +202,7 @@ mod iter_tests {
assert_eq!(int_iter.next(), Some(Int::I16));
assert_eq!(int_iter.next(), Some(Int::I32));
assert_eq!(int_iter.next(), Some(Int::I64));
assert_eq!(int_iter.next(), Some(Int::I128));
assert_eq!(int_iter.next(), None);
}