Package 'tccquickr'

Title: Typed Experimental R Transformation Core
Description: A hard-reset experimental compiler core for a declared subset of R. The package now starts from typed schemas, classed diagnostics, explicit compiler contracts, shape-aware intermediate representations, and generic backend planning. Initial source printers consume a backend-neutral lowered program rather than owning compiler semantics.
Authors: Sounkou Mahamane Toure [aut, cre]
Maintainer: Sounkou Mahamane Toure <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9000
Built: 2026-10-11 16:04:40 UTC
Source: https://github.com/sounkou-bioinfo/tccquickr

Help Index


Construct a domain access mapping

Description

Construct a domain access mapping

Usage

tccq_access(
  value_id,
  domain,
  kind = "identity",
  index_map = list(),
  consumer_shape = NULL
)

Arguments

value_id

Referenced value id.

domain

Access domain.

kind

Access kind.

index_map

Structured index-map payload.

consumer_shape

Logical consumer shape for recycling, or NULL for other access kinds.


Analyze a declared R function into the fresh program schema

Description

This is intentionally narrow. It parses declare(type(...)) declarations, records a program schema, reports calls without implementations as classed diagnostics, and runs the first backend-neutral expression lowering pass when frontend facts are clean.

Usage

tccq_analyze(
  fn,
  strict = FALSE,
  registry = tccq_default_op_registry(),
  context = tccq_op_context()
)

Arguments

fn

Function to analyze.

strict

If TRUE, throw the first diagnostic as a classed condition.

registry

Operation registry used to decide whether calls are supported.

context

Operation support context.


Construct argument-selection reduction metadata

Description

Construct argument-selection reduction metadata

Usage

tccq_arg_reduction_spec(
  name,
  signature,
  direction = "max",
  missing = "ignore",
  ties = "first",
  attrs = list()
)

Arguments

name

Human-readable reduction name.

signature

Shared operation signature.

direction

Value-selection direction.

missing

Missing-value policy.

ties

Tie-selection policy.

attrs

Structured reduction metadata.


Construct an operation arity contract

Description

Construct an operation arity contract

Usage

tccq_arity(counts = integer(), minimum = NULL, maximum = NULL)

Arguments

counts

Exact accepted argument counts.

minimum

Inclusive lower argument-count bound, or NULL for an exact contract.

maximum

Inclusive upper argument-count bound, or NULL for no upper bound.


Test an operation arity contract

Description

Test an operation arity contract

Usage

tccq_arity_accepts(arity, count)

Arguments

arity

A TccqArity contract.

count

Observed argument count.

Value

One logical value.


Construct a neutral assignment

Description

Construct a neutral assignment

Usage

tccq_assignment(id, target, value)

Arguments

id

Stable statement id.

target

Typed destination.

value

Backend-neutral value expression.


Construct a backend allocation binding

Description

Construct a backend allocation binding

Usage

tccq_backend_allocation_binding(source_name, allocation, slots)

Arguments

source_name

Generated source identifier.

allocation

Physical allocation represented by the identifier.

slots

Materialized temporary slots sharing the allocation.


Construct a backend artifact

Description

Construct a backend artifact

Usage

tccq_backend_artifact(
  id,
  kind,
  source_language = "",
  path = "",
  attrs = list()
)

Arguments

id

Stable artifact id.

kind

Artifact kind.

source_language

Source language used to produce the artifact, or empty.

path

Filesystem path for file-backed artifacts, or empty.

attrs

Structured artifact metadata.


Construct a backend planning context

Description

Construct a backend planning context

Usage

tccq_backend_context(
  mode = "source",
  target = "any",
  allow_boundary = FALSE,
  required_capabilities = character(),
  attrs = list()
)

Arguments

mode

Requested backend mode.

target

Requested target language or runtime, or any.

allow_boundary

Whether explicit R call-evaluation boundary plans are allowed.

required_capabilities

Capabilities that candidate backends must expose.

attrs

Structured backend-context attributes.


Construct a backend callable error channel

Description

Construct a backend callable error channel

Usage

tccq_backend_error_channel(source_name, diagnostics)

Arguments

source_name

Generated status-output parameter name.

diagnostics

Ordered runtime diagnostics addressable by status code.


Construct a backend extent binding

Description

Construct a backend extent binding

Usage

tccq_backend_extent_binding(source_name, symbol)

Arguments

source_name

Generated extent parameter name.

symbol

Declared dimension symbol.


Construct a backend function interface

Description

Construct a backend function interface

Usage

tccq_backend_function_interface(
  symbol,
  source_language,
  kind,
  abi = "",
  parameters = list(),
  locals = list(),
  allocations = list(),
  result_value_id,
  result_type,
  result_placement = "return",
  result_name = "",
  domain = NULL,
  extents = list(),
  index_names = character(),
  result_dims = list(),
  result_count_name = "",
  error_channel = NULL
)

Arguments

symbol

Generated function symbol.

source_language

Source language consumed by the printer.

kind

Function shape: scalar, loop_nest, or structured.

abi

Callable ABI.

parameters

Ordered ABI parameter bindings.

locals

Ordered scalar-local bindings.

allocations

Ordered physical-allocation bindings.

result_value_id

Lowered result value id.

result_type

Declared semantic result type.

result_placement

Whether the result is returned or passed by output argument.

result_name

Generated result/output variable name, or empty string.

domain

Loop-nest iteration domain, or NULL.

extents

Ordered symbolic-extent bindings carried by the ABI.

index_names

Generated data-parallel and structured loop index names.

result_dims

Typed result dimensions.

result_count_name

Generated result element-count parameter name, or empty string for scalar results.

error_channel

Optional generated callable error channel.


Construct a backend plan

Description

Construct a backend plan

Usage

tccq_backend_plan(
  id,
  backend_id,
  family,
  mode,
  target,
  capabilities = character(),
  regions = list(),
  bridges = list(),
  diagnostics = list(),
  products = NULL,
  attrs = list()
)

Arguments

id

Stable plan id.

backend_id

Backend spec id.

family

Backend family.

mode

Backend mode.

target

Target language or runtime.

capabilities

Backend capabilities visible to this plan.

regions

Regions assigned to the backend plan.

bridges

Representation-transition plans.

diagnostics

Diagnostics attached to this plan.

products

Typed backend products.

attrs

Structured plan attributes.


Construct a backend plan set

Description

Construct a backend plan set

Usage

tccq_backend_plan_set(
  program_name,
  plans = list(),
  diagnostics = list(),
  attrs = list()
)

Arguments

program_name

Program name.

plans

Backend plans.

diagnostics

Diagnostics collected while planning.

attrs

Structured plan-set attributes.


Prepare a backend plan

Description

Prepare a backend plan

Usage

tccq_backend_prepare(backend, program, context)

Arguments

backend

Backend implementation.

program

Program to plan.

context

Backend planning context.


Construct backend products

Description

Construct backend products

Usage

tccq_backend_products(
  function_interface = NULL,
  body = NULL,
  loop_nest = NULL,
  loop_nests = list(),
  storage_plan = NULL,
  artifacts = list(),
  attrs = list()
)

Arguments

function_interface

Source-level callable interface, if source exists.

body

Expression tree or statement block consumed by the backend, if source exists.

loop_nest

Result loop nest consumed by the backend, if source exists.

loop_nests

Ordered loop nests, intermediates first, result nest last.

storage_plan

Storage plan consumed by the backend, if available.

artifacts

Named backend artifacts.

attrs

Structured product metadata.


Construct a backend implementation descriptor

Description

Construct a backend implementation descriptor

Usage

tccq_backend_spec(
  id,
  family,
  target,
  driver,
  modes,
  region_kinds,
  memory_spaces,
  capabilities,
  uses_rapi,
  attrs = list(),
  prepare = NULL
)

Arguments

id

Stable backend id.

family

Backend family.

target

Target language or runtime.

driver

Concrete driver name.

modes

Supported backend modes.

region_kinds

Supported region kinds.

memory_spaces

Supported memory spaces.

capabilities

Capabilities exposed by this backend.

uses_rapi

Whether this backend may touch the R C API.

attrs

Structured backend attributes.

prepare

Planning implementation.


Construct a backend value binding

Description

Construct a backend value binding

Usage

tccq_backend_value_binding(source_name, value_id, source_type, role)

Arguments

source_name

Generated source identifier.

value_id

Neutral value id.

source_type

Type represented by the generated identifier.

role

Whether the identifier is an ABI parameter or scalar local.


Construct a program binding

Description

Construct a program binding

Usage

tccq_binding(name, type, mutable = FALSE)

Arguments

name

Binding name.

type

Binding type.

mutable

Whether the binding may be mutated.


Construct a local binding reference

Description

Construct a local binding reference

Usage

tccq_binding_reference(id, binding)

Arguments

id

Stable reference value id.

binding

Local binding being read.


Construct a lazy conditional IR value

Description

Construct a lazy conditional IR value

Usage

tccq_branch(
  id,
  condition,
  consequent,
  alternative,
  type,
  semantics,
  effect = tccq_effect(may_error = TRUE),
  attrs = list()
)

Arguments

id

Stable value id.

condition

Scalar logical condition value id.

consequent

Value id selected when the condition is true.

alternative

Value id selected when the condition is false.

type

Joined branch result type.

semantics

Evaluator facts for the originating if call.

effect

Conservative effect summary across the condition and both arms.

attrs

Structured branch metadata.


Construct a backend bridge plan

Description

Construct a backend bridge plan

Usage

tccq_bridge_plan(
  id,
  kind,
  from_space,
  to_space,
  from_type = NULL,
  to_type = NULL,
  effect = tccq_effect(reads = TRUE),
  attrs = list()
)

Arguments

id

Stable bridge id.

kind

Bridge kind.

from_space

Source memory space.

to_space

Destination memory space.

from_type

Optional source type.

to_type

Optional destination type.

effect

Bridge effect summary.

attrs

Structured bridge attributes.


Generic C backend descriptor

Description

Generic C backend descriptor

Usage

tccq_c_backend()

Construct an observed call

Description

Construct an observed call

Usage

tccq_call(
  name,
  expr = NULL,
  origin = "ast",
  id = "",
  kind = NULL,
  arity = NULL,
  argument_names = NULL,
  attrs = list()
)

Arguments

name

Call name.

expr

Original R call expression.

origin

Source of the call observation.

id

Stable call id.

kind

Structural call kind.

arity

Number of supplied arguments, or NA_integer_.

argument_names

Supplied argument tags.

attrs

Structured call attributes.


Construct a typed call index

Description

Construct a typed call index

Usage

tccq_call_index(calls, semantics = NULL, env = baseenv(), attrs = list())

Arguments

calls

List of observed calls.

semantics

Optional list of call evaluator facts. If omitted, inferred.

env

Environment used when inferring missing semantics.

attrs

Structured index attributes.


Return the name of an R call

Description

Return the name of an R call

Usage

tccq_call_name(call)

Arguments

call

R call.


Construct call evaluator facts

Description

Construct call evaluator facts

Usage

tccq_call_semantics(
  call,
  env = baseenv(),
  evaluator_kind = NULL,
  forcing_policy = NULL,
  dispatch_kind = NULL,
  lexical_scope = NULL,
  replacement = NULL,
  control = NULL,
  attrs = list()
)

Arguments

call

Observed call.

env

Environment used to resolve ordinary function names.

evaluator_kind

Optional evaluator kind override.

forcing_policy

Optional forcing-policy override.

dispatch_kind

Optional dispatch-kind override.

lexical_scope

Optional lexical-scope override.

replacement

Optional replacement flag override.

control

Optional control flag override.

attrs

Structured semantic attributes.


Construct a mutable lexical cell

Description

Construct a mutable lexical cell

Usage

tccq_cell(name, value_id, type, storage_type = tccq_type(type@base))

Arguments

name

Binding name.

value_id

Stable storage identity.

type

Binding type.

storage_type

Scalar storage type.


Construct a lowered mutable-cell read

Description

Construct a lowered mutable-cell read

Usage

tccq_cell_reference(id, cell)

Arguments

id

Stable value id for this read.

cell

Mutable cell being read.


Collect a typed call index from an R expression

Description

Collect a typed call index from an R expression

Usage

tccq_collect_call_index(
  expr,
  global_calls = character(),
  env = baseenv(),
  attrs = list()
)

Arguments

expr

R expression to inspect.

global_calls

Additional function names found by codetools.

env

Environment used to resolve ordinary function names.

attrs

Structured index attributes.


Collect evaluator facts for calls

Description

Collect evaluator facts for calls

Usage

tccq_collect_call_semantics(calls, env = baseenv())

Arguments

calls

List of TccqCall objects.

env

Environment used to resolve ordinary function names.


Collect calls from an R expression

Description

Collect calls from an R expression

Usage

tccq_collect_calls(expr, global_calls = character())

Arguments

expr

R expression to inspect.

global_calls

Additional function names found by codetools.


Compile a declared R function

Description

Compilation applies one explicit typed optimization, then asks the core backend suite to account for the same verified program. Generic C, Rtinycc/TinyCC, and quickr-style Fortran report constraints through one contract instead of letting one concrete backend shape the IR. The result succeeds when at least one backend produces a working plan; backends that cannot lower the program report feasibility diagnostics in their plans without vetoing the suite.

Usage

tccq_compile(
  fn,
  backends = tccq_core_backends(),
  context = tccq_backend_context(),
  optimization = TccqDeadStoreOptimization(),
  strict = TRUE
)

Arguments

fn

Function to compile.

backends

Backend implementation descriptors.

context

Backend planning context.

optimization

Program optimization applied before backend planning.

strict

If TRUE, throw the first diagnostic as a classed condition.


Compute structured control completion

Description

Completion summarizes only paths reachable in evaluation order. Nested loops consume their own break and next transfers, while a block retains transfers that target its nearest enclosing loop.

Usage

tccq_completion(control)

Arguments

control

Typed statement or statement block.

Value

A TccqControlCompletion value.


Extract a diagnostic from a compiler condition

Description

Extract a diagnostic from a compiler condition

Usage

tccq_condition_diagnostic(condition)

Arguments

condition

A compiler condition.


Construct a value-producing neutral conditional

Description

Construct a value-producing neutral conditional

Usage

tccq_conditional(id, condition, consequent, alternative, branch)

Arguments

id

Stable statement id.

condition

Scalar logical condition expression.

consequent

Block evaluated when the condition is true.

alternative

Block evaluated when the condition is false.

branch

Source branch payload retaining R special-form semantics.


Construct contraction implementation metadata

Description

Construct contraction implementation metadata

Usage

tccq_contraction_spec(
  name,
  signature,
  reducer,
  combine_op = "*",
  attrs = list()
)

Arguments

name

Human-readable contraction name.

signature

Shared operation signature.

reducer

Reduction metadata used for the contracted axes.

combine_op

Elementwise operation name combining aligned elements.

attrs

Structured contraction metadata.


Core backend suite

Description

Every descriptor in the core suite prints from the shared loop nest and function interface. A backend family enters this suite together with its first real lowering; capability strings describe implemented behavior only.

Usage

tccq_core_backends(include_rtinycc = TRUE)

Arguments

include_rtinycc

Whether to include the Rtinycc TinyCC descriptor.


Default operation registry for the reset frontend

Description

The default registry names the R language call forms that the frontend recognizes structurally. It is not a source-syntax whitelist and it is not a backend lowering promise. The registry is immutable, so it is built once per session and shared.

Usage

tccq_default_op_registry()

Create a compiler diagnostic

Description

Create a compiler diagnostic

Usage

tccq_diagnostic(code, message, phase = "schema", path = "", data = list())

Arguments

code

Stable diagnostic code.

message

Human-facing message.

phase

Compiler phase that produced the diagnostic.

path

Optional path into the program or schema.

data

Structured diagnostic payload.


Construct an affine dimension

Description

An affine dimension is a symbolic extent plus a signed integer offset, such as the n - 2 extent of an interior stencil domain. It keeps shape arithmetic a typed dimension fact instead of a backend string.

Usage

tccq_dim_affine(name, offset)

Arguments

name

Symbolic dimension name.

offset

Signed integer offset added to the symbolic extent.


Construct a constant dimension

Description

Construct a constant dimension

Usage

tccq_dim_constant(value)

Arguments

value

Non-negative integer dimension.


Compare two dimensions for semantic equality

Description

Constant dimensions compare by value, symbolic and affine dimensions by symbol and offset. Unknown dimensions never compare equal.

Usage

tccq_dim_equal(left, right)

Arguments

left, right

TccqDim values.


Construct a symbolic dimension

Description

Construct a symbolic dimension

Usage

tccq_dim_symbol(name)

Arguments

name

Dimension symbol.


Construct an unknown dimension

Description

Construct an unknown dimension

Usage

tccq_dim_unknown()

Construct a typed declared-dimension reference

Description

Construct a typed declared-dimension reference

Usage

tccq_dimension_reference(source_value_id, dimension)

Arguments

source_value_id

Logical value id supplying the referenced storage.

dimension

Declared symbolic dimension supplied by the reference.


Construct an iteration domain

Description

Construct an iteration domain

Usage

tccq_domain(id, shape, axes = NULL, attrs = list())

Arguments

id

Stable domain id.

shape

Domain shape.

axes

Optional axis names. Defaults to i1, i2, ...

attrs

Structured domain attributes.


Construct operation domain policy metadata

Description

Construct operation domain policy metadata

Usage

tccq_domain_policy(name, result_shape, attrs = list())

Arguments

name

Human-readable domain policy name.

result_shape

Function from input TccqType list to result TccqShape.

attrs

Structured domain-policy metadata.


Return an operation domain-policy result shape

Description

Return an operation domain-policy result shape

Usage

tccq_domain_policy_result_shape(policy, input_types)

Arguments

policy

Domain policy.

input_types

List of input TccqType values.


Construct an effect summary

Description

Construct an effect summary

Usage

tccq_effect(
  reads = FALSE,
  writes = FALSE,
  allocates = FALSE,
  boundary = FALSE,
  may_error = FALSE,
  may_warn = FALSE
)

Arguments

reads

Whether the operation reads program state.

writes

Whether the operation writes program state.

allocates

Whether the operation allocates storage.

boundary

Whether the operation crosses an unsupported boundary.

may_error

Whether the operation may signal at runtime.

may_warn

Whether the operation may warn at runtime.


Combine effect summaries

Description

Effect summaries are conservative may-properties. Combining two summaries retains every effect reported by either input.

Usage

tccq_effect_union(effect, other)

Arguments

effect

Effect summary.

other

Effect summary to combine with effect.


Construct the standard elementwise domain policy

Description

The standard elementwise policy returns the shared non-scalar input shape and accepts scalar broadcasting. Following R's recycling rule, a shorter non-scalar operand is also accepted when its dimension multiset divides the longest operand's dimension multiset (so its total length provably divides the iteration size); the result takes the longest shape, and accesses to the shorter operand recycle over the iteration order. Shapes whose divisibility cannot be proven from declared dimensions are rejected.

Usage

tccq_elementwise_domain_policy()

Build a registered elementwise expression

Description

This transformation resolves one operation through the supplied registry, applies its signature to typed input expressions, and returns the ordinary neutral expression consumed by every source backend.

Usage

tccq_elementwise_expression(registry, op, inputs, id)

Arguments

registry

Operation registry used for resolution.

op

Operation name.

inputs

Ordered scalar or array input expressions.

id

Stable expression id.

Value

A TccqResult containing a TccqExpression.


Return an elementwise operation result type

Description

Return an elementwise operation result type

Usage

tccq_elementwise_result_type(spec, input_types)

Arguments

spec

Elementwise metadata.

input_types

List of input TccqType values.


Construct elementwise implementation metadata

Description

Construct elementwise implementation metadata

Usage

tccq_elementwise_spec(
  name,
  arity,
  result_type,
  attrs = list(),
  domain_policy = NULL
)

Arguments

name

Human-readable elementwise operation name.

arity

Accepted argument counts.

result_type

Function from input TccqType list to result TccqType.

attrs

Structured elementwise metadata.

domain_policy

Optional result-shape policy.


Construct a scheduled R evaluation

Description

Construct a scheduled R evaluation

Usage

tccq_evaluation_step(
  value_id,
  statement_index,
  effect,
  binding = NULL,
  uses = list()
)

Arguments

value_id

Lowered value evaluated by this step.

statement_index

One-based executable statement position.

effect

Effect of evaluating the complete step.

binding

Optional local binding defined by the evaluation.

uses

Local bindings read by the evaluation.


Construct a backend-neutral expression

Description

Construct a backend-neutral expression

Usage

tccq_expression(
  id,
  kind,
  type,
  value_id = id,
  op = kind,
  inputs = list(),
  effect = tccq_effect(),
  literal = NULL,
  operation = NULL,
  branch = NULL,
  reference = NULL,
  index_proofs = list()
)

Arguments

id

Stable expression id.

kind

Expression kind.

type

Result type.

value_id

Lowered value id represented by this expression.

op

Operation name.

inputs

Child expressions.

effect

Effect of evaluating the expression.

literal

Literal payload for literal expressions.

operation

Typed lowered-operation payload for operation expressions.

branch

Typed conditional payload for branch expressions.

reference

Typed source payload for reference expressions.

index_proofs

Per-axis bounds proofs for indexed expressions.


Construct a typed expression reference

Description

Construct a typed expression reference

Usage

tccq_expression_reference(
  source_value_id,
  symbol = "",
  binding = NULL,
  slice_offsets = integer(),
  access = NULL
)

Arguments

source_value_id

Logical value id supplying the referenced storage.

symbol

Optional source symbol, or an empty string when not applicable.

binding

Optional lexical binding represented by the reference.

slice_offsets

Zero-based slice offsets, or an empty integer vector.

access

Optional typed domain access attached by loop-nest planning.


Build a backend-neutral expression tree from a lowered value graph

Description

Build a backend-neutral expression tree from a lowered value graph

Usage

tccq_expression_tree(graph, value_id = NULL)

Arguments

graph

Lowered value graph.

value_id

Result value id to root the expression tree at.


Construct a neutral for statement

Description

Construct a neutral for statement

Usage

tccq_for(id, iterator, iteration, body, semantics)

Arguments

id

Stable statement id.

iterator

Mutable scalar destination receiving each element.

iteration

Backend-neutral iteration plan.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.


Quickr-style Fortran backend descriptor

Description

This descriptor captures the pressure from quickr's Fortran path: subroutine lowering, C/R bridges, R CMD SHLIB, BLAS/LAPACK linkage, and optional OpenMP.

Usage

tccq_fortran_backend()

Construct a fusion operation contract

Description

Construct a fusion operation contract

Usage

tccq_fusion_contract(
  fusion_kind,
  result_value,
  operations = list(),
  storage_strategy = NULL,
  attrs = list()
)

Arguments

fusion_kind

Fusion kind owned by the contract.

result_value

Typed value produced by the fusion group.

operations

Named lowered operations by value id. Control-only groups may use an empty list.

storage_strategy

Optional storage strategy. Defaults from fusion_kind.

attrs

Structured metadata.


Construct a fusion group

Description

Construct a fusion group

Usage

tccq_fusion_group(
  id,
  kind,
  domain,
  values = list(),
  outputs = character(),
  accesses = list(),
  region_kind = "kernel",
  target = "any",
  effect = tccq_effect(),
  contract = NULL,
  attrs = list()
)

Arguments

id

Stable fusion-group id.

kind

Fusion kind.

domain

Shared iteration domain.

values

List of IR values in the group.

outputs

Output value ids.

accesses

List of access mappings.

region_kind

Candidate execution region kind, or any.

target

Candidate implementation target, or any.

effect

Effect summary for the fused group.

contract

Typed fusion operation/storage contract.

attrs

Structured fusion attributes.


Construct a neutral procedural if

Description

Construct a neutral procedural if

Usage

tccq_if(id, condition, consequent, alternative, semantics)

Arguments

id

Stable statement id.

condition

Scalar logical condition expression.

consequent

Block evaluated when the condition is true.

alternative

Block evaluated when the condition is false.

semantics

Evaluator facts for the originating if special form.


Construct an affine index expression

Description

Construct an affine index expression

Usage

tccq_index_expr(axis = "", offset = 0L)

Arguments

axis

Iteration-axis name, or empty for a constant index.

offset

Signed integer offset (zero-based).


Construct a proven affine scalar index

Description

Construct a proven affine scalar index

Usage

tccq_index_proof(
  iterator,
  selector,
  iteration,
  source_extent,
  index,
  operation = NULL,
  semantics = NULL
)

Arguments

iterator

Iterator target populated by the enclosing virtual loop.

selector

Direct reference to the iterator cell.

iteration

Virtual iteration establishing the selector range.

source_extent

Extent of the indexed source axis.

index

Zero-based affine storage index.

operation

Lowered selector operation for a shifted index, or NULL.

semantics

Evaluator facts for the shifted selector call, or NULL.


Construct a proven scalar indexed read

Description

Construct a proven scalar indexed read

Usage

tccq_indexed_value(
  id,
  source_id,
  source_type,
  index_proofs,
  access,
  operation,
  semantics
)

Arguments

id

Stable value id.

source_id

Stable value id of the source storage.

source_type

Type of the source storage.

index_proofs

Per-axis affine selector and bounds proofs.

access

Zero-based source access corresponding to the proofs.

operation

Lowered subscript implementation payload.

semantics

Evaluator facts for the originating [ call.


Construct a backend-neutral iteration plan

Description

Construct a backend-neutral iteration plan

Usage

tccq_iteration_plan(
  source,
  domain,
  element,
  element_type,
  resolved_op = NULL,
  semantics = NULL
)

Arguments

source

Expression evaluated once to establish iteration.

domain

One-dimensional iteration domain.

element

Current element expression or affine induction value.

element_type

Scalar type assigned to the iteration cell.

resolved_op

Resolved operation for virtual iteration, or NULL for stored-value iteration.

semantics

Evaluator facts for the virtual iteration call, or NULL.


Construct iteration implementation metadata

Description

Construct iteration implementation metadata

Usage

tccq_iteration_spec(name, signature, extent_arg = 1L, start = 1L)

Arguments

name

Human-readable iteration operation name.

signature

Shared operation signature.

extent_arg

One-based argument position supplying the domain extent.

start

First integer value produced by the iteration.


Construct a scalar literal

Description

Construct a scalar literal

Usage

tccq_literal(kind, type, value = NULL)

Arguments

kind

Literal kind: finite, na, nan, pos_inf, or neg_inf.

type

Scalar type.

value

Literal payload for finite values.


Construct a finite scalar literal

Description

Construct a finite scalar literal

Usage

tccq_literal_finite(value, type = NULL)

Arguments

value

Finite scalar value.

type

Optional scalar type. If omitted, it is inferred from value.


Construct an infinite double literal

Description

Construct an infinite double literal

Usage

tccq_literal_inf(sign = 1L)

Arguments

sign

Positive or negative sign.


Construct a typed NA literal

Description

Construct a typed NA literal

Usage

tccq_literal_na(base)

Arguments

base

Base type for the missing value.


Construct a NaN literal

Description

Construct a NaN literal

Usage

tccq_literal_nan()

Construct a local value binding

Description

Construct a local value binding

Usage

tccq_local_binding(name, value_id, type, statement_index, mutable = FALSE)

Arguments

name

Binding name.

value_id

Lowered value bound to the local name.

type

Binding type.

statement_index

One-based executable statement position defining the binding.

mutable

Whether the binding may be mutated.


Construct a loop-nest iteration axis

Description

Construct a loop-nest iteration axis

Usage

tccq_loop_axis(name, extent, role = "map")

Arguments

name

Iteration-axis name.

extent

Typed axis extent.

role

Axis role, map or reduce.


Construct a selected-arm loop guard

Description

Construct a selected-arm loop guard

Usage

tccq_loop_guard(condition, branch, selected)

Arguments

condition

Scalar logical condition expression.

branch

Source branch payload retaining R special-form semantics.

selected

Whether the consequent (TRUE) or alternative (FALSE) arm selects the guarded loop nest.


Construct a loop nest

Description

Construct a loop nest

Usage

tccq_loop_nest(
  id,
  axes,
  body,
  storage,
  output = NULL,
  reduction = NULL,
  domain = NULL,
  guards = list()
)

Arguments

id

Stable loop-nest id.

axes

Ordered TccqLoopAxis values, outermost first.

body

Body expression or typed statement block with access-carrying references.

storage

Typed storage slot receiving the nest result.

output

Output access over map axes, or NULL for scalar results.

reduction

Closed neutral reduction plan for reduce axes, or NULL.

domain

Optional iteration domain. Defaults to one built from axes.

guards

Ordered TccqLoopGuard control path selecting this nest.


Construct a neutral loop transfer

Description

Construct a neutral loop transfer

Usage

tccq_loop_transfer(id, action, semantics)

Arguments

id

Stable statement id.

action

Loop action, either break or next.

semantics

Evaluator facts for the originating R control special form.


Lower a declared function into a backend-neutral plan

Description

The lowerer produces TccqValue, TccqRegion, TccqFusionGroup, and TccqStoragePlan objects. It is a middle-end pass result, not a C, Fortran, or TinyCC lowering.

Usage

tccq_lower_function(
  fn,
  bindings,
  registry = tccq_default_op_registry(),
  context = tccq_op_context(),
  call_index = NULL
)

Arguments

fn

Function to lower.

bindings

Declared formal bindings.

registry

Operation registry used for operation availability.

context

Operation support context.

call_index

Typed call facts for fn, or NULL to collect them.


Construct a lowered operation payload

Description

Construct a lowered operation payload

Usage

tccq_lowered_operation(
  family,
  resolved_op,
  signature = NULL,
  elementwise = NULL,
  reduction = NULL,
  contraction = NULL,
  subscript = NULL,
  attrs = list()
)

Arguments

family

Lowered operation family.

resolved_op

Selected operation implementation.

signature

Optional operation signature. Defaults to the family spec.

elementwise

Optional elementwise metadata.

reduction

Optional reduction metadata.

contraction

Optional contraction metadata.

subscript

Optional subscript metadata.

attrs

Structured metadata.


Construct a backend-neutral operation body

Description

fn supplies only ordered parameter names and one implementation expression; parameter types come from the operation signature at each expansion site. Exact call tags bind first and remaining arguments bind positionally. Partial tags, defaults, and ... are excluded because their complete R argument and promise semantics are not represented by this expression-body contract.

Usage

tccq_op_body(fn)

Arguments

fn

Function with simple formals and one implementation expression.


Construct an operation support context

Description

Construct an operation support context

Usage

tccq_op_context(
  phase = "frontend",
  target = "any",
  region_kind = "any",
  memory_space = "any",
  allow_rapi = TRUE,
  allow_boundary = FALSE
)

Arguments

phase

Compiler phase issuing the query.

target

Requested implementation target, or any.

region_kind

Requested execution region kind, or any.

memory_space

Requested memory space, or any.

allow_rapi

Whether implementations touching the R C API are allowed.

allow_boundary

Whether explicit boundary implementations are allowed.


Construct an operation implementation

Description

Construct an operation implementation

Usage

tccq_op_impl(
  op,
  target,
  region_kind = "any",
  memory_space = "any",
  uses_rapi = FALSE,
  boundary = FALSE,
  pure = TRUE,
  effect = NULL,
  supports = function(call, context) TRUE,
  render = NULL,
  body = NULL,
  elementwise = NULL,
  reduction = NULL,
  contraction = NULL,
  iteration = NULL,
  subscript = NULL
)

Arguments

op

Operation or function name.

target

Implementation target.

region_kind

Region kind the implementation can run in, or any.

memory_space

Memory space the implementation expects, or any.

uses_rapi

Whether the implementation touches the R C API.

boundary

Whether the implementation crosses a boundary.

pure

Whether the implementation is semantically pure.

effect

Effect summary for calls handled by this implementation.

supports

Predicate receiving a TccqCall and TccqOpContext.

render

Optional source renderer receiving operand strings and a TccqOpRenderContext.

body

Optional backend-neutral operation body.

elementwise

Optional elementwise metadata.

reduction

Optional reduction metadata.

contraction

Optional contraction metadata.

iteration

Optional iteration metadata.

subscript

Optional subscript metadata.


Construct an operation registry

Description

Construct an operation registry

Usage

tccq_op_registry(implementations = list())

Arguments

implementations

List of operation implementations.


Add operation implementations to a registry

Description

Add operation implementations to a registry

Usage

tccq_op_registry_add(registry, implementations)

Arguments

registry

Operation registry.

implementations

Operation implementation or list of implementations.


Render an operation implementation for source output

Description

Render an operation implementation for source output

Usage

tccq_op_render(impl, operands, context)

Arguments

impl

Operation implementation.

operands

Rendered operand strings.

context

Rendering context.


Construct an operation source-rendering context

Description

Construct an operation source-rendering context

Usage

tccq_op_render_context(language, backend_id, attrs = list())

Arguments

language

Target source language.

backend_id

Backend requesting rendering.

attrs

Structured rendering metadata.


Construct operation signature metadata

Description

Construct operation signature metadata

Usage

tccq_op_signature(
  name,
  arity,
  result_type,
  attrs = list(),
  domain_policy = NULL
)

Arguments

name

Human-readable operation signature name.

arity

Accepted argument counts or a TccqArity contract.

result_type

Function from input TccqType list to result TccqType.

attrs

Structured signature metadata.

domain_policy

Optional result-shape policy.


Return an operation signature result type

Description

Return an operation signature result type

Usage

tccq_op_signature_result_type(signature, input_types)

Arguments

signature

Operation signature.

input_types

List of input TccqType values.


Query operation implementation support

Description

Query operation implementation support

Usage

tccq_op_supports(impl, call, context)

Arguments

impl

Operation implementation.

call

Observed R call.

context

Operation query context.


Opaque operation implementation

Description

In R, every call is an operation candidate. This descriptor represents calls whose concrete implementation, purity, and effects have not been refined yet. It is not R call evaluation; that is only one possible backend implementation family.

Usage

tccq_opaque_op_impl()

Optimize a typed program

Description

Optimize a typed program

Usage

tccq_optimize(optimization, program)

Arguments

optimization

Optimization implementation.

program

Typed program to transform.

Value

A TccqResult containing the transformed TccqProgram.


Plan a backend for a typed program

Description

Plan a backend for a typed program

Usage

tccq_plan_backend(
  program,
  backend = tccq_c_backend(),
  context = tccq_backend_context()
)

Arguments

program

Program to plan.

backend

Backend implementation.

context

Backend planning context.


Plan several backends for a typed program

Description

Every backend accounts for the program and reports constraints through its own plan. The plan set succeeds when at least one backend produces a working plan; backends that cannot lower the program contribute feasibility diagnostics without vetoing the suite.

Usage

tccq_plan_backends(
  program,
  backends = tccq_core_backends(),
  context = tccq_backend_context()
)

Arguments

program

Program to plan.

backends

Backend implementation descriptors.

context

Backend planning context.


Construct a program schema

Description

Construct a program schema

Usage

tccq_program(
  name,
  formals,
  schedule = NULL,
  values = list(),
  regions = list(),
  result = NULL,
  diagnostics = list(),
  call_index = NULL,
  storage_plan = NULL,
  attrs = list()
)

Arguments

name

Program name.

formals

Named list of formal bindings.

schedule

Optional ordered program evaluation schedule.

values

List of IR values.

regions

List of executable code regions.

result

Result value id or object.

diagnostics

List of diagnostics attached to the program.

call_index

Typed frontend call handoff.

storage_plan

Optional middle-end storage plan.

attrs

Structured program attributes.


Plan the loop nest for a single-nest lowered program

Description

Thin wrapper over tccq_program_loop_nests() for programs that plan to exactly one nest. Multi-nest programs return a structured diagnostic pointing at the plural planner.

Usage

tccq_program_loop_nest(program)

Arguments

program

Lowered program.


Plan the ordered loop nests for a lowered program

Description

This is the pass that turns a lowered value graph into the ordered sequence of loop nests consumed by source printers. Every non-root scalar reduction becomes its own all-reduce nest whose result is a named scalar intermediate, and the program result becomes the final nest, whose body references those intermediates through scalar accesses. Elementwise maps become all-map nests, full reductions become all-reduce nests, per-axis reductions and contractions become mixed nests, and slice values disappear into affine accesses. Programs the planner cannot express honestly return structured diagnostics.

Usage

tccq_program_loop_nests(program)

Arguments

program

Lowered program.


Construct an ordered program evaluation schedule

Description

values is the lowered value graph used to verify references, binding types, dominance, complete step effects, and structured-body cell ownership. It is checked at this boundary but is not duplicated inside the schedule.

Usage

tccq_program_schedule(steps, result, values, body = NULL)

Arguments

steps

Ordered TccqEvaluationStep values.

result

Result value id produced by the final step.

values

Lowered values referenced by the schedule.

body

Optional structured value-producing body.


Return a reducer identity literal

Description

Return a reducer identity literal

Usage

tccq_reduction_identity(spec, type)

Arguments

spec

Reduction metadata.

type

Result type for the reduction.


Build a neutral reduction plan

Description

Build a neutral reduction plan

Usage

tccq_reduction_plan(spec, value, axes, result_type, id, registry)

Arguments

spec

Reduction metadata.

value

Scalar input-element expression.

axes

Ordered reduce axes.

result_type

Scalar result type.

id

Stable loop-nest id.

registry

Operation registry used to build transition expressions.


Construct reduction implementation metadata

Description

Construct reduction implementation metadata

Usage

tccq_reduction_spec(
  name,
  identity,
  combine_op,
  finalize_op = "",
  associative = TRUE,
  commutative = TRUE,
  attrs = list(),
  signature = NULL
)

Arguments

name

Human-readable reduction name.

identity

Function from result TccqType to identity TccqLiteral.

combine_op

Registered operation combining the accumulator and current value.

finalize_op

Optional registered operation applied to the completed accumulator and reduced element count.

associative

Whether the reducer is associative.

commutative

Whether the reducer is commutative.

attrs

Structured reduction metadata.

signature

Shared operation signature. By default, reductions accept one input and return a scalar of the input base type.


Construct a reduction-state component

Description

Construct a reduction-state component

Usage

tccq_reduction_state_component(name, target, identity)

Arguments

name

Semantic component name.

target

Neutral local target that stores the component.

identity

Initial scalar literal.


Construct an executable code region

Description

Construct an executable code region

Usage

tccq_region(
  id,
  kind,
  values = list(),
  fusion_groups = list(),
  effect = tccq_effect(),
  memory_space = "host",
  touches_rapi = FALSE,
  attrs = list()
)

Arguments

id

Stable region id.

kind

Region kind: host, kernel, parallel, or device.

values

List of IR values in the region.

fusion_groups

List of fusion groups in the region.

effect

Region effect summary.

memory_space

Dominant memory space: r, host, device, or opaque.

touches_rapi

Whether the region may call into the R C API.

attrs

Structured region attributes.


Query whether any registry implementation supports a call

Description

Query whether any registry implementation supports a call

Usage

tccq_registry_supports(registry, call, context = tccq_op_context())

Arguments

registry

Operation registry.

call

Observed R call.

context

Operation query context.


Construct a neutral repeat statement

Description

Construct a neutral repeat statement

Usage

tccq_repeat(id, body, semantics)

Arguments

id

Stable statement id.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.


Resolve a call to one operation implementation

Description

Resolve a call to one operation implementation

Usage

tccq_resolve_call(registry, call, context = tccq_op_context())

Arguments

registry

Operation registry.

call

Observed R call.

context

Operation query context.


Construct a resolved operation

Description

Construct a resolved operation

Usage

tccq_resolved_op(call, implementation, attrs = list())

Arguments

call

Observed R call.

implementation

Selected operation implementation.

attrs

Structured resolution metadata.


Create a compiler result

Description

Create a compiler result

Usage

tccq_result(success, value = NULL, diagnostics = list())

Arguments

success

Whether the phase completed without diagnostics.

value

Result value for the phase.

diagnostics

List of TccqDiagnostic values.


Rtinycc backend descriptor

Description

This descriptor models the available TinyCC-backed C path without making it the compiler architecture. It consumes the same typed function interface, neutral body or loop nests, storage plan, and C source artifact as the generic C path, then produces a JIT callable through Rtinycc.

Usage

tccq_rtinycc_backend()

Construct a shape

Description

Construct a shape

Usage

tccq_shape(dims = list())

Arguments

dims

A list, character vector, integer vector, or single dimension.


Construct a physical storage allocation

Description

Construct a physical storage allocation

Usage

tccq_storage_allocation(id, type, memory_space = "host")

Arguments

id

Stable allocation id.

type

Semantic storage type shared by every assigned slot.

memory_space

Memory space in which the allocation exists.


Construct a storage lifetime interval

Description

Construct a storage lifetime interval

Usage

tccq_storage_lifetime(value_id, defined_at, last_used_at)

Arguments

value_id

Value whose lifetime is described.

defined_at

Linear definition position in schedule-derived value order.

last_used_at

Last position where the value must remain live.


Construct a storage plan

Description

Construct a storage plan

Usage

tccq_storage_plan(slots = list())

Arguments

slots

List of storage slots.


Construct a storage slot

Description

Construct a storage slot

Usage

tccq_storage_slot(
  id,
  value_id,
  type,
  role,
  materialized,
  lifetime = NULL,
  allocation = NULL
)

Arguments

id

Stable storage-slot id.

value_id

Value owned by this slot.

type

Slot value type.

role

Storage role.

materialized

Whether storage exists at runtime.

lifetime

Optional typed liveness interval for storage reuse.

allocation

Physical allocation for a materialized temporary.


Construct subscript implementation metadata

Description

Construct subscript implementation metadata

Usage

tccq_subscript_spec(name, signature)

Arguments

name

Human-readable subscript operation name.

signature

Shared operation signature.


Construct a neutral positional switch

Description

Construct a neutral positional switch

Usage

tccq_switch(id, selector, selector_target, alternatives, semantics)

Arguments

id

Stable statement id.

selector

Scalar integer selector expression.

selector_target

Typed local target for the evaluate-once selector.

alternatives

Ordered positional alternative blocks.

semantics

Evaluator facts for the originating switch special form.


Construct a compiler type

Description

Construct a compiler type

Usage

tccq_type(base, shape = tccq_shape())

Arguments

base

Scalar or storage base type.

shape

Shape value.


Find calls without an implementation for a registry and context

Description

Find calls without an implementation for a registry and context

Usage

tccq_unimplemented_calls(
  calls,
  registry = tccq_default_op_registry(),
  context = tccq_op_context()
)

Arguments

calls

List of TccqCall objects.

registry

Operation registry.

context

Operation query context.


Construct an IR value

Description

Construct an IR value

Usage

tccq_value(
  id,
  op,
  inputs = list(),
  type,
  effect = tccq_effect(),
  attrs = list()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.


Construct a value-producing neutral statement block

Description

Construct a value-producing neutral statement block

Usage

tccq_value_block(id, result, locals = list(), statements = list())

Arguments

id

Stable block id.

result

Typed target produced on every terminal path through the block.

locals

Ordered local write targets declared by the block.

statements

Ordered TccqStatement values.


Verify an optimized program

Description

Verify an optimized program

Usage

tccq_verify_optimization(optimization, before, after)

Arguments

optimization

Optimization implementation.

before

Program before transformation.

after

Program after transformation.

Value

A TccqResult containing after when its pass invariants hold.


Construct a neutral while statement

Description

Construct a neutral while statement

Usage

tccq_while(id, condition, body, semantics)

Arguments

id

Stable statement id.

condition

Scalar logical condition expression.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.


Construct a neutral write target

Description

Construct a neutral write target

Usage

tccq_write_target(
  value_id,
  type,
  storage_type = tccq_type(type@base),
  kind = "local",
  binding = NULL
)

Arguments

value_id

Stable value id written by the target.

type

Semantic value type.

storage_type

Scalar storage type written at the target.

kind

Target kind: local, result, or cell.

binding

Optional binding owned by the target.


Domain access mapping

Description

Access describes how a value is read or written over a domain. It is the schema-level place for identity indexing, scalar broadcast, slicing, transpose, and later richer affine/custom maps.

Usage

TccqAccess(
  value_id = character(0),
  domain = TccqDomain(),
  kind = character(0),
  index_map = list(),
  consumer_shape = NULL
)

Arguments

value_id

Referenced value id.

domain

Access domain.

kind

Access kind.

index_map

Structured index-map payload.

consumer_shape

Logical consumer shape for recycling, or NULL for other access kinds.


Argument-selection reduction metadata

Description

An argument reduction tracks whether a value was seen, the selected value, and its one-based index. The first concrete form supports R-compatible maximum selection while ignoring missing double values.

Usage

TccqArgReductionSpec(
  name = character(0),
  signature = TccqOpSignature(),
  associative = logical(0),
  commutative = logical(0),
  empty_policy = character(0),
  attrs = list(),
  direction = character(0),
  missing = character(0),
  ties = character(0)
)

Arguments

name

Human-readable reduction name.

signature

Shared operation signature.

associative

Whether the reducer is associative under its declared semantics.

commutative

Whether the reducer is commutative under its declared semantics.

empty_policy

Behavior when no value contributes to the reduction.

attrs

Structured reduction metadata.

direction

Value-selection direction.

missing

Missing-value policy.

ties

Tie-selection policy.


Operation arity contract

Description

Arity is a typed operation fact rather than an expanded vector of convenient argument counts. Exact contracts enumerate accepted counts; interval contracts own inclusive lower and optional upper bounds. This lets rank-polymorphic operations such as [ remain independent of an arbitrary maximum array rank.

Usage

TccqArity(counts = integer(0), minimum = NULL, maximum = NULL)

Arguments

counts

Exact accepted argument counts.

minimum

Inclusive lower argument-count bound, or NULL for an exact contract.

maximum

Inclusive upper argument-count bound, or NULL for no upper bound.


Neutral assignment statement

Description

Neutral assignment statement

Usage

TccqAssignment(
  id = character(0),
  effect = TccqEffect(),
  target = TccqWriteTarget(),
  value = TccqExpression()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

target

Typed destination.

value

Backend-neutral value expression.


Backend implementation trait

Description

Backend implementations must opt into this trait before compiler code uses them for planning.

Usage

TccqBackend

Backend allocation binding

Description

An allocation binding assigns one generated source identifier to one typed physical allocation. Every materialized slot sharing that allocation is carried by the same binding.

Usage

TccqBackendAllocationBinding(
  source_name = character(0),
  allocation = TccqStorageAllocation(),
  slots = list()
)

Arguments

source_name

Generated source identifier.

allocation

Physical allocation represented by the identifier.

slots

Materialized temporary slots sharing the allocation.


Backend artifact

Description

Backend artifacts are concrete products of a backend plan: generated source, a compiled shared library, or a JIT callable. They are explicit plan values so source, shared-library, and JIT modes cannot silently collapse into the same loose string attribute.

Usage

TccqBackendArtifact(
  id = character(0),
  kind = character(0),
  source_language = character(0),
  path = character(0),
  attrs = list()
)

Arguments

id

Stable artifact id.

kind

Artifact kind.

source_language

Source language used to produce the artifact, or empty.

path

Filesystem path for file-backed artifacts, or empty.

attrs

Structured artifact metadata.


Backend planning context

Description

Backend planning context

Usage

TccqBackendContext(
  mode = character(0),
  target = character(0),
  allow_boundary = logical(0),
  required_capabilities = character(0),
  attrs = list()
)

Arguments

mode

Requested backend mode.

target

Requested target language or runtime, or any.

allow_boundary

Whether explicit R call-evaluation boundary plans are allowed.

required_capabilities

Capabilities that candidate backends must expose.

attrs

Structured backend-context attributes.


Backend callable error channel

Description

Generated code writes zero on success or the one-based position of a diagnostic on failure. Wrappers turn the status back into the corresponding classed runtime diagnostic.

Usage

TccqBackendErrorChannel(source_name = character(0), diagnostics = list())

Arguments

source_name

Generated status-output parameter name.

diagnostics

Ordered runtime diagnostics addressable by status code.


Backend extent binding

Description

An extent binding assigns one generated ABI parameter to one declared dimension symbol.

Usage

TccqBackendExtentBinding(source_name = character(0), symbol = character(0))

Arguments

source_name

Generated extent parameter name.

symbol

Declared dimension symbol.


Backend function interface

Description

A backend function interface is the source-level callable boundary consumed by C, Rtinycc, Fortran, and later source printers. Generated parameters, scalar locals, physical allocations, and extents are closed typed bindings; positional arrays are not an interface protocol.

Usage

TccqBackendFunctionInterface(
  symbol = character(0),
  source_language = character(0),
  kind = character(0),
  abi = character(0),
  parameters = list(),
  locals = list(),
  allocations = list(),
  result_value_id = character(0),
  result_type = TccqType(),
  result_placement = character(0),
  result_name = character(0),
  domain = NULL,
  extents = list(),
  index_names = character(0),
  result_dims = list(),
  result_count_name = character(0),
  error_channel = NULL
)

Arguments

symbol

Generated function symbol.

source_language

Source language consumed by the printer.

kind

Function shape: scalar, loop_nest, or structured.

abi

Callable ABI.

parameters

Ordered ABI parameter bindings.

locals

Ordered scalar-local bindings.

allocations

Ordered physical-allocation bindings.

result_value_id

Lowered result value id.

result_type

Declared semantic result type.

result_placement

Whether the result is returned or passed by output argument.

result_name

Generated result/output variable name, or empty string.

domain

Loop-nest iteration domain, or NULL.

extents

Ordered symbolic-extent bindings carried by the ABI.

index_names

Generated data-parallel and structured loop index names.

result_dims

Typed result dimensions.

result_count_name

Generated result element-count parameter name, or empty string for scalar results.

error_channel

Optional generated callable error channel.


Backend plan

Description

Backend plan

Usage

TccqBackendPlan(
  id = character(0),
  backend_id = character(0),
  family = character(0),
  mode = character(0),
  target = character(0),
  capabilities = character(0),
  regions = list(),
  bridges = list(),
  diagnostics = list(),
  products = NULL,
  attrs = list()
)

Arguments

id

Stable plan id.

backend_id

Backend spec id.

family

Backend family.

mode

Backend mode.

target

Target language or runtime.

capabilities

Backend capabilities visible to this plan.

regions

Regions assigned to the backend plan.

bridges

Representation-transition plans.

diagnostics

Diagnostics attached to this plan.

products

Typed backend products.

attrs

Structured plan attributes.


Backend plan set

Description

A plan set is the neutral result of asking several backend families to account for the same typed program. It exists to keep the core honest: C, Fortran, and future graph, device, or R call-evaluation implementations must report their constraints through the same contract.

Usage

TccqBackendPlanSet(
  program_name = character(0),
  plans = list(),
  diagnostics = list(),
  attrs = list()
)

Arguments

program_name

Program name.

plans

Backend plans.

diagnostics

Diagnostics collected while planning.

attrs

Structured plan-set attributes.


Backend products

Description

Backend products are the typed outputs owned by a backend plan: the callable interface, loop nest, expression or statement block consumed by the source printer, storage plan, and concrete artifacts. Runtime handles such as loaded libraries and compiled callables stay in attrs, but under this typed products value rather than directly on the backend plan.

Usage

TccqBackendProducts(
  function_interface = NULL,
  body = NULL,
  loop_nest = NULL,
  loop_nests = list(),
  storage_plan = NULL,
  artifacts = list(),
  attrs = list()
)

Arguments

function_interface

Source-level callable interface, if source exists.

body

Expression tree or statement block consumed by the backend, if source exists.

loop_nest

Result loop nest consumed by the backend, if source exists.

loop_nests

Ordered loop nests, intermediates first, result nest last.

storage_plan

Storage plan consumed by the backend, if available.

artifacts

Named backend artifacts.

attrs

Structured product metadata.


Backend implementation descriptor

Description

Backend implementation descriptor

Usage

TccqBackendSpec(
  id = character(0),
  family = character(0),
  target = character(0),
  driver = character(0),
  modes = character(0),
  region_kinds = character(0),
  memory_spaces = character(0),
  capabilities = character(0),
  uses_rapi = logical(0),
  attrs = list(),
  prepare = function() NULL
)

Arguments

id

Stable backend id.

family

Backend family.

target

Target language or runtime.

driver

Concrete driver name.

modes

Supported backend modes.

region_kinds

Supported region kinds.

memory_spaces

Supported memory spaces.

capabilities

Capabilities exposed by this backend.

uses_rapi

Whether this backend may touch the R C API.

attrs

Structured backend attributes.

prepare

Planning implementation.


Backend value binding

Description

A value binding assigns one generated source identifier and source type to a neutral value. Parameters and scalar locals share this representation so their names, identities, and types cannot drift in parallel arrays.

Usage

TccqBackendValueBinding(
  source_name = character(0),
  value_id = character(0),
  source_type = TccqType(),
  role = character(0)
)

Arguments

source_name

Generated source identifier.

value_id

Neutral value id.

source_type

Type represented by the generated identifier.

role

Whether the identifier is an ABI parameter or scalar local.


Program binding

Description

Program binding

Usage

TccqBinding(name = character(0), type = TccqType(), mutable = logical(0))

Arguments

name

Binding name.

type

Binding type.

mutable

Whether the binding may be mutated.


Local binding reference

Description

A binding reference is a lexical read of an already evaluated local. It retains the exact binding identity while pointing at the binding's storage value. Expression and effect traversal stop at this node; reading a local must not re-evaluate the graph that defined it.

Usage

TccqBindingReference(
  id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  attrs = list(),
  binding = TccqLocalBinding()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.

binding

Local binding being read.


Neutral statement block

Description

A block owns lexical local declarations and ordered typed statements. Its nesting is semantic: locals and statements inside one branch arm are not evaluated from another arm. A plain block does not imply that evaluation yields a value; TccqValueBlock adds that stronger completion contract.

Usage

TccqBlock(
  id = character(0),
  locals = list(),
  statements = list(),
  effect = TccqEffect()
)

Arguments

id

Stable block id.

locals

Ordered local write targets declared by the block.

statements

Ordered TccqStatement values.

effect

Exact effect summary of evaluating the statements.


Lazy conditional IR value

Description

TccqBranch is the value-level representation of R's if special form. Its three incoming value ids are analyzed eagerly by the compiler, but the recorded special-form semantics require generated code to evaluate exactly one result arm at runtime.

Usage

TccqBranch(
  id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  attrs = list(),
  condition = character(0),
  consequent = character(0),
  alternative = character(0),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.

condition

Scalar logical condition value id.

consequent

Value id produced when the condition is true.

alternative

Value id produced when the condition is false.

semantics

Evaluator facts for the originating if call.


Backend bridge plan

Description

Bridges model representation transitions such as ⁠SEXP -> host buffer⁠, host -> device, layout conversion, tile materialization, or R call-evaluation boundaries. They are explicit backend-plan values, not emitter branches.

Usage

TccqBridgePlan(
  id = character(0),
  kind = character(0),
  from_space = character(0),
  to_space = character(0),
  from_type = NULL,
  to_type = NULL,
  effect = TccqEffect(),
  attrs = list()
)

Arguments

id

Stable bridge id.

kind

Bridge kind.

from_space

Source memory space.

to_space

Destination memory space.

from_type

Optional source type.

to_type

Optional destination type.

effect

Bridge effect summary.

attrs

Structured bridge attributes.


R call observed by the frontend

Description

R call observed by the frontend

Usage

TccqCall(
  id = character(0),
  name = character(0),
  expr = NULL,
  origin = character(0),
  kind = character(0),
  arity = integer(0),
  argument_names = character(0),
  attrs = list()
)

Arguments

id

Stable call id.

name

Call name.

expr

Original R call expression.

origin

Source of the call observation.

kind

Structural call kind.

arity

Number of supplied arguments, or NA_integer_.

argument_names

Supplied argument tags.

attrs

Structured call attributes.


Indexed frontend call facts

Description

TccqCallIndex is the typed handoff from frontend analysis to later lowering passes. It keeps observed calls and evaluator facts aligned by stable call id.

Usage

TccqCallIndex(calls = list(), semantics = list(), attrs = list())

Arguments

calls

List of observed calls.

semantics

List of call evaluator facts.

attrs

Structured index attributes.


R call evaluator facts

Description

TccqCallSemantics records evaluator-level facts about an observed call. It is not a lowering decision: special forms, builtins, closures, replacement calls, group generics, and unknown calls still need later operation and backend implementations.

Usage

TccqCallSemantics(
  call = TccqCall(),
  evaluator_kind = character(0),
  forcing_policy = character(0),
  dispatch_kind = character(0),
  lexical_scope = logical(0),
  replacement = logical(0),
  control = logical(0),
  attrs = list()
)

Arguments

call

Observed call.

evaluator_kind

Evaluator kind.

forcing_policy

Promise-forcing policy.

dispatch_kind

Dispatch family.

lexical_scope

Whether lexical closure environment matters.

replacement

Whether this is a replacement-function call.

control

Whether this is a control-form call.

attrs

Structured semantic attributes.


Mutable lexical cell

Description

A cell is storage for loop-carried scalar state. It is deliberately distinct from TccqLocalBinding, whose identity remains one immutable SSA definition. Source names are assigned later by the backend interface.

Usage

TccqCell(
  name = character(0),
  type = TccqType(),
  mutable = logical(0),
  value_id = character(0),
  storage_type = TccqType()
)

Arguments

name

Binding name.

type

Binding type.

mutable

Whether the binding may be mutated.

value_id

Stable storage identity.

storage_type

Scalar storage type.


Lowered mutable-cell read

Description

Lowered mutable-cell read

Usage

TccqCellReference(
  id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  attrs = list(),
  cell = TccqCell()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.

cell

Mutable cell being read.


Value-producing neutral conditional

Description

This is the stricter value-producing form of TccqIf. Both arms must be value blocks writing the same target, and the retained TccqBranch must agree with the procedural control facts. The branch retains the effect of the source value; the statement effect covers only work left in its normalized arms after reductions or contractions have been extracted.

Usage

TccqConditional(
  id = character(0),
  effect = TccqEffect(),
  condition = TccqExpression(),
  consequent = TccqBlock(),
  alternative = TccqBlock(),
  semantics = TccqCallSemantics(),
  branch = TccqBranch()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

condition

Scalar logical condition expression.

consequent

Block evaluated when the condition is true.

alternative

Block evaluated when the condition is false.

semantics

Evaluator facts for the originating if special form.

branch

Source branch payload retaining R special-form semantics.


Contraction implementation metadata

Description

A contraction spec is attached to an operation implementation when calls to that implementation lower to a loop nest that multiplies (or otherwise combines) aligned elements along shared reduce axes and folds them with a reducer, such as %*%. It carries the shared operation signature, the reducer used for the fold, and the elementwise combine operation applied before folding.

Usage

TccqContractionSpec(
  name = character(0),
  signature = TccqOpSignature(),
  reducer = TccqFoldReductionSpec(),
  combine_op = character(0),
  attrs = list()
)

Arguments

name

Human-readable contraction name.

signature

Shared operation signature.

reducer

Reduction metadata used for the contracted axes.

combine_op

Elementwise operation name combining aligned elements.

attrs

Structured contraction metadata.


Structured control completion

Description

Completion is distinct from TccqEffect. It records whether structured control may reach the next statement or transfer to the nearest enclosing loop. These facts let dominance and later transformations reason about normal paths without treating break or next as fabricated side effects.

Usage

TccqControlCompletion(
  falls_through = logical(0),
  breaks = logical(0),
  continues = logical(0)
)

Arguments

falls_through

Whether evaluation may reach the next statement.

breaks

Whether evaluation may break from the nearest enclosing loop.

continues

Whether evaluation may continue the nearest enclosing loop.


Dead-store optimization

Description

This optimization removes assignments to compiler-owned local or cell storage when the target is never read and evaluating the assigned expression cannot write, allocate, cross a boundary, signal an error, or warn. It is deliberately limited to structured neutral program bodies; graph-level dead value elimination must also rewrite schedules, regions, fusion contracts, storage lifetimes, and allocations and therefore requires a separate pass.

Usage

TccqDeadStoreOptimization()

Compiler diagnostic value

Description

Diagnostics are values first and condition payloads second. Compiler code should pass these objects around instead of branching on condition strings.

Usage

TccqDiagnostic(
  code = character(0),
  message = character(0),
  phase = character(0),
  path = character(0),
  data = list()
)

Arguments

code

Stable diagnostic code.

message

Human-facing message.

phase

Compiler phase that produced the diagnostic.

path

Optional path into the program or schema.

data

Structured diagnostic payload.


Shape dimension

Description

Shape dimension

Usage

TccqDim(kind = character(0), label = character(0), value = integer(0))

Arguments

kind

Dimension kind.

label

Symbolic dimension label.

value

Constant dimension value.


Typed declared-dimension reference

Description

A dimension reference identifies the scalar ABI extent corresponding to one declared symbolic dimension. It is distinct from an ordinary scalar binding with the same source spelling.

Usage

TccqDimensionReference(
  source_value_id = character(0),
  symbol = character(0),
  binding = NULL,
  slice_offsets = integer(0),
  access = NULL,
  dimension = TccqDim()
)

Arguments

source_value_id

Logical value id supplying the referenced storage.

symbol

Optional source symbol, or an empty string when not applicable.

binding

Optional lexical binding represented by the reference.

slice_offsets

Zero-based slice offsets, or an empty integer vector.

access

Optional typed domain access attached by loop-nest planning.

dimension

Declared symbolic dimension supplied by the reference.


Iteration domain

Description

A domain is the semantic iteration space for elementwise, reduction, stencil, or tiled work. It is separate from shape so transformed programs can name and reuse iteration spaces directly.

Usage

TccqDomain(
  id = character(0),
  shape = TccqShape(),
  axes = character(0),
  attrs = list()
)

Arguments

id

Stable domain id.

shape

Domain shape.

axes

Axis names.

attrs

Structured domain attributes.


Operation domain policy

Description

A domain policy describes how input shapes determine an operation result shape before target source generation. It is the typed home for rules such as scalar broadcast, common elementwise domains, and scalar reducer results.

Usage

TccqDomainPolicy(
  name = character(0),
  result_shape = function() NULL,
  attrs = list()
)

Arguments

name

Human-readable domain policy name.

result_shape

Function from input TccqType list to result TccqShape.

attrs

Structured domain-policy metadata.


Compiler effect summary

Description

Compiler effect summary

Usage

TccqEffect(
  reads = logical(0),
  writes = logical(0),
  allocates = logical(0),
  boundary = logical(0),
  may_error = logical(0),
  may_warn = logical(0)
)

Arguments

reads

Whether the operation reads program state.

writes

Whether the operation writes program state.

allocates

Whether the operation allocates storage.

boundary

Whether the operation crosses an unsupported boundary.

may_error

Whether the operation may signal at runtime.

may_warn

Whether the operation may warn at runtime.


Elementwise implementation metadata

Description

An elementwise spec is attached to an operation implementation when calls to that implementation can lower to elementwise values over the compiler domain model. It carries an operation signature so lowering does not recognize elementwise operations by spelling.

Usage

TccqElementwiseSpec(
  name = character(0),
  signature = TccqOpSignature(),
  attrs = list()
)

Arguments

name

Human-readable elementwise operation name.

signature

Shared operation signature.

attrs

Structured elementwise metadata.


Scheduled R evaluation

Description

One step records one executable top-level form after declarations have been removed. Assignment steps carry the local binding they define; expression statements carry no binding. The effect summarizes the complete value graph evaluated by the step.

Usage

TccqEvaluationStep(
  value_id = character(0),
  statement_index = integer(0),
  binding = NULL,
  uses = list(),
  effect = TccqEffect()
)

Arguments

value_id

Lowered value evaluated by this step.

statement_index

One-based executable statement position.

binding

Optional local binding defined by the evaluation.

uses

Local bindings read by the evaluation.

effect

Effect of evaluating the complete step.


Backend-neutral expression tree

Description

TccqExpression is the small tree form consumed by source printers. It is built from typed lowered values and resolved operations, so C, Fortran, TinyCC, and later printers do not rediscover expression semantics from raw operation strings.

Usage

TccqExpression(
  id = character(0),
  kind = character(0),
  value_id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  literal = NULL,
  operation = NULL,
  branch = NULL,
  reference = NULL,
  index_proofs = list()
)

Arguments

id

Stable expression id.

kind

Expression kind.

value_id

Lowered value id represented by this expression.

op

Operation name, or formal/literal for leaves.

inputs

Child expressions.

type

Result type.

effect

Effect of evaluating the expression.

literal

Literal payload for literal expressions.

operation

Typed lowered-operation payload for operation expressions.

branch

Typed conditional payload for branch expressions.

reference

Typed source payload for reference expressions.

index_proofs

Per-axis bounds proofs for indexed expressions.


Typed expression reference

Description

A reference names the logical source value read by a neutral expression. It keeps lexical binding, source symbol, slice, and affine access facts out of open-ended expression metadata. Physical allocation remains a separate storage-plan concern.

Usage

TccqExpressionReference(
  source_value_id = character(0),
  symbol = character(0),
  binding = NULL,
  slice_offsets = integer(0),
  access = NULL
)

Arguments

source_value_id

Logical value id supplying the referenced storage.

symbol

Optional source symbol, or an empty string when not applicable.

binding

Optional lexical binding represented by the reference.

slice_offsets

Zero-based slice offsets, or an empty integer vector.

access

Optional typed domain access attached by loop-nest planning.


Scalar fold reduction metadata

Description

A fold reduction has one accumulator identity, one combine operation, and an optional finalizer. Its neutral loop state has exactly one component.

Usage

TccqFoldReductionSpec(
  name = character(0),
  signature = TccqOpSignature(),
  associative = logical(0),
  commutative = logical(0),
  empty_policy = character(0),
  attrs = list(),
  identity = function() NULL,
  combine_op = character(0),
  finalize_op = character(0)
)

Arguments

name

Human-readable reduction name.

signature

Shared operation signature.

associative

Whether the reducer is associative under its declared semantics.

commutative

Whether the reducer is commutative under its declared semantics.

empty_policy

Behavior when no value contributes to the reduction.

attrs

Structured reduction metadata.

identity

Function from result TccqType to identity TccqLiteral.

combine_op

Registered elementwise operation combining the accumulator and current value.

finalize_op

Optional registered elementwise operation combining the completed accumulator and reduced element count.


Neutral for statement

Description

A for loop evaluates one typed iteration plan and assigns each selected element to its iteration cell before evaluating the body. Source evaluation, element selection, and iteration domain are explicit so source backends do not reconstruct traversal from R syntax.

Usage

TccqFor(
  id = character(0),
  effect = TccqEffect(),
  body = TccqBlock(),
  semantics = TccqCallSemantics(),
  iterator = TccqWriteTarget(),
  iteration = TccqIterationPlan()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.

iterator

Mutable scalar destination receiving each element.

iteration

Backend-neutral iteration plan.


Fusion operation contract

Description

TccqFusionContract is the typed payload attached to a fusion group after region planning. It keeps the lowered operation payloads, signatures, domain policies, typed result value, optional result operation, and storage strategy together so fusion legality and later optimization passes do not inspect loose group attributes. Control values such as TccqBranch are valid fusion results even when the group contains no lowered operations.

Usage

TccqFusionContract(
  fusion_kind = character(0),
  storage_strategy = character(0),
  operations = list(),
  result_value = TccqValue(),
  result_operation = NULL,
  operation_signatures = list(),
  domain_policies = list(),
  attrs = list()
)

Arguments

fusion_kind

Fusion kind owned by the contract.

storage_strategy

Storage strategy requested by the fusion plan.

operations

Named lowered operations by value id.

result_value

Typed value produced by the fusion group.

result_operation

Optional lowered operation carried by result_value.

operation_signatures

Named operation signatures by value id.

domain_policies

Named domain policies by value id.

attrs

Structured metadata.


Fusion group

Description

A fusion group is a typed plan candidate, not emitted code. It groups values that may share one domain and region when operation implementations, effects, access maps, layout, and backend constraints allow it.

Usage

TccqFusionGroup(
  id = character(0),
  kind = character(0),
  domain = TccqDomain(),
  values = list(),
  outputs = character(0),
  accesses = list(),
  region_kind = character(0),
  target = character(0),
  effect = TccqEffect(),
  contract = NULL,
  attrs = list()
)

Arguments

id

Stable fusion-group id.

kind

Fusion kind.

domain

Shared iteration domain.

values

List of IR values in the group.

outputs

Output value ids.

accesses

List of access mappings.

region_kind

Candidate execution region kind, or any.

target

Candidate implementation target, or any.

effect

Effect summary for the fused group.

contract

Typed fusion operation/storage contract.

attrs

Structured fusion attributes.


Neutral procedural if statement

Description

Neutral procedural if statement

Usage

TccqIf(
  id = character(0),
  effect = TccqEffect(),
  condition = TccqExpression(),
  consequent = TccqBlock(),
  alternative = TccqBlock(),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

condition

Scalar logical condition expression.

consequent

Block evaluated when the condition is true.

alternative

Block evaluated when the condition is false.

semantics

Evaluator facts for the originating if special form.


Proven scalar indexed read

Description

This value represents one scalar extraction only when every source axis has a TccqIndexProof. Proofs may share an iteration, as in a diagonal read. The stored access is zero-based; iterator cells retain R's one-based values. No general R subscript semantics are implied by this class.

Usage

TccqIndexedValue(
  id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  attrs = list(),
  source_type = TccqType(),
  index_proofs = list(),
  access = TccqAccess(),
  operation = TccqLoweredOperation(),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.

source_type

Type of the source storage.

index_proofs

Per-axis affine selector and bounds proofs.

access

Zero-based source access corresponding to the proofs.

operation

Lowered subscript implementation payload.

semantics

Evaluator facts for the originating [ call.


Affine index expression

Description

An index expression maps one stored-tensor axis into the iteration space of a loop nest as axis + offset, or to a constant position when axis is empty. It is the typed unit of access maps, so stencil shifts, broadcasts, and transposes are dimension facts rather than printed index strings.

Usage

TccqIndexExpr(axis = character(0), offset = integer(0))

Arguments

axis

Iteration-axis name, or empty for a constant index.

offset

Signed integer offset (zero-based).


Proven affine scalar index

Description

An index proof ties one R iterator cell to one source axis. The iteration establishes the cell range, index is the zero-based storage access, and source_extent proves that the full affine access remains in bounds. A non-zero offset additionally retains the resolved + call and its evaluator facts; the range proof is what discharges integer overflow and subscript warnings for that normalized selector.

Usage

TccqIndexProof(
  iterator = TccqWriteTarget(),
  selector = TccqCellReference(),
  iteration = TccqIterationPlan(),
  source_extent = TccqDim(),
  index = TccqIndexExpr(),
  operation = NULL,
  semantics = NULL
)

Arguments

iterator

Iterator target populated by the enclosing virtual loop.

selector

Direct reference to the iterator cell.

iteration

Virtual iteration establishing the selector range.

source_extent

Extent of the indexed source axis.

index

Zero-based affine storage index.

operation

Lowered selector operation for a shifted index, or NULL.

semantics

Evaluator facts for the shifted selector call, or NULL.


Backend-neutral iteration plan

Description

An iteration plan separates one-time source evaluation from selection of the current element. Stored-vector iteration carries a typed element expression with an access map. Virtual unit sequences carry an affine index expression and the resolved operation implementation that defines the sequence.

Usage

TccqIterationPlan(
  source = TccqExpression(),
  domain = TccqDomain(),
  element = TccqExpression(),
  element_type = TccqType(),
  resolved_op = NULL,
  semantics = NULL,
  effect = TccqEffect()
)

Arguments

source

Expression evaluated once to establish iteration.

domain

One-dimensional iteration domain.

element

Current element expression or affine induction value.

element_type

Scalar type assigned to the iteration cell.

resolved_op

Resolved operation for virtual iteration, or NULL for stored-value iteration.

semantics

Evaluator facts for the virtual iteration call, or NULL.

effect

Effect summary for source evaluation and element selection.


Iteration implementation metadata

Description

An iteration spec describes an operation whose result can be consumed as a virtual one-dimensional iteration space. The shared signature owns argument and result typing; extent_arg selects the argument proving the domain extent, while start defines the first affine induction value. The current form deliberately represents unit-stride sequences only.

Usage

TccqIterationSpec(
  name = character(0),
  signature = TccqOpSignature(),
  extent_arg = integer(0),
  start = integer(0)
)

Arguments

name

Human-readable iteration operation name.

signature

Shared operation signature.

extent_arg

One-based argument position supplying the domain extent.

start

First integer value produced by the iteration.


Scalar literal value

Description

Scalar literal value

Usage

TccqLiteral(kind = character(0), type = TccqType(), value = NULL)

Arguments

kind

Literal kind.

type

Scalar type.

value

Literal payload.


Local value binding

Description

A local binding records the value produced by one top-level assignment in the declared subset. Its statement position is a semantic definition boundary used by scheduling; it is not source-printer metadata.

Usage

TccqLocalBinding(
  name = character(0),
  type = TccqType(),
  mutable = logical(0),
  value_id = character(0),
  statement_index = integer(0)
)

Arguments

name

Binding name.

type

Binding type.

mutable

Whether the binding may be mutated.

value_id

Lowered value bound to the local name.

statement_index

One-based executable statement position defining the binding.


Neutral sequential loop

Description

Abstract parent for sequential loops whose body is a typed statement block. Concrete loop classes add their own entry and completion rules.

Usage

TccqLoop(
  id = character(0),
  effect = TccqEffect(),
  body = TccqBlock(),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.


Loop-nest iteration axis

Description

An axis is one dimension of a loop-nest iteration space: a stable name, a typed extent, and a role. map axes produce output positions; reduce axes fold into an accumulator.

Usage

TccqLoopAxis(name = character(0), extent = TccqDim(), role = character(0))

Arguments

name

Iteration-axis name.

extent

Typed axis extent.

role

Axis role, map or reduce.


Selected-arm loop guard

Description

A loop guard records one branch decision that must select a loop nest. An ordered list of guards is a control path from outermost to innermost branch; source backends nest those guards around the same TccqLoopNest plan.

Usage

TccqLoopGuard(
  condition = TccqExpression(),
  branch = TccqBranch(),
  selected = logical(0)
)

Arguments

condition

Scalar logical condition expression.

branch

Source branch payload retaining R special-form semantics.

selected

Whether the consequent (TRUE) or alternative (FALSE) arm selects the guarded loop nest.


Loop-nest program plan

Description

TccqLoopNest is the single backend-neutral iteration plan consumed by source printers, in the spirit of the SAC with-loop. One loop nest carries ordered typed axes (map axes produce output positions, reduce axes fold into an accumulator), a value expression or typed statement block whose references carry typed affine accesses, an optional closed reduction plan, and an output access. Elementwise maps, full and per-axis reductions, contractions, stencils, and control-valued results are all instances of this one value; printers must not reintroduce per-family loop shapes or backend-local control trees.

Usage

TccqLoopNest(
  id = character(0),
  domain = TccqDomain(),
  axes = list(),
  body = TccqExpression(),
  output = NULL,
  reduction = NULL,
  storage = TccqStorageSlot(),
  guards = list()
)

Arguments

id

Stable loop-nest id.

domain

Iteration domain naming the axes.

axes

Ordered TccqLoopAxis values, outermost first.

body

Body expression or typed statement block with access-carrying references.

output

Output access over map axes, or NULL for scalar results.

reduction

Closed neutral reduction plan for reduce axes, or NULL.

storage

Typed storage slot receiving the nest result.

guards

Ordered TccqLoopGuard control path selecting this nest.


Neutral loop transfer statement

Description

A transfer is structured control completion, not a read/write side effect. Its action always targets the nearest enclosing sequential loop.

Usage

TccqLoopTransfer(
  id = character(0),
  effect = TccqEffect(),
  action = character(0),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

action

Loop action, either break or next.

semantics

Evaluator facts for the originating R control special form.


Lowered operation payload

Description

TccqLoweredOperation is the typed payload attached to operation values after lowering. It keeps operation family, selected implementation, signature, domain policy, and optional reducer facts together so later passes do not branch on loose value attributes.

Usage

TccqLoweredOperation(
  family = character(0),
  resolved_op = TccqResolvedOp(),
  signature = TccqOpSignature(),
  domain_policy = NULL,
  elementwise = NULL,
  reduction = NULL,
  contraction = NULL,
  subscript = NULL,
  attrs = list()
)

Arguments

family

Lowered operation family.

resolved_op

Selected operation implementation.

signature

Shared operation signature.

domain_policy

Optional result-domain policy.

elementwise

Optional elementwise metadata.

reduction

Optional reduction metadata.

contraction

Optional contraction metadata.

subscript

Optional subscript metadata.

attrs

Structured metadata.


Lowering plan

Description

A lowering plan is the typed result of lowering declared R language objects into backend-neutral values, regions, and storage facts. Backend printers consume this plan through TccqProgram; they do not re-discover compiler semantics from source text.

Usage

TccqLoweringPlan(
  values = list(),
  result = NULL,
  schedule = NULL,
  regions = list(),
  storage_plan = NULL,
  diagnostics = list(),
  attrs = list()
)

Arguments

values

List of lowered IR values.

result

Result value id, or NULL when no expression was lowered.

schedule

Optional ordered program evaluation schedule.

regions

List of executable code regions.

storage_plan

Optional middle-end storage plan.

diagnostics

List of diagnostics attached to lowering.

attrs

Structured lowering metadata.


Backend-neutral operation body

Description

An operation body is one R expression whose symbols are bound by exact call tags and then positionally through ⁠@parameters⁠. Its call index preserves the evaluator facts observed when the body was declared. Lowering expands the body into ordinary typed values before fusion, loop-nest planning, or backend rendering.

Usage

TccqOpBody(
  parameters = character(0),
  expression = quote(x),
  call_index = TccqCallIndex()
)

Arguments

parameters

Ordered operation parameter names.

expression

Unevaluated R expression implementing the operation.

call_index

Typed calls and evaluator facts for expression.


Operation support query context

Description

Operation support query context

Usage

TccqOpContext(
  phase = character(0),
  target = character(0),
  region_kind = character(0),
  memory_space = character(0),
  allow_rapi = logical(0),
  allow_boundary = logical(0)
)

Arguments

phase

Compiler phase issuing the query.

target

Requested implementation target, or any.

region_kind

Requested execution region kind, or any.

memory_space

Requested memory space, or any.

allow_rapi

Whether implementations touching the R C API are allowed.

allow_boundary

Whether explicit boundary implementations are allowed.


Operation implementation descriptor

Description

Operation implementation descriptor

Usage

TccqOpImpl(
  op = character(0),
  target = character(0),
  region_kind = character(0),
  memory_space = character(0),
  uses_rapi = logical(0),
  boundary = logical(0),
  pure = logical(0),
  effect = TccqEffect(),
  supports = function() NULL,
  render = NULL,
  body = NULL,
  elementwise = NULL,
  reduction = NULL,
  contraction = NULL,
  iteration = NULL,
  subscript = NULL
)

Arguments

op

Operation or function name.

target

Implementation target, such as r_language, pure_c, or fortran.

region_kind

Region kind the implementation can run in, or any.

memory_space

Memory space the implementation expects, or any.

uses_rapi

Whether the implementation touches the R C API.

boundary

Whether the implementation crosses a boundary.

pure

Whether the implementation is semantically pure.

effect

Effect summary for calls handled by this implementation.

supports

Predicate receiving a TccqCall and TccqOpContext.

render

Optional source renderer receiving operand strings and a TccqOpRenderContext.

body

Optional backend-neutral operation body.

elementwise

Optional elementwise metadata.

reduction

Optional reduction metadata.

contraction

Optional contraction metadata.

iteration

Optional iteration metadata.

subscript

Optional subscript metadata.


Operation implementation trait

Description

Implementations must explicitly opt into this trait before they can be used by an operation registry.

Usage

TccqOpImplementation

Operation registry

Description

Operation registry

Usage

TccqOpRegistry(implementations = list(), op_index = list())

Arguments

implementations

List of operation implementations.

op_index

Named list from operation name to implementation positions, used to resolve calls without scanning every implementation. Built by tccq_op_registry(); an empty index falls back to a full scan.


Operation source-rendering context

Description

Operation source-rendering context

Usage

TccqOpRenderContext(
  language = character(0),
  backend_id = character(0),
  attrs = list()
)

Arguments

language

Target source language.

backend_id

Backend requesting rendering.

attrs

Structured rendering metadata.


Operation signature metadata

Description

A signature is the shared operation contract for argument count and result typing. It may also carry a domain policy for result shape. Elementwise, reduction, and future operation families should carry a signature instead of each inventing their own arity, shape, and type checks.

Usage

TccqOpSignature(
  name = character(0),
  arity = TccqArity(),
  result_type = function() NULL,
  domain_policy = NULL,
  attrs = list()
)

Arguments

name

Human-readable operation signature name.

arity

A TccqArity contract.

result_type

Function from input TccqType list to result TccqType.

domain_policy

Optional result-shape policy.

attrs

Structured signature metadata.


Program schema

Description

Program schema

Usage

TccqProgram(
  values = list(),
  result = NULL,
  name = character(0),
  formals = list(),
  schedule = NULL,
  regions = list(),
  diagnostics = list(),
  call_index = NULL,
  storage_plan = NULL,
  attrs = list()
)

Arguments

values

List of IR values.

result

Result value id or object.

name

Program name.

formals

Named list of formal bindings.

schedule

Optional ordered program evaluation schedule.

regions

List of executable code regions.

diagnostics

List of diagnostics attached to the program.

call_index

Typed frontend call handoff.

storage_plan

Optional middle-end storage plan.

attrs

Structured program attributes.


Backend-neutral program body

Description

Marker parent for typed structured program bodies. Concrete bodies add lexical scope, statements, and value-completion contracts in the neutral expression layer.

Usage

TccqProgramBody()

Program optimization trait

Description

Optimizations explicitly opt into transformation and verification. The compiler invokes both through this contract before backend planning.

Usage

TccqProgramOptimization

Ordered program evaluation schedule

Description

The schedule is the semantic owner of top-level R evaluation order. Its linear steps are contiguous after declarations are removed. A structured body is the mutually exclusive control-flow form. In either form, the schedule produces the declared program result. Lowering and backend planning consume this value rather than reconstructing statement order from value ids or source text.

Usage

TccqProgramSchedule(steps = list(), result = character(0), body = NULL)

Arguments

steps

Ordered TccqEvaluationStep values.

result

Result value id produced by the final step.

body

Optional structured value-producing body.


Closed neutral reduction plan

Description

A reduction plan owns the reducer, its typed state, the optional condition guarding each transition, one typed assignment per state component, the completed-state projection, and an optional validity expression. No target source appears in this contract.

Usage

TccqReductionPlan(
  spec = TccqReductionSpec(),
  state = TccqReductionState(),
  condition = NULL,
  updates = list(),
  value = TccqExpression(),
  valid = NULL
)

Arguments

spec

Reduction implementation metadata.

state

Typed neutral state.

condition

Optional scalar logical transition condition.

updates

Ordered state-component assignments.

value

Scalar result projected from completed state.

valid

Optional scalar logical expression proving that value exists.


Reduction implementation metadata

Description

A reduction spec is attached to an operation implementation when calls to that implementation can lower to a typed reduction state. Concrete subclasses define that state and its transition; the lowerer and source printers consume the shared protocol instead of recognizing reducer names.

Usage

TccqReductionSpec(
  name = character(0),
  signature = TccqOpSignature(),
  associative = logical(0),
  commutative = logical(0),
  empty_policy = character(0),
  attrs = list()
)

Arguments

name

Human-readable reduction name.

signature

Shared operation signature.

associative

Whether the reducer is associative under its declared semantics.

commutative

Whether the reducer is commutative under its declared semantics.

empty_policy

Behavior when no value contributes to the reduction.

attrs

Structured reduction metadata.


Typed neutral reduction state

Description

Typed neutral reduction state

Usage

TccqReductionState(components = list())

Arguments

components

Named reduction-state components.


Reduction-state component

Description

A component is one typed scalar in a reducer's neutral state. Its semantic name is a portable identifier so backend interfaces can derive generated names without sanitizing arbitrary source text.

Usage

TccqReductionStateComponent(
  name = character(0),
  target = TccqWriteTarget(),
  identity = TccqLiteral()
)

Arguments

name

Semantic component name.

target

Neutral local target that stores the component.

identity

Initial scalar literal.


Executable code region

Description

Regions classify a group of IR values by where they may run and whether they may touch the R C API. kernel, parallel, and device regions are intended to be R-API-free.

Usage

TccqRegion(
  id = character(0),
  kind = character(0),
  values = list(),
  fusion_groups = list(),
  effect = TccqEffect(),
  memory_space = character(0),
  touches_rapi = logical(0),
  attrs = list()
)

Arguments

id

Stable region id.

kind

Region kind.

values

List of IR values in the region.

fusion_groups

List of fusion groups in the region.

effect

Region effect summary.

memory_space

Dominant memory space for the region.

touches_rapi

Whether the region may call into the R C API.

attrs

Structured region attributes.


Neutral repeat statement

Description

A repeat loop enters its body unconditionally and relies on a typed loop transfer to terminate or begin another iteration.

Usage

TccqRepeat(
  id = character(0),
  effect = TccqEffect(),
  body = TccqBlock(),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.


Resolved operation implementation

Description

A resolved operation records the implementation selected for one observed call in one operation context. Lowering and middle-end passes should carry this object rather than re-checking support from raw operation names.

Usage

TccqResolvedOp(
  call = TccqCall(),
  implementation = TccqOpImpl(),
  target = character(0),
  region_kind = character(0),
  memory_space = character(0),
  uses_rapi = logical(0),
  boundary = logical(0),
  pure = logical(0),
  effect = TccqEffect(),
  body = NULL,
  elementwise = NULL,
  reduction = NULL,
  contraction = NULL,
  iteration = NULL,
  subscript = NULL,
  attrs = list()
)

Arguments

call

Observed R call.

implementation

Selected operation implementation.

target

Selected implementation target.

region_kind

Region kind supplied by the implementation.

memory_space

Memory space supplied by the implementation.

uses_rapi

Whether the selected implementation touches the R C API.

boundary

Whether the selected implementation crosses a boundary.

pure

Whether the selected implementation is semantically pure.

effect

Effect summary supplied by the implementation.

body

Optional backend-neutral body supplied by the implementation.

elementwise

Optional elementwise metadata supplied by the implementation.

reduction

Optional reduction metadata supplied by the implementation.

contraction

Optional contraction metadata supplied by the implementation.

iteration

Optional iteration metadata supplied by the implementation.

subscript

Optional subscript metadata supplied by the implementation.

attrs

Structured resolution metadata.


Compiler result value

Description

Compiler result value

Usage

TccqResult(success = logical(0), value = NULL, diagnostics = list())

Arguments

success

Whether the phase completed without diagnostics.

value

Result value for the phase.

diagnostics

List of TccqDiagnostic values.


Shape value

Description

Shape value

Usage

TccqShape(rank = integer(0), dims = list())

Arguments

rank

Number of dimensions.

dims

List of TccqDim values.


Neutral statement

Description

Base class for typed statements consumed by source backends. Concrete statement classes own their operands and control structure.

Usage

TccqStatement(id = character(0), effect = TccqEffect())

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.


Physical storage allocation

Description

A storage allocation is the physical storage identity assigned to one or more non-overlapping materialized temporary slots. Sharing an allocation is the representation of storage reuse; it is not inferred by source printers.

Usage

TccqStorageAllocation(
  id = character(0),
  type = TccqType(),
  memory_space = character(0)
)

Arguments

id

Stable allocation id.

type

Semantic storage type shared by every assigned slot.

memory_space

Memory space in which the allocation exists.


Storage lifetime interval

Description

A storage lifetime records the definition and last-use positions used by storage reuse planning. It is a typed optimization fact, not source-printer metadata.

Usage

TccqStorageLifetime(
  value_id = character(0),
  defined_at = integer(0),
  last_used_at = integer(0)
)

Arguments

value_id

Value whose lifetime is described.

defined_at

Linear definition position in schedule-derived value order.

last_used_at

Last position where the value must remain live.


Storage plan

Description

A storage plan belongs to the middle end. It is consumed by backends but does not depend on C, Fortran, TinyCC, or any concrete emitter.

Usage

TccqStoragePlan(slots = list())

Arguments

slots

List of storage slots.


Storage slot

Description

A storage slot records whether a value is materialized, which typed lifetime it occupies, and which physical allocation owns a materialized temporary.

Usage

TccqStorageSlot(
  id = character(0),
  value_id = character(0),
  type = TccqType(),
  role = character(0),
  materialized = logical(0),
  lifetime = NULL,
  allocation = NULL
)

Arguments

id

Stable storage-slot id.

value_id

Value owned by this slot.

type

Slot value type.

role

Storage role.

materialized

Whether storage exists at runtime.

lifetime

Optional typed liveness interval for storage reuse.

allocation

Physical allocation for a materialized temporary.


Subscript implementation metadata

Description

A subscript spec describes one typed R indexing contract. The first slice is deliberately strict: one scalar integer selector per atomic source axis, with every enclosing iteration proving that its selector is one-based and in bounds. Other selector kinds require their own shape and bounds semantics.

Usage

TccqSubscriptSpec(name = character(0), signature = TccqOpSignature())

Arguments

name

Human-readable subscript operation name.

signature

Shared operation signature.


Neutral positional switch statement

Description

A positional switch evaluates one scalar integer selector exactly once, then evaluates at most one ordered alternative. An unmatched position evaluates no alternative, matching numeric switch() returning NULL when its value is used only for control. Character selection and value-producing switches require separate representation work.

Usage

TccqSwitch(
  id = character(0),
  effect = TccqEffect(),
  selector = TccqExpression(),
  selector_target = TccqWriteTarget(),
  alternatives = list(),
  semantics = TccqCallSemantics()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

selector

Scalar integer selector expression.

selector_target

Typed local target for the evaluate-once selector.

alternatives

Ordered positional alternative blocks.

semantics

Evaluator facts for the originating switch special form.


Declared compiler type

Description

Declared compiler type

Usage

TccqType(base = character(0), shape = TccqShape())

Arguments

base

Scalar or storage base type.

shape

Shape value.


IR value

Description

IR value

Usage

TccqValue(
  id = character(0),
  op = character(0),
  inputs = list(),
  type = TccqType(),
  effect = TccqEffect(),
  attrs = list()
)

Arguments

id

Stable value id.

op

Operation name.

inputs

Input value ids or references.

type

Result type.

effect

Effect summary.

attrs

Structured operation attributes.


Value-producing neutral statement block

Description

A value block strengthens TccqBlock by requiring its terminal statement to write one typed result target on every path. Array loop nests and reducers consume this subtype; future procedural control can use the base block without fabricating a result value.

Usage

TccqValueBlock(
  id = character(0),
  locals = list(),
  statements = list(),
  effect = TccqEffect(),
  result = TccqWriteTarget()
)

Arguments

id

Stable block id.

locals

Ordered local write targets declared by the block.

statements

Ordered TccqStatement values.

effect

Exact effect summary of evaluating the statements.

result

Typed target produced on every terminal path through the block.


Typed lowered value graph

Description

This parent owns the value graph shared by lowering plans and programs. It gives expression construction one typed input contract without coupling the neutral expression layer to either pipeline container.

Usage

TccqValueGraph(values = list(), result = NULL)

Arguments

values

List of lowered IR values.

result

Result value id, or NULL when no expression was lowered.


Neutral while statement

Description

This is sequential recurrence, not a TccqLoopNest. The condition is re-evaluated before every iteration and the body may update explicitly declared mutable cells.

Usage

TccqWhile(
  id = character(0),
  effect = TccqEffect(),
  body = TccqBlock(),
  semantics = TccqCallSemantics(),
  condition = TccqExpression()
)

Arguments

id

Stable statement id.

effect

Effect summary of evaluating the statement.

body

Procedural loop body.

semantics

Evaluator facts for the originating R loop special form.

condition

Scalar logical condition expression.


Neutral write target

Description

A write target names a typed value destination without spelling it in C, Fortran, or another target language. Result targets are resolved through a loop nest's output plan; local targets are mapped to generated names by TccqBackendFunctionInterface. The semantic type retains the value domain, while the scalar storage type describes the element written at this target.

Usage

TccqWriteTarget(
  value_id = character(0),
  type = TccqType(),
  storage_type = TccqType(),
  kind = character(0),
  binding = NULL
)

Arguments

value_id

Stable value id written by the target.

type

Semantic value type.

storage_type

Scalar storage type written at the target.

kind

Target kind: local, result, or cell.

binding

Optional binding owned by the target.