Add ir::Types::lane_of as an alias of lane_type to be used in typevar constraints;

This commit is contained in:
Benjamin Bouvier
2019-07-02 18:29:41 +02:00
parent 4fef03f5f8
commit 3545363006
2 changed files with 10 additions and 3 deletions

View File

@@ -498,7 +498,7 @@ enum OperandConstraint {
/// This operand is the same type as the controlling type variable. /// This operand is the same type as the controlling type variable.
Same, Same,
/// This operand is `ctrlType.lane_type()`. /// This operand is `ctrlType.lane_of()`.
LaneOf, LaneOf,
/// This operand is `ctrlType.as_bool()`. /// This operand is `ctrlType.as_bool()`.
@@ -527,7 +527,7 @@ impl OperandConstraint {
Concrete(t) => Bound(t), Concrete(t) => Bound(t),
Free(vts) => ResolvedConstraint::Free(TYPE_SETS[vts as usize]), Free(vts) => ResolvedConstraint::Free(TYPE_SETS[vts as usize]),
Same => Bound(ctrl_type), Same => Bound(ctrl_type),
LaneOf => Bound(ctrl_type.lane_type()), LaneOf => Bound(ctrl_type.lane_of()),
AsBool => Bound(ctrl_type.as_bool()), AsBool => Bound(ctrl_type.as_bool()),
HalfWidth => Bound(ctrl_type.half_width().expect("invalid type for half_width")), HalfWidth => Bound(ctrl_type.half_width().expect("invalid type for half_width")),
DoubleWidth => Bound( DoubleWidth => Bound(

View File

@@ -44,10 +44,17 @@ impl Type {
if self.0 < VECTOR_BASE { if self.0 < VECTOR_BASE {
self self
} else { } else {
Type(LANE_BASE | (self.0 & 0x0f)) Self(LANE_BASE | (self.0 & 0x0f))
} }
} }
/// The type transformation that returns the lane type of a type variable; it is just a
/// renaming of lane_type() to be used in context where we think in terms of type variable
/// transformations.
pub fn lane_of(self) -> Self {
self.lane_type()
}
/// Get log_2 of the number of bits in a lane. /// Get log_2 of the number of bits in a lane.
pub fn log2_lane_bits(self) -> u8 { pub fn log2_lane_bits(self) -> u8 {
match self.lane_type() { match self.lane_type() {