[RFC] Dynamic Vector Support (#4200)
Introduce a new concept in the IR that allows a producer to create dynamic vector types. An IR function can now contain global value(s) that represent a dynamic scaling factor, for a given fixed-width vector type. A dynamic type is then created by 'multiplying' the corresponding global value with a fixed-width type. These new types can be used just like the existing types and the type system has a set of hard-coded dynamic types, such as I32X4XN, which the user defined types map onto. The dynamic types are also used explicitly to create dynamic stack slots, which have no set size like their existing counterparts. New IR instructions are added to access these new stack entities. Currently, during codegen, the dynamic scaling factor has to be lowered to a constant so the dynamic slots do eventually have a compile-time known size, as do spill slots. The current lowering for aarch64 just targets Neon, using a dynamic scale of 1. Copyright (c) 2022, Arm Limited.
This commit is contained in:
@@ -135,6 +135,44 @@ impl StackSlot {
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to a dynamic stack slot.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct DynamicStackSlot(u32);
|
||||
entity_impl!(DynamicStackSlot, "dss");
|
||||
|
||||
impl DynamicStackSlot {
|
||||
/// Create a new stack slot reference from its number.
|
||||
///
|
||||
/// This method is for use by the parser.
|
||||
pub fn with_number(n: u32) -> Option<Self> {
|
||||
if n < u32::MAX {
|
||||
Some(Self(n))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to a dynamic type.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
#[cfg_attr(feature = "enable-serde", derive(Serialize, Deserialize))]
|
||||
pub struct DynamicType(u32);
|
||||
entity_impl!(DynamicType, "dt");
|
||||
|
||||
impl DynamicType {
|
||||
/// Create a new dynamic type reference from its number.
|
||||
///
|
||||
/// This method is for use by the parser.
|
||||
pub fn with_number(n: u32) -> Option<Self> {
|
||||
if n < u32::MAX {
|
||||
Some(Self(n))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An opaque reference to a global value.
|
||||
///
|
||||
/// A `GlobalValue` is a [`Value`](Value) that will be live across the entire
|
||||
@@ -389,6 +427,10 @@ pub enum AnyEntity {
|
||||
Value(Value),
|
||||
/// A stack slot.
|
||||
StackSlot(StackSlot),
|
||||
/// A dynamic stack slot.
|
||||
DynamicStackSlot(DynamicStackSlot),
|
||||
/// A dynamic type
|
||||
DynamicType(DynamicType),
|
||||
/// A Global value.
|
||||
GlobalValue(GlobalValue),
|
||||
/// A jump table.
|
||||
@@ -415,6 +457,8 @@ impl fmt::Display for AnyEntity {
|
||||
Self::Inst(r) => r.fmt(f),
|
||||
Self::Value(r) => r.fmt(f),
|
||||
Self::StackSlot(r) => r.fmt(f),
|
||||
Self::DynamicStackSlot(r) => r.fmt(f),
|
||||
Self::DynamicType(r) => r.fmt(f),
|
||||
Self::GlobalValue(r) => r.fmt(f),
|
||||
Self::JumpTable(r) => r.fmt(f),
|
||||
Self::Constant(r) => r.fmt(f),
|
||||
@@ -457,6 +501,18 @@ impl From<StackSlot> for AnyEntity {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DynamicStackSlot> for AnyEntity {
|
||||
fn from(r: DynamicStackSlot) -> Self {
|
||||
Self::DynamicStackSlot(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<DynamicType> for AnyEntity {
|
||||
fn from(r: DynamicType) -> Self {
|
||||
Self::DynamicType(r)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<GlobalValue> for AnyEntity {
|
||||
fn from(r: GlobalValue) -> Self {
|
||||
Self::GlobalValue(r)
|
||||
|
||||
Reference in New Issue
Block a user