Skip to main content

Crate fishstringer_slang_parse

Crate fishstringer_slang_parse 

Source
Expand description

The Slang front end for Unpopped.

FishStringer owns Slang in the CireSnave ecosystem (it moved here from Vulkane’s vulkane-slang-parse), so the language’s parser lives here (the emitter is fishstringer-slang-emit). Unpopped keeps the language-neutral half: Frontend and the lift_* walkers in unpopped::convert, which this crate feeds with a grammar binding, exactly as baracuda-cuda-parse does for CUDA.

  • parse_slang - Slang source to an error-tolerant tree-sitter CST.
  • SLANG_RESIDUE - constructs refused as inexpressible (shared memory, barriers, atomics).
  • SLANG - the Frontend: numthreads kernels with output / input{K} buffers. The buffer names are not a style choice: out and in are HLSL keywords.
use unpopped::convert::lift_elementwise;
use unpopped_vocab::ElementKind;
use fishstringer_slang_parse::SLANG;

let src = "StructuredBuffer<float> input0;\n\
    RWStructuredBuffer<float> output;\n\
    [numthreads(256, 1, 1)]\n\
    void copy(uint3 tid : SV_DispatchThreadID) { uint i = tid.x; output[i] = input0[i]; }";
let lifted = lift_elementwise(&SLANG, src, "copy", &[ElementKind::F32]).unwrap();
assert_eq!(lifted.n_inputs, 1);

The grammar crate (tree-sitter-slang) is named in exactly one place, parse_slang. Moved here from unpopped::convert (Unpopped 213df4f, v0.34.11); see THIRD-PARTY-NOTICES.md.

Constants§

SLANG
Slang: numthreads compute kernels, output/input{K} buffers.
SLANG_RESIDUE
Slang constructs that aren’t IR-expressible - group-shared memory, barriers, atomics.

Functions§

parse_slang
Parse Slang source into a tree-sitter CST.