Package 'anvltcc'

Title: TinyCC Backend Bridge from 'anvl' Traces to 'tccquickr' Kernels
Description: Compiles 'anvl' traced array programs to C kernels through 'tccquickr' and the TinyCC just-in-time compiler from 'Rtinycc'. Traced graphs are lowered to declared R using anvl's own quickr lowering rules wherever those emit tccquickr's declared subset, with bridge-owned tinycc rules for primitives that have a native tccquickr surface form (matrix products as '%*%' contractions, aval-checked broadcast passthrough). The result is a millisecond-latency CPU compile path for anvl programs with no XLA dependency.
Authors: Sounkou Mahamane Toure [aut, cre]
Maintainer: Sounkou Mahamane Toure <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2026-07-20 21:06:06 UTC
Source: https://github.com/sounkou-bioinfo/anvltcc

Help Index


Lower an anvl graph to a declared R function

Description

Walks an anvl::AnvlGraph's calls in order and emits one declared R function in tccquickr's input dialect. Each primitive is lowered by its tinycc bridge rule when one claims the configuration, and by anvl's own quickr rule otherwise, so the bridge only owns the primitives whose quickr code would leave tccquickr's declared subset.

Usage

graph_to_tinycc_r_function(graph)

Arguments

graph

(AnvlGraph)
A graph traced by anvl::trace_fn().

Details

Graph constants become trailing formals; their traced values are attached as the anvltcc_constants attribute so callers can complete the call.

Value

A function whose body starts with declare(type(...)), suitable for tccquickr::tccq_analyze() and plain R evaluation alike.


Compile an anvl-traceable function to a TinyCC kernel

Description

Traces f with anvl::trace_fn(), lowers the graph through graph_to_tinycc_r_function(), and JIT-compiles the result with tccquickr's Rtinycc backend. The returned function takes plain R scalars/vectors/arrays in the traced argument order and returns plain R values; traced constants are bound automatically.

Usage

tinycc_jit(f, ...)

Arguments

f

(function)
Function over anvl arrays to trace.

...

Named example arguments for tracing: AnvlArrays, or plain R values which are wrapped with the "plain" anvl backend.

Value

A compiled function over plain R values.


Show the C source for an anvl-traceable function

Description

Same pipeline as tinycc_jit() but stops at source emission.

Usage

tinycc_source(f, ...)

Arguments

f

(function)
Function over anvl arrays to trace.

...

Named example arguments for tracing: AnvlArrays, or plain R values which are wrapped with the "plain" anvl backend.

Value

(character(1)) the generated C kernel source.