|
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... | |
| struct | loomc_compile_artifact_options_t |
| Complete target-artifact compilation 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. | |
| loomc_status_t | loomc_compile_artifact (loomc_compiler_t *compiler, loomc_workspace_t *workspace, const loomc_pass_program_t *pass_program, loomc_module_t *module, const loomc_compile_artifact_options_t *options, loomc_allocator_t allocator, loomc_result_t **out_result) |
| Compiles one mutable module through final target artifact emission. | |
| loomc_status_t | loomc_compile_request (loomc_compiler_t *compiler, loomc_workspace_t *workspace, const loomc_pass_program_t *pass_program, const loomc_request_t *request, const loomc_compile_options_t *options, loomc_allocator_t allocator, loomc_product_t **out_product, loomc_result_t **out_result) |
| Compiles one immutable leaf request into a compiler product. | |
| const loomc_product_descriptor_t * | loomc_compiled_module_product_descriptor (void) |
| Returns the process-local descriptor for products from loomc_compile_request. | |
| 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_artifact | ( | loomc_compiler_t * | compiler, |
| loomc_workspace_t * | workspace, | ||
| const loomc_pass_program_t * | pass_program, | ||
| loomc_module_t * | module, | ||
| const loomc_compile_artifact_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_result_t ** | out_result ) |
Compiles one mutable module through final target artifact emission.
The operation verifies and configures the input, resolves and materializes one core compile request, executes one pass program, and emits through the request's selected target emitter. Diagnostics and all primary or sidecar artifacts share one result and preserve operation order.
| compiler | Prepared compiler whose context owns module. |
| workspace | Invocation-local scratch workspace. |
| pass_program | Optional prepared pass program. NULL selects the target emitter's default prepared-low pipeline. Pass an explicitly empty prepared program to perform no compiler transformations. |
| module | Mutable input module. Root materialization and compilation may replace or rewrite its internal IR while preserving the public handle. |
| options | Complete artifact options, or NULL for inferred roots, authored targets, empty configuration, and canonical emission. |
| allocator | Host allocator used for result and default-pipeline state. |
| out_result | Receives one retained result for the complete operation. |
| 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_compile_request | ( | loomc_compiler_t * | compiler, |
| loomc_workspace_t * | workspace, | ||
| const loomc_pass_program_t * | pass_program, | ||
| const loomc_request_t * | request, | ||
| const loomc_compile_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_product_t ** | out_product, | ||
| loomc_result_t ** | out_result ) |
Compiles one immutable leaf request into a compiler product.
The request source is deserialized into workspace and compiled with the same pass program and invocation options as loomc_compile_module. The returned product owns the emitted artifact views and preserves request-root order as its exported-root order. It has no unresolved requirements.
This is the synchronous leaf operation used by a composing host after a cache miss. Cache hits bypass the operation entirely. Selecting the pass program remains the host's responsibility. Requests requiring this operation carry loomc_compiled_module_product_descriptor() as their process-local product contract without a target-kind enum.
| compiler | Prepared compiler. |
| workspace | Invocation-local scratch workspace. |
| pass_program | Prepared pass program selected for the request roots. |
| request | Immutable independently compilable request. |
| options | Compile invocation options, or NULL for defaults. |
| allocator | Host allocator used for the returned product and result. |
| out_product | Receives a retained product when the result succeeds; receives NULL when the result fails. |
| out_result | Receives a retained result for the operation. |
| const loomc_product_descriptor_t * loomc_compiled_module_product_descriptor | ( | void | ) |
Returns the process-local descriptor for products from loomc_compile_request.
| 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. |