[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:
@@ -264,7 +264,7 @@ impl wasmtime_environ::Compiler for Compiler {
|
||||
|
||||
let length = u32::try_from(code_buf.len()).unwrap();
|
||||
|
||||
let stack_slots = std::mem::take(&mut context.func.stack_slots);
|
||||
let sized_stack_slots = std::mem::take(&mut context.func.sized_stack_slots);
|
||||
|
||||
self.save_context(CompilerContext {
|
||||
func_translator,
|
||||
@@ -275,7 +275,7 @@ impl wasmtime_environ::Compiler for Compiler {
|
||||
body: code_buf,
|
||||
relocations: func_relocs,
|
||||
value_labels_ranges: ranges.unwrap_or(Default::default()),
|
||||
stack_slots,
|
||||
sized_stack_slots,
|
||||
unwind_info,
|
||||
traps,
|
||||
info: FunctionInfo {
|
||||
@@ -613,7 +613,7 @@ impl Compiler {
|
||||
let values_vec_byte_size = u32::try_from(value_size * values_vec_len).unwrap();
|
||||
let values_vec_len = u32::try_from(values_vec_len).unwrap();
|
||||
|
||||
let ss = builder.func.create_stack_slot(ir::StackSlotData::new(
|
||||
let ss = builder.func.create_sized_stack_slot(ir::StackSlotData::new(
|
||||
ir::StackSlotKind::ExplicitSlot,
|
||||
values_vec_byte_size,
|
||||
));
|
||||
@@ -712,7 +712,7 @@ impl Compiler {
|
||||
body: code_buf,
|
||||
unwind_info,
|
||||
relocations: Vec::new(),
|
||||
stack_slots: Default::default(),
|
||||
sized_stack_slots: Default::default(),
|
||||
value_labels_ranges: Default::default(),
|
||||
info: Default::default(),
|
||||
address_map: Default::default(),
|
||||
|
||||
@@ -17,7 +17,7 @@ use wasmtime_environ::{DefinedFuncIndex, EntityRef};
|
||||
pub struct FunctionFrameInfo<'a> {
|
||||
pub value_ranges: &'a ValueLabelsRanges,
|
||||
pub memory_offset: ModuleMemoryOffset,
|
||||
pub stack_slots: &'a StackSlots,
|
||||
pub sized_stack_slots: &'a StackSlots,
|
||||
}
|
||||
|
||||
impl<'a> FunctionFrameInfo<'a> {
|
||||
@@ -1207,11 +1207,11 @@ mod tests {
|
||||
use wasmtime_environ::{DefinedFuncIndex, EntityRef};
|
||||
|
||||
let addr_tr = create_mock_address_transform();
|
||||
let stack_slots = StackSlots::new();
|
||||
let sized_stack_slots = StackSlots::new();
|
||||
let (value_ranges, value_labels) = create_mock_value_ranges();
|
||||
let fi = FunctionFrameInfo {
|
||||
memory_offset: ModuleMemoryOffset::None,
|
||||
stack_slots: &stack_slots,
|
||||
sized_stack_slots: &sized_stack_slots,
|
||||
value_ranges: &value_ranges,
|
||||
};
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ where
|
||||
let frame_info = FunctionFrameInfo {
|
||||
value_ranges: &func.value_labels_ranges,
|
||||
memory_offset: memory_offset.clone(),
|
||||
stack_slots: &func.stack_slots,
|
||||
sized_stack_slots: &func.sized_stack_slots,
|
||||
};
|
||||
Some(frame_info)
|
||||
} else {
|
||||
|
||||
@@ -42,8 +42,9 @@ pub struct CompiledFunction {
|
||||
|
||||
relocations: Vec<Relocation>,
|
||||
value_labels_ranges: cranelift_codegen::ValueLabelsRanges,
|
||||
stack_slots: ir::StackSlots,
|
||||
sized_stack_slots: ir::StackSlots,
|
||||
|
||||
// TODO: Add dynamic_stack_slots?
|
||||
info: FunctionInfo,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user