Skip to content

[c_api] Expose interpreter and JIT proc runtimes - #5531

Open
cdleary wants to merge 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-23-proc-runtime-c-api
Open

cdleary wants to merge 1 commit into
google:mainfrom
xlsynth:cdleary/2026-11-23-proc-runtime-c-api

Conversation

@cdleary

@cdleary cdleary commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Expose interpreter and JIT proc runtimes through the C API. xls_proc_runtime_create creates an interpreter. xls_proc_runtime_create_jit compiles the procs at creation so subsequent ticks reuse native code. Both constructors take an existing package. Callers use the same operations for channel I/O, ticking, taking trace messages, and freeing the runtime.

The package must outlive the runtime. Free the runtime before rewriting IR it uses. To run xls_schedule_and_codegen_package while the runtime is live, use a separate package. For proc-scoped channels, each runtime uses the top selected at creation, even if the caller later selects another package top. Writes borrow the input value. A successful try-read returns a caller-owned value to free with xls_value_free, or null if the queue is empty. On failure, try-read returns false and an error string to free with xls_c_str_free.

xls_proc_runtime_take_trace_messages transfers traces from the latest tick, including those emitted before an assertion failure. A second take returns an empty list. The next tick discards any untaken traces. Callers release the array with xls_trace_messages_free.

Tests

The optimized //xls/... sweep passed all 2,232 selected targets, including channel I/O, ownership, top reselection, and trace regressions on both backends, plus the C API symbol export check. The sweep excluded contrib, dev_tools, visualization, and five individual targets.

@cdleary cdleary changed the title Expose proc runtime execution and channel I/O in the C API [c_api] Expose proc runtime execution and channel I/O in the C API Nov 23, 2026
@cdleary
cdleary force-pushed the cdleary/2026-11-23-proc-runtime-c-api branch 2 times, most recently from 3eeabcd to 952de66 Compare November 23, 2026 19:14
@cdleary
cdleary marked this pull request as ready for review November 23, 2026 20:04
cdleary added a commit to xlsynth/xlsynth that referenced this pull request Nov 23, 2026
…l I/O in the C API

Bind proc-scoped channel lookup to the elaborated top. Expose caller-owned reads and per-tick trace messages through the C API.

Upstream-head: 952de66
Let callers select an interpreter or JIT runtime when creating a proc network. Both use the same tick, channel I/O, trace transfer, and lifetime contracts.
@cdleary
cdleary force-pushed the cdleary/2026-11-23-proc-runtime-c-api branch from 952de66 to b3edb28 Compare November 24, 2026 05:28
@cdleary cdleary changed the title [c_api] Expose proc runtime execution and channel I/O in the C API [c_api] Expose interpreter and JIT proc runtimes Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant