|
Loom C API
Public Loom compiler C API
|
Prepared target environments and target lowering pipelines. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_context_target_options_t |
| Context option extension that registers a target environment. More... | |
| struct | loomc_target_specialization_t |
| One function version to specialize to one structured target profile. More... | |
| struct | loomc_target_binding_t |
| One authored target declaration to bind to one target profile. More... | |
| struct | loomc_target_specialization_options_t |
| Option extension carrying target specialization inputs. More... | |
| struct | loomc_target_pipeline_options_t |
| Target pipeline creation options. More... | |
Typedefs | |
| typedef struct loomc_target_environment_t | loomc_target_environment_t |
| Prepared immutable target environment. | |
| typedef struct loomc_target_profile_t | loomc_target_profile_t |
| Prepared immutable target profile. | |
Enumerations | |
| enum | loomc_target_fact_state_t { LOOMC_TARGET_FACT_STATE_UNKNOWN = 0 , LOOMC_TARGET_FACT_STATE_FALSE = 1 , LOOMC_TARGET_FACT_STATE_TRUE = 2 } |
| Three-valued target fact state. More... | |
| enum | loomc_target_pipeline_kind_t { LOOMC_TARGET_PIPELINE_KIND_PREPARED_LOW = 0 , LOOMC_TARGET_PIPELINE_KIND_SOURCE_LOW = 1 } |
| Target lowering pipeline boundary. More... | |
| enum | loomc_target_control_flow_lowering_t { LOOMC_TARGET_CONTROL_FLOW_LOWERING_CFG = 0 , LOOMC_TARGET_CONTROL_FLOW_LOWERING_STRUCTURED_LOW = 1 } |
| Control-flow shape selected for source-to-low lowering. More... | |
Functions | |
| loomc_status_t | loomc_pass_program_create_from_target_pipeline (loomc_context_t *context, const loomc_target_pipeline_options_t *options, loomc_allocator_t allocator, loomc_pass_program_t **out_pass_program, loomc_result_t **out_result) |
| Creates a prepared target lowering pass program. | |
| loomc_status_t | loomc_target_profile_select (loomc_target_environment_t *target_environment, loomc_string_view_t specification, loomc_allocator_t allocator, loomc_target_profile_t **out_profile) |
| Selects a complete named profile from a target environment. | |
| void | loomc_target_profile_retain (loomc_target_profile_t *profile) |
| Retains a target profile for another owner. | |
| void | loomc_target_profile_release (loomc_target_profile_t *profile) |
| Releases a target profile from one owner. | |
| loomc_status_t | loomc_target_environment_create (loomc_host_size_t environment_count, loomc_target_environment_t *const *environments, loomc_allocator_t allocator, loomc_target_environment_t **out_target_environment) |
| Creates one immutable environment from explicitly selected target packages. | |
| void | loomc_target_environment_retain (loomc_target_environment_t *target_environment) |
| Retains a target environment for another owner. | |
| void | loomc_target_environment_release (loomc_target_environment_t *target_environment) |
| Releases a target environment from one owner. | |
Prepared target environments and target lowering pipelines.
A target environment is the reusable compiler capability package selected by the embedding binary. It describes target dialects, target-low descriptor registries, source-to-low policy tables, target math policies, pass registries, and target-aware pass predicates. It is not a device handle and does not require hardware to exist.
Target environments are prepared before contexts because target dialects must be registered while the context is still mutable. A context created with a target environment can parse and build IR for those target dialects. Prepared compilers and target pipelines created from that context reuse the same environment-derived tables.
A target profile is a reusable, immutable, target-family-typed set of facts for a concrete, partial, saved, or synthetic target. Compile invocations borrow profiles in direct-function and target-declaration binding rows. This lets a JIT share cached device profiles across worker threads while independently choosing the exact target of function roots or authored target declarations in a multi-target module.
| typedef struct loomc_target_environment_t loomc_target_environment_t |
Prepared immutable target environment.
A target environment owns target provider composition selected by the linked binary. It should be created once per target provider set and reused across contexts, compilers, pass programs, and worker threads.
| typedef struct loomc_target_profile_t loomc_target_profile_t |
Prepared immutable target profile.
A target profile owns normalized target facts and any target-family payload needed by compiler passes or emitters. Profiles are separate from contexts and compilers so embedders can cache one profile per device, saved hardware profile, or cross-compilation bucket.
Three-valued target fact state.
Target profiles distinguish unavailable, available, and not-yet-known facts because partial targets are valid inputs. Unknown is not false: a later live probe, saved profile, or user override may refine it.
Target lowering pipeline boundary.
| loomc_status_t loomc_pass_program_create_from_target_pipeline | ( | loomc_context_t * | context, |
| const loomc_target_pipeline_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_pass_program_t ** | out_pass_program, | ||
| loomc_result_t ** | out_result ) |
Creates a prepared target lowering pass program.
The context must have been created with a target environment using loomc_context_target_options_t. The returned pass program is an ordinary loomc_pass_program_t and is passed to loomc_compile_module like any other prepared pipeline.
| context | Context whose target environment selects the target package. |
| options | Target pipeline 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 target pipeline preparation fails. |
| out_result | Receives a retained result containing pipeline preparation diagnostics and operation state. |
| loomc_status_t loomc_target_environment_create | ( | loomc_host_size_t | environment_count, |
| loomc_target_environment_t *const * | environments, | ||
| loomc_allocator_t | allocator, | ||
| loomc_target_environment_t ** | out_target_environment ) |
Creates one immutable environment from explicitly selected target packages.
The result retains every input environment and includes each identical provider contribution once, in first-occurrence order. Distinct providers claiming the same target family or artifact format are rejected. An empty list creates an environment with no target providers. The input array is borrowed only for this call; no element may be NULL.
Create profiles against the resulting environment before using them with its contexts and compilers. Composition does not change the compatibility domain of profiles previously created against an input environment.
| environment_count | Number of input target environments. |
| environments | Input environments to compose. May be NULL when environment_count is zero. |
| allocator | Host allocator used for target-environment storage. |
| out_target_environment | Receives one retained environment on success, or NULL on failure. |
| void loomc_target_environment_release | ( | loomc_target_environment_t * | target_environment | ) |
Releases a target environment from one owner.
| target_environment | Target environment to release. Passing NULL is allowed. |
| void loomc_target_environment_retain | ( | loomc_target_environment_t * | target_environment | ) |
Retains a target environment for another owner.
| target_environment | Target environment to retain. |
| void loomc_target_profile_release | ( | loomc_target_profile_t * | profile | ) |
Releases a target profile from one owner.
| profile | Target profile to release. Passing NULL is allowed. |
| void loomc_target_profile_retain | ( | loomc_target_profile_t * | profile | ) |
Retains a target profile for another owner.
| profile | Target profile to retain. |
| loomc_status_t loomc_target_profile_select | ( | loomc_target_environment_t * | target_environment, |
| loomc_string_view_t | specification, | ||
| loomc_allocator_t | allocator, | ||
| loomc_target_profile_t ** | out_profile ) |
Selects a complete named profile from a target environment.
The specification uses Loom's family:selector spelling, such as vm:core or wasm:simd128. The target environment must contain exactly one provider for the named family, and that provider must expose the named process-lifetime profile. This operation performs no hardware discovery.
| target_environment | Environment containing the target family. |
| specification | Complete family:selector target specification. The view need not be NUL-terminated. |
| allocator | Host allocator used for profile-handle storage. |
| out_profile | Receives one retained profile on success. |