[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

@@ -256,6 +256,8 @@
(extern const $F32X4 Type)
(extern const $F64X2 Type)
(extern const $I32X4XN Type)
;; Get the bit width of a given type.
(decl pure ty_bits (Type) u8)
(extern constructor ty_bits ty_bits)
@@ -290,6 +292,10 @@
(decl fits_in_32 (Type) Type)
(extern extractor fits_in_32 fits_in_32)
;; An extractor that only matches types that can fit in 32 bits.
(decl lane_fits_in_32 (Type) Type)
(extern extractor lane_fits_in_32 lane_fits_in_32)
;; An extractor that only matches types that can fit in 64 bits.
(decl fits_in_64 (Type) Type)
(extern extractor fits_in_64 fits_in_64)
@@ -433,6 +439,21 @@
(decl multi_lane (u32 u32) Type)
(extern extractor multi_lane multi_lane)
;; Match a dynamic-lane type, extracting (# bits per lane) from the given
;; type.
(decl dynamic_lane (u32 u32) Type)
(extern extractor dynamic_lane dynamic_lane)
;; Match a dynamic-lane integer type, extracting (# bits per lane) from the given
;; type.
(decl dynamic_int_lane (u32) Type)
(extern extractor dynamic_int_lane dynamic_int_lane)
;; Match a dynamic-lane floating point type, extracting (# bits per lane)
;; from the given type.
(decl dynamic_fp_lane (u32) Type)
(extern extractor dynamic_fp_lane dynamic_fp_lane)
;; Match the instruction that defines the given value, if any.
(decl def_inst (Inst) Value)
(extern extractor def_inst def_inst)
@@ -727,12 +748,20 @@
(extern extractor abi_no_ret_arg abi_no_ret_arg)
;; Size of the argument area.
(decl abi_stack_arg_space (ABISig) i64)
(extern constructor abi_stack_arg_space abi_stack_arg_space)
(decl abi_sized_stack_arg_space (ABISig) i64)
(extern constructor abi_sized_stack_arg_space abi_sized_stack_arg_space)
;; Size of the return-value area.
(decl abi_stack_ret_space (ABISig) i64)
(extern constructor abi_stack_ret_space abi_stack_ret_space)
(decl abi_sized_stack_ret_space (ABISig) i64)
(extern constructor abi_sized_stack_ret_space abi_sized_stack_ret_space)
;; StackSlot addr
(decl abi_stackslot_addr (WritableReg StackSlot Offset32) MInst)
(extern constructor abi_stackslot_addr abi_stackslot_addr)
;; DynamicStackSlot addr
(decl abi_dynamic_stackslot_addr (WritableReg DynamicStackSlot) MInst)
(extern constructor abi_dynamic_stackslot_addr abi_dynamic_stackslot_addr)
;; Extractor to detect the special case where an argument or
;; return value only requires a single slot to be passed.