[meta] Remove unused bit-vector functionalty;
It can be resurrected if needed in the future. It was used only for the semantics descriptions, which went away with the transition of the meta-language to Rust.
This commit is contained in:
@@ -16,7 +16,6 @@ static _RUST_NAME_PREFIX: &str = "ir::types::";
|
|||||||
/// or one of its subclasses.
|
/// or one of its subclasses.
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub(crate) enum ValueType {
|
pub(crate) enum ValueType {
|
||||||
BV(BVType),
|
|
||||||
Lane(LaneType),
|
Lane(LaneType),
|
||||||
Reference(ReferenceType),
|
Reference(ReferenceType),
|
||||||
Special(SpecialType),
|
Special(SpecialType),
|
||||||
@@ -41,7 +40,6 @@ impl ValueType {
|
|||||||
/// Return a string containing the documentation comment for this type.
|
/// Return a string containing the documentation comment for this type.
|
||||||
pub fn doc(&self) -> String {
|
pub fn doc(&self) -> String {
|
||||||
match *self {
|
match *self {
|
||||||
ValueType::BV(ref b) => b.doc(),
|
|
||||||
ValueType::Lane(l) => l.doc(),
|
ValueType::Lane(l) => l.doc(),
|
||||||
ValueType::Reference(r) => r.doc(),
|
ValueType::Reference(r) => r.doc(),
|
||||||
ValueType::Special(s) => s.doc(),
|
ValueType::Special(s) => s.doc(),
|
||||||
@@ -52,7 +50,6 @@ impl ValueType {
|
|||||||
/// Return the number of bits in a lane.
|
/// Return the number of bits in a lane.
|
||||||
pub fn lane_bits(&self) -> u64 {
|
pub fn lane_bits(&self) -> u64 {
|
||||||
match *self {
|
match *self {
|
||||||
ValueType::BV(ref b) => b.lane_bits(),
|
|
||||||
ValueType::Lane(l) => l.lane_bits(),
|
ValueType::Lane(l) => l.lane_bits(),
|
||||||
ValueType::Reference(r) => r.lane_bits(),
|
ValueType::Reference(r) => r.lane_bits(),
|
||||||
ValueType::Special(s) => s.lane_bits(),
|
ValueType::Special(s) => s.lane_bits(),
|
||||||
@@ -76,7 +73,6 @@ impl ValueType {
|
|||||||
/// Find the unique number associated with this type.
|
/// Find the unique number associated with this type.
|
||||||
pub fn number(&self) -> Option<u8> {
|
pub fn number(&self) -> Option<u8> {
|
||||||
match *self {
|
match *self {
|
||||||
ValueType::BV(_) => None,
|
|
||||||
ValueType::Lane(l) => Some(l.number()),
|
ValueType::Lane(l) => Some(l.number()),
|
||||||
ValueType::Reference(r) => Some(r.number()),
|
ValueType::Reference(r) => Some(r.number()),
|
||||||
ValueType::Special(s) => Some(s.number()),
|
ValueType::Special(s) => Some(s.number()),
|
||||||
@@ -105,7 +101,6 @@ impl ValueType {
|
|||||||
impl fmt::Display for ValueType {
|
impl fmt::Display for ValueType {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
ValueType::BV(ref b) => b.fmt(f),
|
|
||||||
ValueType::Lane(l) => l.fmt(f),
|
ValueType::Lane(l) => l.fmt(f),
|
||||||
ValueType::Reference(r) => r.fmt(f),
|
ValueType::Reference(r) => r.fmt(f),
|
||||||
ValueType::Special(s) => s.fmt(f),
|
ValueType::Special(s) => s.fmt(f),
|
||||||
@@ -114,13 +109,6 @@ impl fmt::Display for ValueType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a ValueType from a given bitvector type.
|
|
||||||
impl From<BVType> for ValueType {
|
|
||||||
fn from(bv: BVType) -> Self {
|
|
||||||
ValueType::BV(bv)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a ValueType from a given lane type.
|
/// Create a ValueType from a given lane type.
|
||||||
impl From<LaneType> for ValueType {
|
impl From<LaneType> for ValueType {
|
||||||
fn from(lane: LaneType) -> Self {
|
fn from(lane: LaneType) -> Self {
|
||||||
@@ -263,13 +251,6 @@ impl LaneType {
|
|||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_bool(self) -> bool {
|
|
||||||
match self {
|
|
||||||
LaneType::BoolType(_) => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for LaneType {
|
impl fmt::Display for LaneType {
|
||||||
@@ -420,41 +401,6 @@ impl fmt::Debug for VectorType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A flat bitvector type. Used for semantics description only.
|
|
||||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub(crate) struct BVType {
|
|
||||||
bits: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BVType {
|
|
||||||
/// Initialize a new bitvector type with `n` bits.
|
|
||||||
pub fn new(bits: u16) -> Self {
|
|
||||||
Self { bits: bits.into() }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return a string containing the documentation comment for this bitvector type.
|
|
||||||
pub fn doc(&self) -> String {
|
|
||||||
format!("A bitvector type with {} bits.", self.bits)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the number of bits in a lane.
|
|
||||||
pub fn lane_bits(&self) -> u64 {
|
|
||||||
self.bits
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for BVType {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "bv{}", self.bits)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Debug for BVType {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "BVType(bits={})", self.lane_bits())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A concrete scalar type that is neither a vector nor a lane type.
|
/// A concrete scalar type that is neither a vector nor a lane type.
|
||||||
///
|
///
|
||||||
/// Special types cannot be used to form vectors.
|
/// Special types cannot be used to form vectors.
|
||||||
|
|||||||
@@ -6,12 +6,11 @@ use std::iter::FromIterator;
|
|||||||
use std::ops;
|
use std::ops;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
|
|
||||||
use crate::cdsl::types::{BVType, LaneType, ReferenceType, SpecialType, ValueType};
|
use crate::cdsl::types::{LaneType, ReferenceType, SpecialType, ValueType};
|
||||||
|
|
||||||
const MAX_LANES: u16 = 256;
|
const MAX_LANES: u16 = 256;
|
||||||
const MAX_BITS: u16 = 128;
|
const MAX_BITS: u16 = 128;
|
||||||
const MAX_FLOAT_BITS: u16 = 64;
|
const MAX_FLOAT_BITS: u16 = 64;
|
||||||
const MAX_BITVEC: u16 = MAX_BITS * MAX_LANES;
|
|
||||||
|
|
||||||
/// Type variables can be used in place of concrete types when defining
|
/// Type variables can be used in place of concrete types when defining
|
||||||
/// instructions. This makes the instructions *polymorphic*.
|
/// instructions. This makes the instructions *polymorphic*.
|
||||||
@@ -58,10 +57,6 @@ impl TypeVar {
|
|||||||
let mut builder = TypeSetBuilder::new();
|
let mut builder = TypeSetBuilder::new();
|
||||||
|
|
||||||
let (scalar_type, num_lanes) = match value_type {
|
let (scalar_type, num_lanes) = match value_type {
|
||||||
ValueType::BV(bitvec_type) => {
|
|
||||||
let bits = bitvec_type.lane_bits() as RangeBound;
|
|
||||||
return TypeVar::new(name, doc, builder.bitvecs(bits..bits).build());
|
|
||||||
}
|
|
||||||
ValueType::Special(special_type) => {
|
ValueType::Special(special_type) => {
|
||||||
return TypeVar::new(name, doc, builder.specials(vec![special_type]).build());
|
return TypeVar::new(name, doc, builder.specials(vec![special_type]).build());
|
||||||
}
|
}
|
||||||
@@ -198,9 +193,7 @@ impl TypeVar {
|
|||||||
"can't double 256 lanes"
|
"can't double 256 lanes"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
DerivedFunc::LaneOf | DerivedFunc::ToBitVec | DerivedFunc::AsBool => {
|
DerivedFunc::LaneOf | DerivedFunc::AsBool => { /* no particular assertions */ }
|
||||||
/* no particular assertions */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeVar {
|
TypeVar {
|
||||||
@@ -234,9 +227,6 @@ impl TypeVar {
|
|||||||
pub fn double_vector(&self) -> TypeVar {
|
pub fn double_vector(&self) -> TypeVar {
|
||||||
self.derived(DerivedFunc::DoubleVector)
|
self.derived(DerivedFunc::DoubleVector)
|
||||||
}
|
}
|
||||||
pub fn to_bitvec(&self) -> TypeVar {
|
|
||||||
self.derived(DerivedFunc::ToBitVec)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Constrain the range of types this variable can assume to a subset of those in the typeset
|
/// Constrain the range of types this variable can assume to a subset of those in the typeset
|
||||||
/// ts.
|
/// ts.
|
||||||
@@ -343,7 +333,6 @@ pub(crate) enum DerivedFunc {
|
|||||||
DoubleWidth,
|
DoubleWidth,
|
||||||
HalfVector,
|
HalfVector,
|
||||||
DoubleVector,
|
DoubleVector,
|
||||||
ToBitVec,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DerivedFunc {
|
impl DerivedFunc {
|
||||||
@@ -355,7 +344,6 @@ impl DerivedFunc {
|
|||||||
DerivedFunc::DoubleWidth => "double_width",
|
DerivedFunc::DoubleWidth => "double_width",
|
||||||
DerivedFunc::HalfVector => "half_vector",
|
DerivedFunc::HalfVector => "half_vector",
|
||||||
DerivedFunc::DoubleVector => "double_vector",
|
DerivedFunc::DoubleVector => "double_vector",
|
||||||
DerivedFunc::ToBitVec => "to_bitvec",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,7 +400,6 @@ pub(crate) struct TypeSet {
|
|||||||
pub floats: NumSet,
|
pub floats: NumSet,
|
||||||
pub bools: NumSet,
|
pub bools: NumSet,
|
||||||
pub refs: NumSet,
|
pub refs: NumSet,
|
||||||
pub bitvecs: NumSet,
|
|
||||||
pub specials: Vec<SpecialType>,
|
pub specials: Vec<SpecialType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,7 +410,6 @@ impl TypeSet {
|
|||||||
floats: NumSet,
|
floats: NumSet,
|
||||||
bools: NumSet,
|
bools: NumSet,
|
||||||
refs: NumSet,
|
refs: NumSet,
|
||||||
bitvecs: NumSet,
|
|
||||||
specials: Vec<SpecialType>,
|
specials: Vec<SpecialType>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -432,7 +418,6 @@ impl TypeSet {
|
|||||||
floats,
|
floats,
|
||||||
bools,
|
bools,
|
||||||
refs,
|
refs,
|
||||||
bitvecs,
|
|
||||||
specials,
|
specials,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -440,11 +425,7 @@ impl TypeSet {
|
|||||||
/// Return the number of concrete types represented by this typeset.
|
/// Return the number of concrete types represented by this typeset.
|
||||||
pub fn size(&self) -> usize {
|
pub fn size(&self) -> usize {
|
||||||
self.lanes.len()
|
self.lanes.len()
|
||||||
* (self.ints.len()
|
* (self.ints.len() + self.floats.len() + self.bools.len() + self.refs.len())
|
||||||
+ self.floats.len()
|
|
||||||
+ self.bools.len()
|
|
||||||
+ self.refs.len()
|
|
||||||
+ self.bitvecs.len())
|
|
||||||
+ self.specials.len()
|
+ self.specials.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +438,6 @@ impl TypeSet {
|
|||||||
DerivedFunc::DoubleWidth => self.double_width(),
|
DerivedFunc::DoubleWidth => self.double_width(),
|
||||||
DerivedFunc::HalfVector => self.half_vector(),
|
DerivedFunc::HalfVector => self.half_vector(),
|
||||||
DerivedFunc::DoubleVector => self.double_vector(),
|
DerivedFunc::DoubleVector => self.double_vector(),
|
||||||
DerivedFunc::ToBitVec => self.to_bitvec(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -465,7 +445,6 @@ impl TypeSet {
|
|||||||
fn lane_of(&self) -> TypeSet {
|
fn lane_of(&self) -> TypeSet {
|
||||||
let mut copy = self.clone();
|
let mut copy = self.clone();
|
||||||
copy.lanes = num_set![1];
|
copy.lanes = num_set![1];
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +454,6 @@ impl TypeSet {
|
|||||||
copy.ints = NumSet::new();
|
copy.ints = NumSet::new();
|
||||||
copy.floats = NumSet::new();
|
copy.floats = NumSet::new();
|
||||||
copy.refs = NumSet::new();
|
copy.refs = NumSet::new();
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
if !(&self.lanes - &num_set![1]).is_empty() {
|
if !(&self.lanes - &num_set![1]).is_empty() {
|
||||||
copy.bools = &self.ints | &self.floats;
|
copy.bools = &self.ints | &self.floats;
|
||||||
copy.bools = ©.bools | &self.bools;
|
copy.bools = ©.bools | &self.bools;
|
||||||
@@ -492,7 +470,6 @@ impl TypeSet {
|
|||||||
copy.ints = NumSet::from_iter(self.ints.iter().filter(|&&x| x > 8).map(|&x| x / 2));
|
copy.ints = NumSet::from_iter(self.ints.iter().filter(|&&x| x > 8).map(|&x| x / 2));
|
||||||
copy.floats = NumSet::from_iter(self.floats.iter().filter(|&&x| x > 32).map(|&x| x / 2));
|
copy.floats = NumSet::from_iter(self.floats.iter().filter(|&&x| x > 32).map(|&x| x / 2));
|
||||||
copy.bools = NumSet::from_iter(self.bools.iter().filter(|&&x| x > 8).map(|&x| x / 2));
|
copy.bools = NumSet::from_iter(self.bools.iter().filter(|&&x| x > 8).map(|&x| x / 2));
|
||||||
copy.bitvecs = NumSet::from_iter(self.bitvecs.iter().filter(|&&x| x > 1).map(|&x| x / 2));
|
|
||||||
copy.specials = Vec::new();
|
copy.specials = Vec::new();
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
@@ -514,12 +491,6 @@ impl TypeSet {
|
|||||||
.map(|&x| x * 2)
|
.map(|&x| x * 2)
|
||||||
.filter(|x| legal_bool(*x)),
|
.filter(|x| legal_bool(*x)),
|
||||||
);
|
);
|
||||||
copy.bitvecs = NumSet::from_iter(
|
|
||||||
self.bitvecs
|
|
||||||
.iter()
|
|
||||||
.filter(|&&x| x < MAX_BITVEC)
|
|
||||||
.map(|&x| x * 2),
|
|
||||||
);
|
|
||||||
copy.specials = Vec::new();
|
copy.specials = Vec::new();
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
@@ -527,7 +498,6 @@ impl TypeSet {
|
|||||||
/// Return a TypeSet describing the image of self across halfvector.
|
/// Return a TypeSet describing the image of self across halfvector.
|
||||||
fn half_vector(&self) -> TypeSet {
|
fn half_vector(&self) -> TypeSet {
|
||||||
let mut copy = self.clone();
|
let mut copy = self.clone();
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
copy.lanes = NumSet::from_iter(self.lanes.iter().filter(|&&x| x > 1).map(|&x| x / 2));
|
copy.lanes = NumSet::from_iter(self.lanes.iter().filter(|&&x| x > 1).map(|&x| x / 2));
|
||||||
copy.specials = Vec::new();
|
copy.specials = Vec::new();
|
||||||
copy
|
copy
|
||||||
@@ -536,7 +506,6 @@ impl TypeSet {
|
|||||||
/// Return a TypeSet describing the image of self across doublevector.
|
/// Return a TypeSet describing the image of self across doublevector.
|
||||||
fn double_vector(&self) -> TypeSet {
|
fn double_vector(&self) -> TypeSet {
|
||||||
let mut copy = self.clone();
|
let mut copy = self.clone();
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
copy.lanes = NumSet::from_iter(
|
copy.lanes = NumSet::from_iter(
|
||||||
self.lanes
|
self.lanes
|
||||||
.iter()
|
.iter()
|
||||||
@@ -547,29 +516,6 @@ impl TypeSet {
|
|||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return a TypeSet describing the image of self across to_bitvec.
|
|
||||||
fn to_bitvec(&self) -> TypeSet {
|
|
||||||
assert!(self.bitvecs.is_empty());
|
|
||||||
let all_scalars = &(&self.ints | &self.floats) | &self.bools;
|
|
||||||
|
|
||||||
let mut copy = self.clone();
|
|
||||||
copy.lanes = num_set![1];
|
|
||||||
copy.ints = NumSet::new();
|
|
||||||
copy.bools = NumSet::new();
|
|
||||||
copy.floats = NumSet::new();
|
|
||||||
copy.refs = NumSet::new();
|
|
||||||
copy.bitvecs = self
|
|
||||||
.lanes
|
|
||||||
.iter()
|
|
||||||
.cycle()
|
|
||||||
.zip(all_scalars.iter())
|
|
||||||
.map(|(num_lanes, lane_width)| num_lanes * lane_width)
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
copy.specials = Vec::new();
|
|
||||||
copy
|
|
||||||
}
|
|
||||||
|
|
||||||
fn concrete_types(&self) -> Vec<ValueType> {
|
fn concrete_types(&self) -> Vec<ValueType> {
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
for &num_lanes in &self.lanes {
|
for &num_lanes in &self.lanes {
|
||||||
@@ -585,10 +531,6 @@ impl TypeSet {
|
|||||||
for &bits in &self.refs {
|
for &bits in &self.refs {
|
||||||
ret.push(ReferenceType::ref_from_bits(bits).into());
|
ret.push(ReferenceType::ref_from_bits(bits).into());
|
||||||
}
|
}
|
||||||
for &bits in &self.bitvecs {
|
|
||||||
assert_eq!(num_lanes, 1);
|
|
||||||
ret.push(BVType::new(bits).into());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for &special in &self.specials {
|
for &special in &self.specials {
|
||||||
ret.push(special.into());
|
ret.push(special.into());
|
||||||
@@ -613,14 +555,12 @@ impl TypeSet {
|
|||||||
match func {
|
match func {
|
||||||
DerivedFunc::LaneOf => {
|
DerivedFunc::LaneOf => {
|
||||||
let mut copy = self.clone();
|
let mut copy = self.clone();
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
copy.lanes =
|
copy.lanes =
|
||||||
NumSet::from_iter((0..=MAX_LANES.trailing_zeros()).map(|i| u16::pow(2, i)));
|
NumSet::from_iter((0..=MAX_LANES.trailing_zeros()).map(|i| u16::pow(2, i)));
|
||||||
copy
|
copy
|
||||||
}
|
}
|
||||||
DerivedFunc::AsBool => {
|
DerivedFunc::AsBool => {
|
||||||
let mut copy = self.clone();
|
let mut copy = self.clone();
|
||||||
copy.bitvecs = NumSet::new();
|
|
||||||
if self.bools.contains(&1) {
|
if self.bools.contains(&1) {
|
||||||
copy.ints = NumSet::from_iter(vec![8, 16, 32, 64, 128]);
|
copy.ints = NumSet::from_iter(vec![8, 16, 32, 64, 128]);
|
||||||
copy.floats = NumSet::from_iter(vec![32, 64]);
|
copy.floats = NumSet::from_iter(vec![32, 64]);
|
||||||
@@ -637,43 +577,6 @@ impl TypeSet {
|
|||||||
DerivedFunc::DoubleWidth => self.half_width(),
|
DerivedFunc::DoubleWidth => self.half_width(),
|
||||||
DerivedFunc::HalfVector => self.double_vector(),
|
DerivedFunc::HalfVector => self.double_vector(),
|
||||||
DerivedFunc::DoubleVector => self.half_vector(),
|
DerivedFunc::DoubleVector => self.half_vector(),
|
||||||
DerivedFunc::ToBitVec => {
|
|
||||||
let all_lanes = range_to_set(Some(1..MAX_LANES));
|
|
||||||
let all_ints = range_to_set(Some(8..MAX_BITS));
|
|
||||||
let all_floats = range_to_set(Some(32..64));
|
|
||||||
let all_bools = range_to_set(Some(1..MAX_BITS));
|
|
||||||
|
|
||||||
let mut lanes = range_to_set(Some(1..MAX_LANES));
|
|
||||||
let mut ints = range_to_set(Some(8..MAX_BITS));
|
|
||||||
let mut floats = range_to_set(Some(32..64));
|
|
||||||
let mut bools = range_to_set(Some(1..MAX_BITS));
|
|
||||||
let refs = range_to_set(Some(32..64));
|
|
||||||
|
|
||||||
for &l in &all_lanes {
|
|
||||||
for &i in &all_ints {
|
|
||||||
if self.bitvecs.contains(&(i * l)) {
|
|
||||||
lanes.insert(l);
|
|
||||||
ints.insert(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for &f in &all_floats {
|
|
||||||
if self.bitvecs.contains(&(f * l)) {
|
|
||||||
lanes.insert(l);
|
|
||||||
floats.insert(f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for &b in &all_bools {
|
|
||||||
if self.bitvecs.contains(&(b * l)) {
|
|
||||||
lanes.insert(l);
|
|
||||||
bools.insert(b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let bitvecs = NumSet::new();
|
|
||||||
let specials = Vec::new();
|
|
||||||
TypeSet::new(lanes, ints, floats, bools, refs, bitvecs, specials)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -683,7 +586,6 @@ impl TypeSet {
|
|||||||
self.floats = &self.floats & &other.floats;
|
self.floats = &self.floats & &other.floats;
|
||||||
self.bools = &self.bools & &other.bools;
|
self.bools = &self.bools & &other.bools;
|
||||||
self.refs = &self.refs & &other.refs;
|
self.refs = &self.refs & &other.refs;
|
||||||
self.bitvecs = &self.bitvecs & &other.bitvecs;
|
|
||||||
|
|
||||||
let mut new_specials = Vec::new();
|
let mut new_specials = Vec::new();
|
||||||
for spec in &self.specials {
|
for spec in &self.specials {
|
||||||
@@ -700,7 +602,6 @@ impl TypeSet {
|
|||||||
&& self.floats.is_subset(&other.floats)
|
&& self.floats.is_subset(&other.floats)
|
||||||
&& self.bools.is_subset(&other.bools)
|
&& self.bools.is_subset(&other.bools)
|
||||||
&& self.refs.is_subset(&other.refs)
|
&& self.refs.is_subset(&other.refs)
|
||||||
&& self.bitvecs.is_subset(&other.bitvecs)
|
|
||||||
&& {
|
&& {
|
||||||
let specials: HashSet<SpecialType> = HashSet::from_iter(self.specials.clone());
|
let specials: HashSet<SpecialType> = HashSet::from_iter(self.specials.clone());
|
||||||
let other_specials = HashSet::from_iter(other.specials.clone());
|
let other_specials = HashSet::from_iter(other.specials.clone());
|
||||||
@@ -766,12 +667,6 @@ impl fmt::Debug for TypeSet {
|
|||||||
Vec::from_iter(self.refs.iter().map(|x| x.to_string())).join(", ")
|
Vec::from_iter(self.refs.iter().map(|x| x.to_string())).join(", ")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if !self.bitvecs.is_empty() {
|
|
||||||
subsets.push(format!(
|
|
||||||
"bitvecs={{{}}}",
|
|
||||||
Vec::from_iter(self.bitvecs.iter().map(|x| x.to_string())).join(", ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
if !self.specials.is_empty() {
|
if !self.specials.is_empty() {
|
||||||
subsets.push(format!(
|
subsets.push(format!(
|
||||||
"specials={{{}}}",
|
"specials={{{}}}",
|
||||||
@@ -789,7 +684,6 @@ pub(crate) struct TypeSetBuilder {
|
|||||||
floats: Interval,
|
floats: Interval,
|
||||||
bools: Interval,
|
bools: Interval,
|
||||||
refs: Interval,
|
refs: Interval,
|
||||||
bitvecs: Interval,
|
|
||||||
includes_scalars: bool,
|
includes_scalars: bool,
|
||||||
simd_lanes: Interval,
|
simd_lanes: Interval,
|
||||||
specials: Vec<SpecialType>,
|
specials: Vec<SpecialType>,
|
||||||
@@ -802,7 +696,6 @@ impl TypeSetBuilder {
|
|||||||
floats: Interval::None,
|
floats: Interval::None,
|
||||||
bools: Interval::None,
|
bools: Interval::None,
|
||||||
refs: Interval::None,
|
refs: Interval::None,
|
||||||
bitvecs: Interval::None,
|
|
||||||
includes_scalars: true,
|
includes_scalars: true,
|
||||||
simd_lanes: Interval::None,
|
simd_lanes: Interval::None,
|
||||||
specials: Vec::new(),
|
specials: Vec::new(),
|
||||||
@@ -838,11 +731,6 @@ impl TypeSetBuilder {
|
|||||||
self.simd_lanes = interval.into();
|
self.simd_lanes = interval.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
pub fn bitvecs(mut self, interval: impl Into<Interval>) -> Self {
|
|
||||||
assert!(self.bitvecs == Interval::None);
|
|
||||||
self.bitvecs = interval.into();
|
|
||||||
self
|
|
||||||
}
|
|
||||||
pub fn specials(mut self, specials: Vec<SpecialType>) -> Self {
|
pub fn specials(mut self, specials: Vec<SpecialType>) -> Self {
|
||||||
assert!(self.specials.is_empty());
|
assert!(self.specials.is_empty());
|
||||||
self.specials = specials;
|
self.specials = specials;
|
||||||
@@ -863,7 +751,6 @@ impl TypeSetBuilder {
|
|||||||
range_to_set(self.floats.to_range(32..64, None)),
|
range_to_set(self.floats.to_range(32..64, None)),
|
||||||
bools,
|
bools,
|
||||||
range_to_set(self.refs.to_range(32..64, None)),
|
range_to_set(self.refs.to_range(32..64, None)),
|
||||||
range_to_set(self.bitvecs.to_range(1..MAX_BITVEC, None)),
|
|
||||||
self.specials,
|
self.specials,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -875,7 +762,6 @@ impl TypeSetBuilder {
|
|||||||
.bools(Interval::All)
|
.bools(Interval::All)
|
||||||
.refs(Interval::All)
|
.refs(Interval::All)
|
||||||
.simd_lanes(Interval::All)
|
.simd_lanes(Interval::All)
|
||||||
.bitvecs(Interval::All)
|
|
||||||
.specials(ValueType::all_special_types().collect())
|
.specials(ValueType::all_special_types().collect())
|
||||||
.includes_scalars(true)
|
.includes_scalars(true)
|
||||||
.build()
|
.build()
|
||||||
@@ -953,7 +839,6 @@ fn test_typevar_builder() {
|
|||||||
assert!(type_set.floats.is_empty());
|
assert!(type_set.floats.is_empty());
|
||||||
assert_eq!(type_set.ints, num_set![8, 16, 32, 64, 128]);
|
assert_eq!(type_set.ints, num_set![8, 16, 32, 64, 128]);
|
||||||
assert!(type_set.bools.is_empty());
|
assert!(type_set.bools.is_empty());
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
|
|
||||||
let type_set = TypeSetBuilder::new().bools(Interval::All).build();
|
let type_set = TypeSetBuilder::new().bools(Interval::All).build();
|
||||||
@@ -961,7 +846,6 @@ fn test_typevar_builder() {
|
|||||||
assert!(type_set.floats.is_empty());
|
assert!(type_set.floats.is_empty());
|
||||||
assert!(type_set.ints.is_empty());
|
assert!(type_set.ints.is_empty());
|
||||||
assert_eq!(type_set.bools, num_set![1, 8, 16, 32, 64, 128]);
|
assert_eq!(type_set.bools, num_set![1, 8, 16, 32, 64, 128]);
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
|
|
||||||
let type_set = TypeSetBuilder::new().floats(Interval::All).build();
|
let type_set = TypeSetBuilder::new().floats(Interval::All).build();
|
||||||
@@ -969,7 +853,6 @@ fn test_typevar_builder() {
|
|||||||
assert_eq!(type_set.floats, num_set![32, 64]);
|
assert_eq!(type_set.floats, num_set![32, 64]);
|
||||||
assert!(type_set.ints.is_empty());
|
assert!(type_set.ints.is_empty());
|
||||||
assert!(type_set.bools.is_empty());
|
assert!(type_set.bools.is_empty());
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
|
|
||||||
let type_set = TypeSetBuilder::new()
|
let type_set = TypeSetBuilder::new()
|
||||||
@@ -981,7 +864,6 @@ fn test_typevar_builder() {
|
|||||||
assert_eq!(type_set.floats, num_set![32, 64]);
|
assert_eq!(type_set.floats, num_set![32, 64]);
|
||||||
assert!(type_set.ints.is_empty());
|
assert!(type_set.ints.is_empty());
|
||||||
assert!(type_set.bools.is_empty());
|
assert!(type_set.bools.is_empty());
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
|
|
||||||
let type_set = TypeSetBuilder::new()
|
let type_set = TypeSetBuilder::new()
|
||||||
@@ -993,7 +875,6 @@ fn test_typevar_builder() {
|
|||||||
assert_eq!(type_set.floats, num_set![32, 64]);
|
assert_eq!(type_set.floats, num_set![32, 64]);
|
||||||
assert!(type_set.ints.is_empty());
|
assert!(type_set.ints.is_empty());
|
||||||
assert!(type_set.bools.is_empty());
|
assert!(type_set.bools.is_empty());
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
|
|
||||||
let type_set = TypeSetBuilder::new().ints(16..64).build();
|
let type_set = TypeSetBuilder::new().ints(16..64).build();
|
||||||
@@ -1001,7 +882,6 @@ fn test_typevar_builder() {
|
|||||||
assert_eq!(type_set.ints, num_set![16, 32, 64]);
|
assert_eq!(type_set.ints, num_set![16, 32, 64]);
|
||||||
assert!(type_set.floats.is_empty());
|
assert!(type_set.floats.is_empty());
|
||||||
assert!(type_set.bools.is_empty());
|
assert!(type_set.bools.is_empty());
|
||||||
assert!(type_set.bitvecs.is_empty());
|
|
||||||
assert!(type_set.specials.is_empty());
|
assert!(type_set.specials.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1326,7 +1206,6 @@ fn test_typevar_singleton() {
|
|||||||
assert_eq!(typevar.type_set.ints, num_set![32]);
|
assert_eq!(typevar.type_set.ints, num_set![32]);
|
||||||
assert!(typevar.type_set.floats.is_empty());
|
assert!(typevar.type_set.floats.is_empty());
|
||||||
assert!(typevar.type_set.bools.is_empty());
|
assert!(typevar.type_set.bools.is_empty());
|
||||||
assert!(typevar.type_set.bitvecs.is_empty());
|
|
||||||
assert!(typevar.type_set.specials.is_empty());
|
assert!(typevar.type_set.specials.is_empty());
|
||||||
assert_eq!(typevar.type_set.lanes, num_set![1]);
|
assert_eq!(typevar.type_set.lanes, num_set![1]);
|
||||||
|
|
||||||
@@ -1340,6 +1219,5 @@ fn test_typevar_singleton() {
|
|||||||
assert_eq!(typevar.type_set.floats, num_set![32]);
|
assert_eq!(typevar.type_set.floats, num_set![32]);
|
||||||
assert_eq!(typevar.type_set.lanes, num_set![4]);
|
assert_eq!(typevar.type_set.lanes, num_set![4]);
|
||||||
assert!(typevar.type_set.bools.is_empty());
|
assert!(typevar.type_set.bools.is_empty());
|
||||||
assert!(typevar.type_set.bitvecs.is_empty());
|
|
||||||
assert!(typevar.type_set.specials.is_empty());
|
assert!(typevar.type_set.specials.is_empty());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -650,9 +650,6 @@ fn typeset_to_string(ts: &TypeSet) -> String {
|
|||||||
if !ts.bools.is_empty() {
|
if !ts.bools.is_empty() {
|
||||||
result += &format!(", bools={}", iterable_to_string(&ts.bools));
|
result += &format!(", bools={}", iterable_to_string(&ts.bools));
|
||||||
}
|
}
|
||||||
if !ts.bitvecs.is_empty() {
|
|
||||||
result += &format!(", bitvecs={}", iterable_to_string(&ts.bitvecs));
|
|
||||||
}
|
|
||||||
if !ts.specials.is_empty() {
|
if !ts.specials.is_empty() {
|
||||||
result += &format!(", specials=[{}]", iterable_to_string(&ts.specials));
|
result += &format!(", specials=[{}]", iterable_to_string(&ts.specials));
|
||||||
}
|
}
|
||||||
@@ -680,7 +677,6 @@ pub(crate) fn gen_typesets_table(type_sets: &UniqueTable<TypeSet>, fmt: &mut For
|
|||||||
for ts in type_sets.iter() {
|
for ts in type_sets.iter() {
|
||||||
fmt.line("ir::instructions::ValueTypeSet {");
|
fmt.line("ir::instructions::ValueTypeSet {");
|
||||||
fmt.indent(|fmt| {
|
fmt.indent(|fmt| {
|
||||||
assert!(ts.bitvecs.is_empty(), "Bitvector types are not emittable.");
|
|
||||||
fmt.comment(typeset_to_string(ts));
|
fmt.comment(typeset_to_string(ts));
|
||||||
gen_bitset(&ts.lanes, "lanes", 16, fmt);
|
gen_bitset(&ts.lanes, "lanes", 16, fmt);
|
||||||
gen_bitset(&ts.ints, "ints", 8, fmt);
|
gen_bitset(&ts.ints, "ints", 8, fmt);
|
||||||
|
|||||||
Reference in New Issue
Block a user