| Title: | Experimental R Code Transformation Framework on Top of 'Rtinycc' |
|---|---|
| Description: | Provides an experimental and intentionally narrow declare()-annotated R code transformation and R-to-C compilation framework built on top of 'Rtinycc'. The package contains frontend parsing, typed IR, middle-end kernel rewrites, target C emission, and backend-neutral compilation helpers while keeping the underlying TinyCC toolchain and FFI runtime in 'Rtinycc' <https://github.com/sounkou-bioinfo/Rtinycc>. |
| Authors: | Sounkou Mahamane Toure [aut, cre] |
| Maintainer: | Sounkou Mahamane Toure <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.0.0.9000 |
| Built: | 2026-06-06 21:07:15 UTC |
| Source: | https://github.com/sounkou-bioinfo/tccquickr |
tccq typeFormat a tccq type
## S3 method for class 'tccq_type' format(x, ...)## S3 method for class 'tccq_type' format(x, ...)
x |
A |
... |
Unused. |
A compact character representation.
tccq module summaryPrint a tccq module summary
## S3 method for class 'tccq_module' print(x, ...)## S3 method for class 'tccq_module' print(x, ...)
x |
A |
... |
Unused. |
x, invisibly.
tccq typePrint a tccq type
## S3 method for class 'tccq_type' print(x, ...)## S3 method for class 'tccq_type' print(x, ...)
x |
A |
... |
Unused. |
x, invisibly.
tccq_analyze() collects high-level AST facts and optional compiler-package
observations for a function. This is intentionally a side-band analysis to
improve compiler diagnostics and help with boundary-reachability, while keeping
the typed-IR path as the optimization frontier.
tccq_analyze(fn)tccq_analyze(fn)
fn |
R function. |
The output is intentionally conservative and mostly advisory.
A list of class tccq_analysis with fields:
formals: formals metadata
ast: AST observations (calls, symbols, assignments, loops)
compiler: compiler package metadata when available
recommendations: conservative suggestions for lowering success
tccq_compile(), tccq_jit()
f <- function(x, y = 1) { declare(type(x = double(NA), y = double(NA))) sum((x + y) * y) } tccq_analyze(f)f <- function(x, y = 1) { declare(type(x = double(NA), y = double(NA))) sum((x + y) * y) } tccq_analyze(f)
tccq backend factoriesBackend objects control how emitted C is handled by tccq_compile().
tccq_backend_source() tccq_backend_tinycc() tccq_backend_shlib()tccq_backend_source() tccq_backend_tinycc() tccq_backend_shlib()
tccq_backend_source() returns generated C source without compiling it.
tccq_backend_tinycc() compiles and loads the emitted C in memory through
Rtinycc.
tccq_backend_shlib() compiles the emitted C as a shared library through
R CMD SHLIB and loads it with dyn.load(). This lives in the same
general deployment space as callme.
Backends declare capabilities internally, and tccq_compile() validates the
selected backend against the current target, compile context, and explicit
boundary APIs before compiling.
A tccq_backend object suitable for the backend = argument of
tccq_compile().
tccq_backend_source()$name tccq_backend_tinycc()$name tccq_backend_shlib()$nametccq_backend_source()$name tccq_backend_tinycc()$name tccq_backend_shlib()$name
This is the package's current compiler path. The current milestone supports declared scalar and vector arithmetic, generic fold-style reducers, local bindings, indexed reads, contiguous slices, and local indexed/range writes.
tccq_compile( fn, mode = c("compile", "code", "ir"), fallback = c("hard", "auto"), backend = tccq_backend_tinycc(), target = tccq_target_c_rapi(), extlibs = list(), debug = FALSE )tccq_compile( fn, mode = c("compile", "code", "ir"), fallback = c("hard", "auto"), backend = tccq_backend_tinycc(), target = tccq_target_c_rapi(), extlibs = list(), debug = FALSE )
fn |
R function with a leading declare(type(...)) annotation. |
mode |
One of "compile", "code", or "ir". |
fallback |
One of "hard" or "auto". In "hard" mode unsupported calls
are rejected. In "auto" mode unsupported calls may lower to explicit
|
backend |
Backend object. Use |
target |
Target object. Defaults to C + R C API emission. |
extlibs |
Optional list of tccq_external_library descriptors. |
debug |
Print generated C source before compiling. |
Current statement semantics are intentionally strict: rebinding a local name is rejected, direct mutation of formal arguments is rejected, and indexed or range assignment currently requires a scalar right-hand side.
A compiled callable, C source string, or module IR depending on mode.
tccq functionstccq_jit() wraps a declared tccq function with a per-call dispatch
cache keyed by observed argument signatures. Each distinct signature is compiled
at most once (optionally with exact shape guards) and then reused on
subsequent calls.
tccq_jit( fn, fallback = c("hard", "auto"), backend = tccq_backend_tinycc(), target = tccq_target_c_rapi(), extlibs = list(), debug = FALSE, exact = TRUE )tccq_jit( fn, fallback = c("hard", "auto"), backend = tccq_backend_tinycc(), target = tccq_target_c_rapi(), extlibs = list(), debug = FALSE, exact = TRUE )
fn |
R function with a leading |
fallback |
One of "hard" or "auto". In "hard" mode unsupported calls
are rejected. In "auto" mode unsupported calls may lower to explicit
|
backend |
Backend object. Use |
target |
Target object. Defaults to C + R C API emission. |
extlibs |
Optional list of |
debug |
Print generated C source before each (first-time) signature compilation. |
exact |
If |
This is intentionally a thin layer over tccq_compile() and is aimed at
low-latency interactive workflows where many calls share the same runtime
shape, e.g. fixed-size vectors/matrices.
A callable R function with signature-cache semantics. Repeated calls with the same observed signature reuse the compiled callable.
tccq_compile(), tccq_backend_tinycc(), tccq_backend_shlib()
f <- function(x) { declare(type(x = double(NA))) x + 1 } jf <- tccq_jit(f, exact = TRUE) jf(c(1, 2, 3))f <- function(x) { declare(type(x = double(NA))) x + 1 } jf <- tccq_jit(f, exact = TRUE) jf(c(1, 2, 3))