|
Loom C API
Public Loom compiler C API
|
Prepared pass programs. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_pass_report_options_t |
| Requests a result-owned JSON report of executed passes. More... | |
| struct | loomc_pass_program_options_t |
| Pass program creation options. More... | |
| struct | loomc_pass_run_options_t |
| Options for executing one prepared pass program. More... | |
Macros | |
| #define | LOOMC_ARTIFACT_FORMAT_PASS_REPORT_JSON "loom-pass-report-json" |
| Structured pass invocation report artifact format. | |
Typedefs | |
| typedef struct loomc_pass_program_t | loomc_pass_program_t |
| Prepared immutable pass program. | |
| typedef uint32_t | loomc_pass_report_flags_t |
| Bitmask of loomc_pass_report_flag_bits_e. | |
Enumerations | |
| enum | loomc_pass_report_flag_bits_e { LOOMC_PASS_REPORT_FLAG_TIMING = 1u << 0 } |
| Pass report observation flags. More... | |
Functions | |
| loomc_status_t | loomc_pass_program_create_empty (loomc_context_t *context, const loomc_pass_program_options_t *options, loomc_allocator_t allocator, loomc_pass_program_t **out_pass_program) |
| Creates a prepared no-op pass program. | |
| loomc_status_t | loomc_pass_program_create_from_pipeline_text (loomc_context_t *context, loomc_string_view_t pipeline_text, const loomc_pass_program_options_t *options, loomc_allocator_t allocator, loomc_pass_program_t **out_pass_program, loomc_result_t **out_result) |
| Creates a prepared pass program from a shallow textual pass list. | |
| loomc_status_t | loomc_pass_program_create_from_module_symbol (const loomc_module_t *module, loomc_string_view_t pipeline_symbol, const loomc_pass_program_options_t *options, loomc_allocator_t allocator, loomc_pass_program_t **out_pass_program, loomc_result_t **out_result) |
| Creates a prepared pass program from a named pass.pipeline symbol. | |
| void | loomc_pass_program_retain (loomc_pass_program_t *pass_program) |
| Retains a pass program for another owner. | |
| void | loomc_pass_program_release (loomc_pass_program_t *pass_program) |
| Releases a pass program from one owner. | |
| loomc_status_t | loomc_pass_program_print_text_to_source (const loomc_pass_program_t *pass_program, const loomc_module_serialize_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source) |
| Prints the prepared program's pipeline IR as textual .loom. | |
| loomc_status_t | loomc_pass_program_run (const loomc_pass_program_t *pass_program, loomc_workspace_t *workspace, loomc_module_t *module, const loomc_pass_run_options_t *options, loomc_allocator_t allocator, loomc_result_t **out_result) |
| Executes a prepared pipeline, transforming a caller-owned module in place. | |
Prepared pass programs.
A pass program is the reusable, immutable representation of a Loom compile pipeline. Constructor helpers prepare this handle from cold configuration forms such as a textual flag-like pass list; compilation and direct execution borrow the prepared object. This keeps the hot JIT path from reparsing pipeline strings or rebuilding pass descriptor state for every kernel.
| typedef struct loomc_pass_program_t loomc_pass_program_t |
Prepared immutable pass program.
Pass programs are separate from compilers so JITs and autotuners can cache common pipelines, choose among several prepared programs per invocation, or sweep pipeline configurations without constructing many compiler handles. Pass programs remain target-independent. Target-aware predicates resolve each function's durable target when the program executes.
| loomc_status_t loomc_pass_program_create_empty | ( | loomc_context_t * | context, |
| const loomc_pass_program_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_pass_program_t ** | out_pass_program ) |
Creates a prepared no-op pass program.
| context | Context shared with modules compiled using this pass program. |
| options | Pass program options, or NULL for defaults. |
| allocator | Host allocator used for pass-program-owned storage. |
| out_pass_program | Receives one retained pass program on success. |
| loomc_status_t loomc_pass_program_create_from_module_symbol | ( | const loomc_module_t * | module, |
| loomc_string_view_t | pipeline_symbol, | ||
| const loomc_pass_program_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_pass_program_t ** | out_pass_program, | ||
| loomc_result_t ** | out_result ) |
Creates a prepared pass program from a named pass.pipeline symbol.
pipeline_symbol names a symbol in module; both cleanup and @cleanup are accepted. The symbol must resolve to a pass.pipeline op. Any pipeline symbols reached through call @other_pipeline are included in the prepared program snapshot so the returned handle is independent of the source module.
| module | Module containing the selected pass pipeline. |
| pipeline_symbol | Borrowed, non-NUL-terminated pipeline symbol name. |
| options | Pass program options, or NULL for defaults. |
| allocator | Host allocator used for pass-program and result storage. |
| out_pass_program | Receives one retained pass program when the result succeeds. Receives NULL when the symbol does not resolve to a valid pipeline program. |
| out_result | Receives a retained result containing pipeline selection, verification, and preparation diagnostics. |
| loomc_status_t loomc_pass_program_create_from_pipeline_text | ( | loomc_context_t * | context, |
| loomc_string_view_t | pipeline_text, | ||
| const loomc_pass_program_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_pass_program_t ** | out_pass_program, | ||
| loomc_result_t ** | out_result ) |
Creates a prepared pass program from a shallow textual pass list.
pipeline_text is the same cold-path pass-list shape used by command-line flags, for example canonicalize{max-iterations=20},dce. The textual form is intended for configuration and examples; hot paths should create a pass program once and pass the prepared handle to every compile invocation.
| context | Context shared with modules compiled using this pass program. |
| pipeline_text | Borrowed, non-NUL-terminated textual pass list. |
| options | Pass program options, or NULL for defaults. |
| allocator | Host allocator used for pass-program and result storage. |
| out_pass_program | Receives one retained pass program when the result succeeds. Receives NULL when the pass list is invalid. |
| out_result | Receives a retained result containing pass-list diagnostics and operation state. |
| loomc_status_t loomc_pass_program_print_text_to_source | ( | const loomc_pass_program_t * | pass_program, |
| const loomc_module_serialize_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_source_t ** | out_source ) |
Prints the prepared program's pipeline IR as textual .loom.
The listing contains the pipeline selected at creation and its called pipelines, preserving source-level control flow and pass options. It does not expand calls into the flattened instruction program. Programs created from a module symbol print their owned snapshot, independently of later changes to the original module.
Printing is optional: preparing and running programs do not select the text printer. Link-time optimization can omit it from nonprinting clients.
| pass_program | Immutable prepared program to inspect. |
| options | Module text presentation, location, and source identifier options. NULL selects defaults. format must be unknown or text. |
| allocator | Host allocator used for source-owned storage. |
| out_source | Receives one retained text source on success, or NULL on failure. |
| void loomc_pass_program_release | ( | loomc_pass_program_t * | pass_program | ) |
Releases a pass program from one owner.
| pass_program | Pass program to release. Passing NULL is allowed. |
| void loomc_pass_program_retain | ( | loomc_pass_program_t * | pass_program | ) |
Retains a pass program for another owner.
| pass_program | Pass program to retain. |
| loomc_status_t loomc_pass_program_run | ( | const loomc_pass_program_t * | pass_program, |
| loomc_workspace_t * | workspace, | ||
| loomc_module_t * | module, | ||
| const loomc_pass_run_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_result_t ** | out_result ) |
Executes a prepared pipeline, transforming a caller-owned module in place.
Structural and target-Low input invariants are established before execution, reusing verification already owned by the module. Configuration application, target specialization, and artifact emission remain separate operations. A function-root pipeline executes over each bodyful function in the module.
| pass_program | Immutable program created in the module's context. |
| workspace | Invocation-local scratch workspace. |
| module | Mutable module borrowed for this invocation. |
| options | Execution options, or NULL for defaults. |
| allocator | Host allocator used for result-owned storage. |
| out_result | Receives one owned execution result on an OK return. |