Agent skill

Llvm Spirv

by LuisaGroup in LuisaGroup/LuisaCompute

Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path.

Apache-2.0Auto-check passed

Install Llvm Spirv

skills CLI
$ npx skills add LuisaGroup/LuisaCompute --skill llvm-spirv -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install LuisaGroup/LuisaCompute llvm-spirv --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/LuisaGroup/LuisaCompute.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.agents/skills/llvm-spirv .claude/skills/llvm-spirv && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
llvm-spirv
GitHub stars
1.1k
Token cost
~2.8k tokens
SKILL.md length
1,305 words
Files
1
Skills in repo
12
Repo updated
First seen
Licence
Apache-2.0

At a glance

Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path.

  • Works in 8 steps: Create a fresh LLVM… → Initialize a spirv64-unknown-vulkan1.2… → Detect prospective bindless/property… → …
  • SKILL.md covers Current support boundary, Source map, Compilation pipeline and Function and control-flow rules, plus 6 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Llvm Spirv is an agent skill from LuisaGroup/LuisaCompute. Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path.

Its SKILL.md is about 2.8k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It works with C++. The repository describes itself as: High-Performance Rendering Framework on Stream Architectures. The licence is Apache-2.0.

Example prompts

  • “/llvm-spirv”

Workflow steps

8 steps, taken from the first numbered list in SKILL.md.

  1. Create a fresh LLVM context/module/builder and register LLVM's SPIR-V target
  2. Initialize a spirv64-unknown-vulkan1.2 target machine and its data layout.
  3. Detect prospective bindless/property usage from the AST, validate the
  4. Lower the kernel and reachable callables to LLVM IR. A compute entry is
  5. Before target emission, recursively scalarize aggregate loads/stores,
  6. Emit object bytes through LLVM's legacy pass manager. The expected output
  7. Strip LLVM's Addresses/Linkage capabilities and linkage decorations,
  8. Validate the returned module with SPIRV-Tools under

What it can do on your machine

Read from SKILL.md and the folder at commit 0c84a1a. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are cpp).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Llvm Spirv loads about 2.8k tokens when it runs. Until then it costs about 38 tokens; SKILL.md has 1,305 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~38
When it runs · the whole SKILL.md, loaded when a task matches
~2.8k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from LuisaGroup/LuisaCompute at commit 0c84a1a, republished under its Apache-2.0 licence (© LuisaGroup). 1,305 words, ~2,766 tokens.

Download SKILL.mdSave it as .claude/skills/llvm-spirv/SKILL.md (or your agent's skills folder).
name
llvm-spirv
description
Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path.

LLVM SPIR-V Codegen

The experimental backend lives in src/backends/common/spirv_llvm/. It lowers a Luisa AST Function to LLVM IR and asks LLVM's native SPIR-V target to emit a spirv64-unknown-vulkan1.2 module.

This is not the native XIR-to-SPIR-V path. The two Vulkan codegen selections are mutually exclusive:

  • CMake: LUISA_COMPUTE_ENABLE_VK_AST_LLVM_SPIRV=ON and LUISA_COMPUTE_ENABLE_VK_XIR_SPIRV=OFF;
  • XMake: lc_vk_backend_use_ast_llvm_spirv=true, with lc_llvm_path pointing to an LLVM installation/build prefix or its llvm-config.

The public entry is deliberately LLVM-header-free:

cpp
#include <spirv_llvm/spirv_llvm.h>

auto result = lc::llvm_codegen::compile_spirv(kernel, option);

Do not expose an LLVM type through spirv_llvm.h or llvm_codegen_result.h; consumers of the static facade must not inherit LLVM include directories or unrelated LLVM preprocessor definitions.

Current support boundary

The Vulkan descriptor interface is preflighted before AST lowering by validate_llvm_vulkan_resource_model. At present it rejects:

  • every kernel argument, including ordinary value arguments and direct buffers;
  • textures, bindless arrays, acceleration structures, custom/indirect resources, and their global heaps;
  • shader printing.

Consequently the current end-to-end Vulkan contract is intentionally narrow: no-argument, no-print compute kernels whose operations are implemented by the visitor. The successful interface contains only the fixed 16-entry immutable sampler property. Do not describe the visitor's partial resource stubs as runtime support, and do not bypass this preflight merely because LLVM happens to emit some SPIR-V for an address-space global.

Unsupported AST operations call LUISA_NOT_IMPLEMENTED or otherwise fail closed. Returning zero, undef, or a no-op is not an acceptable way to claim support. When expanding the backend, implement the LLVM IR lowering, extend the property preflight, validate the Vulkan runtime binding shape, and add an end-to-end SPIR-V validator test together.

Source map

FilesResponsibility
spirv_llvm.h/.cppLLVM-free facade and once-only SPIR-V target registration
llvm_codegen_result.hSPIR-V words, properties, printer records, and global bindless flags returned to Vulkan
llvm_codegen_stack_data.h/.cppPer-compilation state and mutex-protected reusable state pool
llvm_codegen_utility.h/.cppType/constant/function lowering, module legalization, target-machine emission, post-processing, and validation
llvm_state_visitor.h/.cppAST expression and statement lowering through llvm::IRBuilder<>
llvm_compat.hAPI-detection boundary for LLVM-version differences such as nullable terminator lookup
vulkan_binding_properties.hPure property planner and fail-closed resource-model support check
CMakeLists.txt / xmake.luaComponent-aware LLVM discovery and static-facade linkage

Compilation pipeline

LLVMCodegenUtility::CompileSPIRV owns the complete path:

  1. Create a fresh LLVM context/module/builder and register LLVM's SPIR-V target exactly once with std::call_once.
  2. Initialize a spirv64-unknown-vulkan1.2 target machine and its data layout.
  3. Detect prospective bindless/property usage from the AST, validate the current Vulkan resource-model boundary, and freeze the property plan before visiting the AST.
  4. Lower the kernel and reachable callables to LLVM IR. A compute entry is named main, has no function parameters, and carries hlsl.shader=compute plus hlsl.numthreads attributes.
  5. Before target emission, recursively scalarize aggregate loads/stores, lower aggregate returns to void plus an out pointer, scalarize again, and verify the LLVM module.
  6. Emit object bytes through LLVM's legacy pass manager. The expected output is raw SPIR-V words; an ELF result is not silently accepted as valid SPIR-V and will fail the final validator (there is no ELF section extractor yet).
  7. Strip LLVM's Addresses/Linkage capabilities and linkage decorations, and convert OpPtrAccessChain forms to their logical-addressing counterparts.
  8. Validate the returned module with SPIRV-Tools under SPV_ENV_VULKAN_1_2.

Unlike the native path, this backend currently has no SPIRV-Tools optimizer stage and does not produce the native exact per-argument role plan. Vulkan serializes it as LLVM_SPIRV, embeds constants directly in the module, and uses the backend's conservative SPIR-V artifact feature requirements.

Function and control-flow rules

  • Vulkan entry points have no LLVM function parameters. The current code has provisional global-variable lowering for arguments, but the property preflight rejects those kernels until a real descriptor ABI exists.
  • Callable arguments remain LLVM function parameters.
  • Save and restore the builder insertion point, current function, and variable map around recursive callable generation.
  • Probe incomplete blocks through llvm_compat.h::terminator_or_null; do not guess the API from an LLVM major version.
  • Verify the full module before invoking LLVM target passes. Per-function verification warnings are useful during construction but do not replace the module check.
  • Aggregate legalization is mandatory because the LLVM SPIR-V target cannot reliably legalize the aggregate memory/return forms produced here.

Target initialization

InitializeLLVMSPIRVTarget registers global LLVM state in dependency order:

cpp
LLVMInitializeSPIRVTargetInfo();
LLVMInitializeSPIRVTarget();
LLVMInitializeSPIRVTargetMC();
LLVMInitializeSPIRVAsmPrinter();

Use the declarations from <llvm/Support/TargetSelect.h>. Hand-written declarations can acquire the wrong language linkage. Keep the std::call_once guard because shader compilation may be concurrent.

The target triple is deliberately spirv64: the supported LLVM revision's spirv32 path fails in pointer-cast legalization. Vulkan logical addressing is restored by the checked post-processing step and then enforced by validation; raw EmitSPIRV() output is not the public contract.

Show full SKILL.md (587 more words)Show less

CMake integration

The target is luisa-compute-spirv-llvm. It is created only when Vulkan and LUISA_COMPUTE_ENABLE_VK_AST_LLVM_SPIRV are enabled. The Vulkan plugin also links luisa-compute-spirv, because the shared artifact codec still needs the native/common SPIR-V validation and feature-reconciliation utilities.

src/backends/common/spirv_llvm/CMakeLists.txt must:

  • find_package(LLVM CONFIG REQUIRED) without allowing LLVMConfig.cmake to overwrite the project's CMAKE_MSVC_RUNTIME_LIBRARY default;
  • require an exact SPIRV token in LLVM_TARGETS_TO_BUILD and locate llvm/IR/IntrinsicsSPIRV.h in LLVM's reported include directories;
  • keep LLVM includes and ordinary definitions private;
  • compile-check _GLIBCXX_USE_CXX11_ABI and propagate only that ABI macro through the C++ facade when LLVM reports it;
  • request core, support, bitwriter, transformutils, analysis, codegen, target, mc, spirvcodegen, spirvdesc, spirvinfo, and spirvanalysis through LLVM's component mapper;
  • use llvm_config(... USE_SHARED ...) when a monolithic LLVM target exists so target-specific archives omitted by the dylib remain linked;
  • reject incompatible Windows CRT families or Debug iterator modes, and stage and install a monolithic LLVM DLL when that is the selected import.

The facade is static, so implementation link dependencies must still reach the final Vulkan plugin/test link. Do not make LLVM headers public as a workaround for a link failure.

XMake integration

The target is lc-spirv-llvm. Configuration requires an explicit lc_llvm_path. Keep lc_vk_backend_use_xir_spirv=false when selecting it: the top-level configuration rejects an explicit conflict, while the option hook forces lc_enable_xir on and normalizes the native option off. The SPIR-V targets and tests are created only when the Vulkan backend itself is enabled.

Treat the selected llvm-config as the source of truth:

  • accept an executable path, install prefix, build prefix, or common source-tree build layout;
  • parse --quote-paths output with os.argv, including all -I paths from --cppflags so generated intrinsics headers in development trees are found;
  • require an exact SPIRV token from --targets-built;
  • query --shared-mode for the complete component set before selecting --link-shared or --link-static;
  • use static LLVM components on Windows because llvm-config reports DLL filenames rather than MSVC import libraries for shared mode;
  • propagate shared-library rpaths on Unix and the required component system libraries on every platform;
  • verify the libstdc++ ABI and, on Windows, the CRT family and Debug/non-Debug mode before compiling the facade.

Vulkan artifact boundary

The LLVM result reuses hlsl::Property and the common Vulkan artifact codec, but it is a distinct LLVM_SPIRV dialect:

  • do not apply native XIR capability reconciliation or exact accel-role rules to LLVM artifacts;
  • constants are embedded in SPIR-V, so there is no constant-UBO payload;
  • saved arguments use the legacy/unspecified resource-role sentinel;
  • loaded modules are still integrity-checked and Vulkan-validated before pipeline creation.

Tests

test_spirv_llvm_facade is registered only when the LLVM facade target exists. It compiles a no-argument kernel through the public header, checks the fixed sampler property, and independently validates/disassembles the returned module for Vulkan 1.2. test_vk_shader_binary_contract separately covers the common artifact boundary under the LUISA_AST_LLVM_TO_SPIRV dialect define.

When adding support, include at least:

  1. a pure property-preflight rejection/acceptance test;
  2. a public-facade compile test;
  3. independent SPV_ENV_VULKAN_1_2 validation;
  4. a Vulkan artifact round trip when properties or feature contracts change;
  5. a runtime Vulkan test before claiming descriptor or dispatch support.

Diagnostics and pitfalls

  • EmitSPIRV() writes llvm_ir_debug.ll in the process working directory.
  • Missing SPIR-V intrinsics or target components are configuration errors, not reasons to guess library filenames or add every LLVM archive.
  • getDeclarationIfExists() may return null. Handle that at the operation's semantic boundary; never call through a null intrinsic declaration.
  • Do not call EmitSPIRV() directly from Vulkan. Only the public facade runs required post-processing and Vulkan validation.
  • Do not report an AST opcode as supported merely because a visitor case exists; it must survive resource preflight, LLVM verification, SPIR-V emission, Vulkan validation, artifact loading, and runtime dispatch.

© LuisaGroup, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in .agents/skills/llvm-spirv of LuisaGroup/LuisaCompute.

Open the folder on GitHubat commit 0c84a1a

Compare with similar skills

Llvm Spirv next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Llvm Spirv compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Llvm Spirv this skillLuisaGroup/LuisaCompute1.1k—~2.8kAutomated safety check: PassApache-2.0
Paddle BuildPaddlePaddle/Paddle24k—~1kAutomated safety check: PassApache-2.0
Fory Releaseapache/fory4.6k—~2.9kAutomated safety check: PassApache-2.0
ONNX Runtime Shape Inference Safety Auditmicrosoft/onnxruntime22k—~3.3kAutomated safety check: PassMIT
Code Audit3stoneBrother/code-audit8931 repos~2.7kAutomated safety check: PassNone
Qt C++ Code Reviewx-tools-author/x-tools1.1k2 repos~4.3kAutomated safety check: PassBSD-3-Clause

Similar skills

  • Paddle Build

    PaddlePaddle/Paddle

    A skill your agent uses when needing to compile, rebuild, or install Paddle from source after code changes.

    24k GitHub stars~1k tokensUpdated 8 days ago
    AI & LLM EngineeringAuto-check passed
  • Fory Release

    apache/fory

    Prepare an Apache Fory release candidate from a clean release branch, including the version bump, RC tag, JVM staging, ASF source artifacts, SVN upload, and vote email.

    4.6k GitHub stars~2.9k tokensUpdated yesterday
    Auto-check passed
  • Official

    Finds and fixes out-of-range output writes in ONNX Runtime operator shape-inference functions where a getNumOutputs guard admits too few outputs.

    22k GitHub stars~3.3k tokensUpdated today
    SecurityAuto-check passed
  • Code Audit

    3stoneBrother/code-audit

    Professional code security audit skill covering 55+ vulnerability types.

    893 GitHub starsUsed in 1 repo~2.7k tokens
    SecurityAuto-check passed
  • Qt C++ Code Review

    x-tools-author/x-tools

    Read-only review of Qt6 C++ code that combines a deterministic lint script with six parallel analysis agents and reports only high-confidence issues.

    1.1k GitHub starsUsed in 2 repos~4.3k tokens
    DevelopmentAuto-check passed
  • Translation

    doxygen/doxygen

    Keeps all Doxygen and Doxywizard translations up to date across three mechanisms: translator C++ classes (src/translatorxx.h), Qt .ts locale files for the Doxywizard GUI (addon/doxywizard/i18n/)…

    6.6k GitHub stars~5.2k tokensUpdated 8 days ago
    Writing & ContentAuto-check passed

More from LuisaGroup/LuisaCompute

All 12 skills in this repo
  • Git

    LuisaGroup/LuisaCompute

    Show uncommitted changes and commit history via git. An agent skill from LuisaGroup/LuisaCompute.

    1.1k GitHub stars~544 tokensUpdated today
    Auto-check passed
  • Ast

    LuisaGroup/LuisaCompute

    Manual AST construction with FunctionBuilder for kernels and callables without DSL sugar.

    1.1k GitHub stars~4.2k tokensUpdated today
    Auto-check passed
  • Cmake

    LuisaGroup/LuisaCompute

    CMake build options, custom functions, and backend patterns for LuisaCompute.

    1.1k GitHub stars~2.4k tokensUpdated today
    Auto-check passed
  • Cpp Style

    LuisaGroup/LuisaCompute

    C++ naming, formatting, static analysis, and RTTI rules for LuisaCompute.

    1.1k GitHub stars~1.1k tokensUpdated today
    Auto-check passed
  • Debug

    LuisaGroup/LuisaCompute

    Debug crashes and test failures via stack-traces, host/device logging, and DSL buffer inspection.

    1.1k GitHub stars~2.3k tokensUpdated today
    Auto-check passed
  • Hlsl

    LuisaGroup/LuisaCompute

    HLSL code generation, StringBuilder patterns, builtin headers, and DXIL embedding.

    1.1k GitHub stars~1.6k tokensUpdated today
    Auto-check passed

Works with

Questions about Llvm Spirv

What does Llvm Spirv do?

Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path. Llvm Spirv is an agent skill from LuisaGroup/LuisaCompute. Experimental Vulkan AST-to-LLVM-to-SPIR-V backend, its fail-closed runtime-interface boundary, LLVM build integration, and validation path.

How do I install Llvm Spirv in Claude Code?

Run `npx skills add LuisaGroup/LuisaCompute --skill llvm-spirv -a claude-code`. Or copy the skill folder (.agents/skills/llvm-spirv in LuisaGroup/LuisaCompute) into .claude/skills/llvm-spirv in your project. Claude Code loads it when a task matches its description.

How do I install Llvm Spirv in Codex?

Run `npx skills add LuisaGroup/LuisaCompute --skill llvm-spirv -a codex`. Or copy the skill folder (.agents/skills/llvm-spirv in LuisaGroup/LuisaCompute) into .agents/skills/llvm-spirv in your project. Codex loads it when a task matches its description.

Can I use Llvm Spirv in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add LuisaGroup/LuisaCompute --skill llvm-spirv -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/llvm-spirv, .gemini/skills/llvm-spirv, .github/skills/llvm-spirv and .opencode/skills/llvm-spirv in your project.

What does Llvm Spirv need to run?

SKILL.md names no scripts, command-line tools or credentials: Llvm Spirv is instructions for the agent only.

Does Llvm Spirv access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Llvm Spirv safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Llvm Spirv use?

Llvm Spirv is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Llvm Spirv use?

About 2.8k tokens (SKILL.md is roughly 11k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Llvm Spirv?

Skills that share tags, products or a category with Llvm Spirv: Paddle Build (PaddlePaddle/Paddle, 24k stars), Fory Release (apache/fory, 4.6k stars), ONNX Runtime Shape Inference Safety Audit (microsoft/onnxruntime, 22k stars) and Code Audit (3stoneBrother/code-audit, 893 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Llvm Spirv?

LuisaGroup (a GitHub organization) maintains it in LuisaGroup/LuisaCompute, which has 1,051 GitHub stars. The repository holds 12 skills in this directory. The repository was last updated on October 8, 2026.

Source: LuisaGroup/LuisaCompute on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.