Commit graph

223568 commits

Author SHA1 Message Date
Faith Ekstrand
cd679dbc5d kraid: Support signless IAdd
Signed and unsigned types are only allowed for IADD and not IADD_IMM so
it's simpler if we support signless for regular IADD.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
1ad7ddf076 kraid: Claim we use 64 registers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
f6ed151807 kraid: Implement OpCSel and nir_op_[ui]min/max
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
247e561445 kraid: Clean up the data type mess in the encoder
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
d5a92e5322 kraid/isa: Emit TryFrom<DataType> for all data-type-like enums
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
ac4d8d31ab kraid/isa: Add a special case in to_snake/camel_case() for data types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
2d849e184c kraid: Use instruction info to implement op_is_message()
This was a lot of plumbing but now we know for sure 100% of the time.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
e644edab7a kraid: Break v9 instruction encoding out into traits
This is modeled, again, after what we're doing in NAK.  The new traits
also allow us to query instruction info from the ISA XML.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:27 +00:00
Faith Ekstrand
afb7fb0287 krai/isa: Expose a new InstructionInfo struct per-instruction
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
c8cd650898 kraid: Implement integer comparisons
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
7e6993a72f kraid: Implement shifts and logic ops
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
d771ba7908 kraid: Add a very dumb message slot assignment pass
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
60c3690165 kraid: Add a lower_small_constants() pass
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
80ef2aa42e kraid: Add a SmallConstant struct and a Model::small_constants() hook
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
4c1d579db4 kraid/isa: Specially handle small_constant_t
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
348fd5d3e0 kraid: Add the start of a v9 encoder
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
0a4cd88f67 kraid/isa: Add support for field modifiers
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
b5147b070c kraid/isa: Add an encoder for instructions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
c2be5255e5 kraid/isa: Add an encoder for expressiosn
These are parsed into a tree and then the resulting tree implements
ToTokens so we can tokenize it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
eeae8938cf kraid/isa: Generate enums with [Try]Encode/Decode
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
052a758cfb kraid/isa: Add a simple XML parser
The xml crate doesn't provide a DOM but it makes everything easier to
have one so let's hand-roll a super simple DOM for the ISA XML.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
99dd4d269f kraid: Add the start of encoder code-gen
This is structured both as a proc macro and as a stand-alone executable.
This gives us options for how we want to actually dispatch it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
cec49c3654 kraid: Add ISA XML for v9-15
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
3557f69ded subprojects: Pull in the Rust xml crate
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
237b648d88 kraid: Move proc/lib.rs to proc/macros.rs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
7a1ee1b66f kraid: Replace OpEnd with OpNop.end
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
688bcea2ba kraid: Add a FlowCtrl struct
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
19e19f2dc8 kraid: Copy the bitview module from nouveau
This should go somewhere common eventually.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
0af201122b kraid: Print ASM swizzles when we have them
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
16d3ad1820 kraid: Rework swizzles
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
1631ebbc5a kraid: Plumb through Model::encode_shader()
Of course, we can't actually encode anything yet but this gives us the
model hook and deals with the util_dynarray so that everything inside
the model hook is safe code.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
11ceef9295 kraid: Add a super simple register allocator
This RA will do okay for large flat blocks and should either assert or
correctly allocate.  However, it's nowhere near a real allocator.  It's
just enough to get us off the ground.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
0542a2870e kraid: Add a validator to check IR invariants
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
b4ac98fa25 Kraid: re-indent shaders for prettier printing
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
03b206ec41 kraid: Handle a few NIR intrinsics
This is just enough to have working SSBOs.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
00e2afdbb9 kraid: Implement nir_op_iadd
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
b2adfd28e9 kraid: Add some float alu ops
This also sets up the rest of the ALU op infrastructure, including
handling source swizzles coming in from NIR.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
2febabbd3c kraid: Handle nir_op_mov/vec/[un]pack
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
765b89ed2e kraid: Handle load_const instructions
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
6cbdc95f2a kraid: Parse the NIR CFG
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
102795ce74 kraid: Start parsing NIR shaders
The parser doesn't actually do anything yet but now we have a framework
we can add stuff to.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
f8a4b912d0 kraid: Add a builder
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
45c7868e39 kraid: Add Instr, BasicBlock, and Shader structs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
e07f0b567c kraid: Add an Opcode trait and Op enum
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
3de388f652 kraid: Add Src/Dst data types
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
eaead919d5 kraid: Add SSAValue and SSARef structs
These is based on NAK but modified for what we need on Mali.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
292ec991a0 kraid: Add a swizzle struct
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
326c7b4382 kraid: Add DataType and NumericType enums
Most of the implementation of DataType is in a proc macro so we can walk
over all the variants programatically instead of having to hand-type a
bunch of potentially error-prone code.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
9b33ba5a73 kraid: Add a GPU model abstraction
This is sort of our version of pan_model.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:26 +00:00
Faith Ekstrand
d88b53075a panfrost: Add the basis for the new Kraid compiler
This adds some mostly empty rust files, bindings, meson bits, and a call
into kraid from the bifrost compiler, guarded by PAN_USE_KRAID=1.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
2026-06-02 21:19:25 +00:00