|
Loom C API
Public Loom compiler C API
|
Prepared compilers and module compilation. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_compiler_options_t |
| Compiler creation options. More... | |
| struct | loomc_compile_options_t |
| Compile invocation options. More... | |
Typedefs | |
| typedef struct loomc_compiler_t | loomc_compiler_t |
| Prepared immutable compiler. | |
| typedef uint32_t | loomc_compile_artifact_flags_t |
| Bitmask of loomc_compile_artifact_flag_bits_t. | |
Enumerations | |
| enum | loomc_compile_artifact_flag_bits_t { LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_TEXT = 1u << 0 , LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_BYTECODE = 1u << 1 , LOOMC_COMPILE_ARTIFACT_FLAG_REPORT_JSON = 1u << 2 , LOOMC_COMPILE_ARTIFACT_FLAG_LAUNCH_CONFIG = 1u << 3 } |
| Compile artifact request bits. More... | |
Functions | |
| loomc_status_t | loomc_compiler_create (loomc_context_t *context, const loomc_compiler_options_t *options, loomc_allocator_t allocator, loomc_compiler_t **out_compiler) |
| Creates a prepared immutable compiler. | |
| loomc_status_t | loomc_compile_module (loomc_compiler_t *compiler, loomc_workspace_t *workspace, const loomc_pass_program_t *pass_program, loomc_module_t *module, const loomc_compile_options_t *options, loomc_allocator_t allocator, loomc_result_t **out_result) |
| Compiles a mutable module into in-memory artifacts. | |
| void | loomc_compiler_retain (loomc_compiler_t *compiler) |
| Retains a prepared compiler for another owner. | |
| void | loomc_compiler_release (loomc_compiler_t *compiler) |
| Releases a prepared compiler from one owner. | |
Prepared compilers and module compilation.
A prepared compiler owns validated compile-time configuration and provider state. Compile invocations compose that compiler with a caller-selected prepared pass program, caller-owned workspace scratch, and a mutable module. Results return in-memory diagnostics, reports, and artifacts.
The core compile primitive accepts an already-formed loomc_module_t. Sources are deserialized into modules and indexes are linked into modules before compilation so each stage has independent options, diagnostics, and lifetime boundaries.
| typedef struct loomc_compiler_t loomc_compiler_t |
Prepared immutable compiler.
A compiler is intended to be created once and reused across many invocations. It must not require repeated filesystem access on the hot path. Pass pipelines are prepared as loomc_pass_program_t handles and selected per invocation.
Compile artifact request bits.
| Enumerator | |
|---|---|
| LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_TEXT | Return textual Loom module IR after successful compilation. |
| LOOMC_COMPILE_ARTIFACT_FLAG_MODULE_BYTECODE | Return binary Loom bytecode after successful compilation. |
| LOOMC_COMPILE_ARTIFACT_FLAG_REPORT_JSON | Return a JSON compile report artifact. Reports are emitted for completed invocations, including failed results that still returned diagnostics. |
| LOOMC_COMPILE_ARTIFACT_FLAG_LAUNCH_CONFIG | Return the compiled host launch-config program for all kernel entries. The selected pass program must lower source kernel entries through the normal source-to-low boundary. The artifact contains one pure function per exported kernel and is loaded with loomc_launch_config_program_load. |
| loomc_status_t loomc_compile_module | ( | loomc_compiler_t * | compiler, |
| loomc_workspace_t * | workspace, | ||
| const loomc_pass_program_t * | pass_program, | ||
| loomc_module_t * | module, | ||
| const loomc_compile_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_result_t ** | out_result ) |
Compiles a mutable module into in-memory artifacts.
| compiler | Prepared compiler. |
| workspace | Invocation-local scratch workspace. |
| pass_program | Prepared pass program selected for this invocation. |
| module | Module produced by deserialization, linking, or another module operation. The invocation borrows the module for the duration of the call and may rewrite its IR in place. |
| options | Compile invocation options, or NULL for defaults. |
| allocator | Host allocator used for result-owned storage. |
| out_result | Receives a retained result for the operation. |
| loomc_status_t loomc_compiler_create | ( | loomc_context_t * | context, |
| const loomc_compiler_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_compiler_t ** | out_compiler ) |
Creates a prepared immutable compiler.
| context | Context shared with modules compiled by this compiler. |
| options | Compiler configuration, or NULL for defaults. |
| allocator | Host allocator used for compiler-owned storage. |
| out_compiler | Receives one retained compiler on success. |
| void loomc_compiler_release | ( | loomc_compiler_t * | compiler | ) |
Releases a prepared compiler from one owner.
| compiler | Compiler to release. Passing NULL is allowed. |
| void loomc_compiler_retain | ( | loomc_compiler_t * | compiler | ) |
Retains a prepared compiler for another owner.
| compiler | Compiler to retain. |