[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:
Sam Parker
2022-07-07 20:54:39 +01:00
committed by GitHub
parent 9ae060a12a
commit 9c43749dfe
69 changed files with 2422 additions and 294 deletions

View File

@@ -15,40 +15,43 @@ use std::u16;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Token<'a> {
Comment(&'a str),
LPar, // '('
RPar, // ')'
LBrace, // '{'
RBrace, // '}'
LBracket, // '['
RBracket, // ']'
Minus, // '-'
Plus, // '+'
Comma, // ','
Dot, // '.'
Colon, // ':'
Equal, // '='
Not, // '!'
Arrow, // '->'
Float(&'a str), // Floating point immediate
Integer(&'a str), // Integer immediate
Type(types::Type), // i32, f32, b32x4, ...
Value(Value), // v12, v7
Block(Block), // block3
Cold, // cold (flag on block)
StackSlot(u32), // ss3
GlobalValue(u32), // gv3
Heap(u32), // heap2
Table(u32), // table2
JumpTable(u32), // jt2
Constant(u32), // const2
FuncRef(u32), // fn2
SigRef(u32), // sig2
UserRef(u32), // u345
Name(&'a str), // %9arbitrary_alphanum, %x3, %0, %function ...
String(&'a str), // "arbitrary quoted string with no escape" ...
HexSequence(&'a str), // #89AF
Identifier(&'a str), // Unrecognized identifier (opcode, enumerator, ...)
SourceLoc(&'a str), // @00c7
LPar, // '('
RPar, // ')'
LBrace, // '{'
RBrace, // '}'
LBracket, // '['
RBracket, // ']'
Minus, // '-'
Plus, // '+'
Multiply, // '*'
Comma, // ','
Dot, // '.'
Colon, // ':'
Equal, // '='
Not, // '!'
Arrow, // '->'
Float(&'a str), // Floating point immediate
Integer(&'a str), // Integer immediate
Type(types::Type), // i32, f32, b32x4, ...
DynamicType(u32), // dt5
Value(Value), // v12, v7
Block(Block), // block3
Cold, // cold (flag on block)
StackSlot(u32), // ss3
DynamicStackSlot(u32), // dss4
GlobalValue(u32), // gv3
Heap(u32), // heap2
Table(u32), // table2
JumpTable(u32), // jt2
Constant(u32), // const2
FuncRef(u32), // fn2
SigRef(u32), // sig2
UserRef(u32), // u345
Name(&'a str), // %9arbitrary_alphanum, %x3, %0, %function ...
String(&'a str), // "arbitrary quoted string with no escape" ...
HexSequence(&'a str), // #89AF
Identifier(&'a str), // Unrecognized identifier (opcode, enumerator, ...)
SourceLoc(&'a str), // @00c7
}
/// A `Token` with an associated location.
@@ -341,6 +344,8 @@ impl<'a> Lexer<'a> {
"v" => Value::with_number(number).map(Token::Value),
"block" => Block::with_number(number).map(Token::Block),
"ss" => Some(Token::StackSlot(number)),
"dss" => Some(Token::DynamicStackSlot(number)),
"dt" => Some(Token::DynamicType(number)),
"gv" => Some(Token::GlobalValue(number)),
"heap" => Some(Token::Heap(number)),
"table" => Some(Token::Table(number)),
@@ -482,6 +487,7 @@ impl<'a> Lexer<'a> {
Some('=') => Some(self.scan_char(Token::Equal)),
Some('!') => Some(self.scan_char(Token::Not)),
Some('+') => Some(self.scan_number()),
Some('*') => Some(self.scan_char(Token::Multiply)),
Some('-') => {
if self.looking_at("->") {
Some(self.scan_chars(2, Token::Arrow))