|
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. | |
| typedef uint32_t | loomc_source_to_low_diagnostic_flags_t |
| Bitmask of loomc_source_to_low_diagnostic_flag_bits_t values. | |
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 , LOOMC_TARGET_PIPELINE_KIND_SOURCE_LOW_ARTIFACTS = 2 } |
| Target lowering pipeline boundary. More... | |
| enum | loomc_source_to_low_diagnostic_flag_bits_t { LOOMC_SOURCE_TO_LOW_DIAGNOSTIC_MEMORY_ACCESS = 1u << 0 , LOOMC_SOURCE_TO_LOW_DIAGNOSTIC_OPERAND_FORM = 1u << 1 , LOOMC_SOURCE_TO_LOW_DIAGNOSTIC_ALL } |
| Optional source-to-low diagnostic flag bits. 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. | |
| loomc_status_t | loomc_target_profile_refine_execution_unit_count (loomc_target_profile_t *base_profile, uint32_t execution_unit_count, loomc_allocator_t allocator, loomc_target_profile_t **out_profile) |
| Refines a complete profile with a known deployment execution-unit count. | |
| 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. | |
| bool | loomc_target_profile_equal (const loomc_target_profile_t *lhs, const loomc_target_profile_t *rhs) |
| Compares exact immutable profile inputs without allocating or compiling. | |
| 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. | |
| loomc_host_size_t | loomc_target_environment_artifact_format_count (const loomc_target_environment_t *target_environment) |
| Returns the number of public artifact formats in a target environment. | |
| loomc_string_view_t | loomc_target_environment_artifact_format_at (const loomc_target_environment_t *target_environment, loomc_host_size_t ordinal) |
| Returns a public artifact format by ordinal. | |
| loomc_host_size_t | loomc_target_environment_target_family_count (const loomc_target_environment_t *target_environment) |
| Returns the number of target families in a target environment. | |
| loomc_string_view_t | loomc_target_environment_target_family_at (const loomc_target_environment_t *target_environment, loomc_host_size_t ordinal) |
| Returns a target family name by ordinal. | |
| 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.
Optional source-to-low diagnostic flag bits.
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_string_view_t loomc_target_environment_artifact_format_at | ( | const loomc_target_environment_t * | target_environment, |
| loomc_host_size_t | ordinal ) |
Returns a public artifact format by ordinal.
| target_environment | Environment to inspect. |
| ordinal | Zero-based artifact format ordinal. |
| loomc_host_size_t loomc_target_environment_artifact_format_count | ( | const loomc_target_environment_t * | target_environment | ) |
Returns the number of public artifact formats in a target environment.
Each format names one linked emitter and may be passed to artifact-emission APIs. Formats preserve target provider composition order.
| target_environment | Environment to inspect, or NULL. |
| 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. |
| loomc_string_view_t loomc_target_environment_target_family_at | ( | const loomc_target_environment_t * | target_environment, |
| loomc_host_size_t | ordinal ) |
Returns a target family name by ordinal.
| target_environment | Environment to inspect. |
| ordinal | Zero-based target family ordinal. |
| loomc_host_size_t loomc_target_environment_target_family_count | ( | const loomc_target_environment_t * | target_environment | ) |
Returns the number of target families in a target environment.
Each family names one linked target profile provider. Families preserve target provider composition order. Family-owned profile selectors are not enumerated by this target-neutral query.
| target_environment | Environment to inspect, or NULL. |
| bool loomc_target_profile_equal | ( | const loomc_target_profile_t * | lhs, |
| const loomc_target_profile_t * | rhs ) |
Compares exact immutable profile inputs without allocating or compiling.
Equal profiles have compatible compiler environments, identical diagnostic identifiers, and identical common and family-specific facts, including unknown or explicitly supplied fields. This is stronger than executable compatibility: a stronger target is not equal to a weaker one. NULL equals only NULL. The query is safe from multiple threads.
Profiles are only one part of a compilation identity. Reusing artifacts also requires identical sources, roots, compiler configuration, and emit options.
| lhs | First profile to compare, or NULL. Borrowed for this call. |
| rhs | Second profile to compare, or NULL. Borrowed for this call. |
| loomc_status_t loomc_target_profile_refine_execution_unit_count | ( | loomc_target_profile_t * | base_profile, |
| uint32_t | execution_unit_count, | ||
| loomc_allocator_t | allocator, | ||
| loomc_target_profile_t ** | out_profile ) |
Refines a complete profile with a known deployment execution-unit count.
The count describes available units in the deployment scope, such as a queue's selected CUs or SMs. It is not kernel occupancy or a workgroup budget. Unknown capacity is represented by leaving the profile unrefined. A count supplied here must be nonzero and agree with any count already in the profile. Named architecture profiles ordinarily leave this fact unknown.
| base_profile | Complete profile to refine, borrowed for this call. |
| execution_unit_count | Known available execution-unit count. |
| allocator | Host allocator used for the refined profile. |
| out_profile | Receives one retained immutable profile on success. |
| 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. |