Loom C API
Public Loom compiler C API
Loading...
Searching...
No Matches
cxx.h File Reference

Optional native C/C++ source import into ordinary Loom modules. More...

Go to the source code of this file.

Data Structures

struct  loomc_cxx_source_provider_t
 Optional source provider replacing filesystem include reads. More...
struct  loomc_cxx_define_t
 Preprocessor definition applied after the frontend's predefined macros. More...
struct  loomc_cxx_import_options_t
 Configuration for one source translation unit. More...

Typedefs

typedef uint32_t loomc_cxx_import_flags_t
 Bitmask of loomc_cxx_import_flag_bits_t values.
typedef loomc_status_t(* loomc_cxx_source_provider_fn_t) (void *user_data, loomc_string_view_t path, loomc_source_t **out_source)
 Resolves a candidate include path to immutable source bytes.

Enumerations

enum  loomc_cxx_data_model_t { LOOMC_CXX_DATA_MODEL_LP64 = 0 , LOOMC_CXX_DATA_MODEL_LLP64 = 1 , LOOMC_CXX_DATA_MODEL_ILP32 = 2 }
 Source integer and pointer layout, independent of the importing process. More...
enum  loomc_cxx_import_flag_bits_t { LOOMC_CXX_IMPORT_FLAG_APPROXIMATE_FUNCTIONS = 1u << 0 , LOOMC_CXX_IMPORT_FLAG_NO_BUILTIN_INCLUDES = 1u << 1 }
 Explicit source permissions and include delivery policy. More...

Functions

loomc_status_t loomc_module_import_cxx (loomc_context_t *context, loomc_workspace_t *workspace, const loomc_source_t *source, const loomc_cxx_import_options_t *options, loomc_allocator_t allocator, loomc_module_t **out_module, loomc_result_t **out_result)
 Imports C/C++ source into a verified High IR module, without cleanup passes.

Detailed Description

Optional native C/C++ source import into ordinary Loom modules.

One configured translation unit produces one compilation-unit module. Multiple kernels and ordinary functions share the module. Build scheduling, host/device partitioning, and linking remain above this interface.

The implementation uses the standalone cxx frontend and native Loom APIs; no LLVM or Python runtime is required. Enable the cxx importer package when building the library and link the optional import/cxx component.

Typedef Documentation

◆ loomc_cxx_source_provider_fn_t

typedef loomc_status_t(* loomc_cxx_source_provider_fn_t) (void *user_data, loomc_string_view_t path, loomc_source_t **out_source)

Resolves a candidate include path to immutable source bytes.

Paths follow ordinary quote, user, system, and include_next search rules. Candidate paths use generic '/' separators on every host. Return OK with a NULL output for a missing candidate. Other failures return status with a NULL output. A found source uses UNKNOWN format; its contents supply the header and the candidate path determines include identity.

Parameters
user_dataCaller state from the provider descriptor.
pathCandidate path borrowed for this callback.
out_sourceReceives one retained source or NULL for a missing path.
Returns
OK for found/missing candidates, or a provider failure status.
Ownership
A successful non-NULL output transfers one retained reference to the importer. A cache can retain its own reference and return another. The importer releases the reference once it has copied the bytes.
Thread safety
Calls are synchronous and sequential within one import. A provider shared by concurrent imports must synchronize its own mutable state.

Enumeration Type Documentation

◆ loomc_cxx_data_model_t

Source integer and pointer layout, independent of the importing process.

Enumerator
LOOMC_CXX_DATA_MODEL_LP64 

32-bit int; 64-bit long and pointers.

LOOMC_CXX_DATA_MODEL_LLP64 

32-bit int and long; 64-bit pointers.

LOOMC_CXX_DATA_MODEL_ILP32 

32-bit int, long, and pointers.

◆ loomc_cxx_import_flag_bits_t

Explicit source permissions and include delivery policy.

Enumerator
LOOMC_CXX_IMPORT_FLAG_APPROXIMATE_FUNCTIONS 

Permit approximate mathematical functions (Loom's AFN contract).

LOOMC_CXX_IMPORT_FLAG_NO_BUILTIN_INCLUDES 

Omit the embedded system include root; use caller paths/providers only.

Function Documentation

◆ loomc_module_import_cxx()

loomc_status_t loomc_module_import_cxx ( loomc_context_t * context,
loomc_workspace_t * workspace,
const loomc_source_t * source,
const loomc_cxx_import_options_t * options,
loomc_allocator_t allocator,
loomc_module_t ** out_module,
loomc_result_t ** out_result )

Imports C/C++ source into a verified High IR module, without cleanup passes.

Parameters
contextImmutable context containing the core dialects.
workspaceWorkspace backing the returned module's arena storage.
sourceSource with UNKNOWN format. Its identifier labels diagnostics and supplies the main file's path for quoted include lookup.
optionsSource configuration, or NULL for defaults.
allocatorHost allocator for public handles and temporary adapters.
out_moduleReceives one owned module on successful source admission.
out_resultReceives one owned result with retained diagnostics.
Returns
OK for successful import or diagnosed source rejection. Rejection returns a failed result and NULL module. Infrastructure/API failures return non-OK status and NULL outputs. C++ exceptions never cross this boundary.
Ownership
Release outputs with loomc_module_release and loomc_result_release. The module retains its context/workspace. The result owns diagnostic contents.
Lifetime
Source/include bytes, options, and callback state may be released on return. Neither the module nor the result retains borrowed frontend or AST storage.
Thread safety
Each import requires exclusive access to its workspace. Concurrent imports may share an immutable context and immutable source handles.