|
Loom C API
Public Loom compiler C API
|
The loomc library is the public C ABI for embedding the Loom compiler in native language drivers, JITs, autotuners, packaging tools, and caller-owned artifact caches. The API is shaped around in-memory sources, reusable compiler/linker/index handles, caller-owned workspaces, structured diagnostics, and in-memory artifacts.
Core loomc headers expose C types defined by the Loom API. Optional target and runtime integration headers adapt to host ecosystems such as HSA, Vulkan, and IREE HAL without making those ecosystems part of the core ABI.
The narrow embedding shape is #include <loomc/loomc.h> plus the target package that produces the artifact your runtime loads. The core package keeps source, link, compile, emit, result, diagnostic, and artifact ownership independent from any GPU runtime.
| Package or header | Provides | External headers |
|---|---|---|
| //loom/binding/c:loomc, loomc/loomc.h | Core source, module, linker, compiler, target, result, diagnostic, and artifact APIs. | None beyond the C/C++ runtime headers used by the public ABI. |
| loomc/iree.h | Header-only adapters between Loom status/allocator/string types and IREE base types. | IREE base headers. |
| //loom/binding/c/target/amdgpu, loomc/target/amdgpu.h | AMDGPU target environment, processor profiles, and HSACO emission. | No HSA, HIP, ROCm, or IREE HAL headers. |
| //loom/binding/c/target/spirv, loomc/target/spirv.h | SPIR-V target environment, profiles, and SPIR-V emission. | No Vulkan or IREE HAL headers. |
| //loom/binding/c/target/spirv/vulkaninfo, loomc/target/spirv/vulkaninfo.h | Saved Vulkan/GPUInfo profile import for offline or cached SPIR-V targeting. | No Vulkan loader or Vulkan SDK headers. |
| //loom/binding/c/target/spirv/vulkan, loomc/target/spirv/vulkan.h | Raw Vulkan device/profile adapter for SPIR-V targeting. | Vulkan headers; the caller owns the loader, physical device, and function table. |
| //loom/binding/c/target/iree_hal, loomc/target/iree_hal.h | Runtime target routing from IREE HAL devices into Loom target profiles. | IREE HAL headers. |
| //loom/binding/c/target/spirv/iree_hal, loomc/target/spirv/iree_hal.h | SPIR-V targeting through IREE HAL Vulkan device information. | IREE HAL headers. |
| //loom/binding/c:loomc_full | Convenience package for the current core, SPIR-V, Vulkan, VulkanInfo, and IREE HAL binding slice. | The union of the headers above for that slice. |
loomc_full is a packaging convenience for environments that already accept the broader dependency surface. Tight runtime integrations usually link //loom/binding/c:loomc and the one target package they need. The AMDGPU path is intentionally a separate package today so raw HSA/HRX-style integrations can embed Loom without pulling in Vulkan or IREE HAL.
Installed headers keep the same component shape under loomc/. Static and dynamic library packaging should preserve that boundary: link the core Loom C API plus selected target packages for dependency-light embeddings, or link the full convenience package when the application already carries the SPIR-V, Vulkan, and IREE HAL dependency set. Runtime loader libraries remain an application choice; raw HSA and raw Vulkan examples load/query those runtimes outside of loomc.
Loom's embedding pipeline is filesystem-optional. File constructors and artifact write helpers exist for command line tools, caches, and release packaging, but a JIT can keep every important edge in process memory:
That shape supports both offline and online specialization. An application can pre-link authored libraries into .loombc, then at runtime create a tiny generated source containing a kernel.def, constants, or dispatch parameters, link it against the frozen library index, and emit a target artifact without round-tripping through temporary files.
The C API uses explicit reference ownership so C++, Rust, Python, and other bindings can present their native lifetime model without changing the compiler contract.
The examples under loom/binding/c/example/ are intentionally small end-to-end embedding programs:
The public headers are the primary API documentation. Contributor conventions for those comments live in loom/binding/c/doc/STYLE_GUIDE.md.