Files
wasmtime/cranelift/codegen/shared/src/constants.rs
Sam Parker 9c43749dfe [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.
2022-07-07 12:54:39 -07:00

29 lines
805 B
Rust

//! This module contains constants that are shared between the codegen and the meta crate, so they
//! are kept in sync.
// Numbering scheme for value types:
//
// 0: Void
// 0x01-0x6f: Special types
// 0x70-0x7d: Lane types
// 0x7e-0x7f: Reference types
// 0x80-0xff: Vector types
// 0x100-0x17f: Dynamic Vector types
//
// Vector types are encoded with the lane type in the low 4 bits and log2(lanes)
// in the next highest 4 bits, giving a range of 2-256 lanes.
// Dynamic vector types are encoded similarily.
/// Start of the lane types.
pub const LANE_BASE: u16 = 0x70;
/// Base for reference types.
pub const REFERENCE_BASE: u16 = 0x7E;
/// Start of the 2-lane vector types.
pub const VECTOR_BASE: u16 = 0x80;
/// Start of the dynamic vector types.
pub const DYNAMIC_VECTOR_BASE: u16 = 0x100;