[libre-riscv-dev] variable length vector types in shader compiler for Kazan

Jacob Lifshay programmerjake at gmail.com
Tue Oct 9 03:45:21 BST 2018


I'm currently creating a wrapper for LLVM to make it easier to port the
rest of the shader compiler to use different versions of LLVM and possibly
to use a different JIT compiler backend like GCC's jit or cranelift as well
as isolating backend-specific oddities like LLVM not having a built-in bool
type (they use a 1-bit integer for that, leading to messiness when loading
or storing) and LLVM not currently having a vector reduce instruction.

As part of creating the wrapper, I am creating the code used for creating
vector types. This is what I have so far:

/// length of a vector
pub enum VectorLength {
    /// fixed length vector
    Fixed {
        /// length in elements
        length: u32,
    },
    /// variable length vector
    Variable {
        /// base length in elements which the runtime vector length is a
multiple of
        base_length: u32,
    },
}
// <snip>
/// trait for building types
pub trait TypeBuilder<'a> {
    // <snip>
    /// build a vector
    fn build_vector(&self, element: Self::Type, length: VectorLength) ->
Self::Type;
}

I tried to design it based off of the in-progress ARM SVE implementation
for LLVM as that appears to be what LLVM might settle on.
Meanwhile, the backends can select the variable vector length multiplier
statically and then switch to dynamic lengths when LLVM's implementation
lands.

Comments welcome.

Jacob


More information about the libre-riscv-dev mailing list