Execution, Recording & Lowering
Architectura provides four execution and backend consumers alongside archsem-ir:
archsem-ref— Independent bounded concrete reference oraclearchsem-symex— Self-contained bounded symbolic & concolic execution and proof obligationsarchsem-record— Action-stream recorder (IrEmitter→ serializableRecordedInstruction)archsem-llvm— Reference LLVM IR emitter and Register-SSA lowering backend
Concrete Reference Execution (archsem-ref)
archsem-ref is an independent concrete interpreter (#![forbid(unsafe_code)]) used as a common-mode-failure oracle against archsem-simplify, archsem-symex, and archsem-llvm. It deliberately maintains its own 1–512-bit BitVector evaluator rather than sharing evaluation code with archsem-simplify or archsem-symex.
- Definedness: Raw shifts/rotates with count
>= width, division/remainder by zero,INT_MIN / -1, and invalid lane indices returnPartialOperationinstead of panicking or inheriting host overflow. - Pluggable Environment (
ReferenceEnvironment): ComposesRegisterEnvironment,MemoryEnvironment,ChoiceEnvironment,FloatingPointEnvironment, andOpaqueEnvironment.- The stock
ConcreteEnvironmentstores exact(RegisterId, bits)cells and byte-addressed sparse memory keyed by(AddrSpace, BitVector). - Optional
arm64-guestfeature connectsConcreteEnvironment::with_arm64_bindingsandwith_arm64_servicesto exact AArch64 FP, SVE/SME VL/SVL, MOPS, MTE, RCW/LSFE, LS64, and TIndex policies.
- The stock
- Fault Visibility (
ReferenceExecution::visible_state):ReferenceExecutionseparates raw environment mutations (outcome: ExecutionOutcome) fromArchitecturallyVisibleState(Exact,CanonicalPrefix,PermittedMemorySubset, orUnsupported(ReferenceVisibilityBoundary)when an eager environment cannot roll back aRestartablefault). - Suspensible Opaque Execution:
ReferenceEmitter::suspend()/ReferenceEmitterState::resume()allows embeddings (such asarchsem-lua/runtime) to complete reentrant guest services without losing session counters, choices, or transaction state.
Bounded Symbolic & Concolic Execution (archsem-symex)
archsem-symex lowers a complete Function via RegisterSsa into SymbolicProgram block templates and explores paths deterministically within explicit ExecutionConfig budgets—without requiring LLVM or an external SMT solver.
[!WARNING] Licensing:
archsem-symexdepends onbitwright(PolyForm-Noncommercial-1.0.0). Noncommercial use is free; commercial use requires a license frombitwright's licensor.
Symbolic Engine & bitwright Integration
- Context-Owned Arena (
ExprArena): Structurally interned 1–512-bit expressions with exact widths, ternaryselects, conservative symbols, and scopedChoices (FreshPerObservation,ProducedValue,InstructionExecution, persistent scopes). - Total Translation + Definedness Guards: Each node translates into a total
bitwrightbitvector value paired with a 1-bit invalidness guard (1iff a partial operation is violated). Invalid operations are excluded from path-condition input inference so path pruning never erases a shift/division definedness obligation. - Deterministic Constraint Solving & Simplification: Each path maintains
bitwrightconstraints (known bits, signed/unsigned ranges, equality classes) and prunes only proven contradictions. Reported expressions are simplified (and optionally equality-saturated viaSimplificationBudgets::max_saturation_work_per_expression) deterministically. - Nested Resource Budgets (
ExecutionConfig): Independently capsPathBudgets(max_steps_per_path,max_paths,max_block_visits_per_path),ExpressionBudgets,SubstitutionBudgets,RecursionBudgets,MemoryBudgets,SimplificationBudgets, andDiagnosticBudgets. Each limit produces a typedBudgetKindexit. - Policy Boundaries (
ExecutionContext): Unmodeled memory, opaque intrinsics, calls, fences, atomics, reservations, transactions, and faults fail closed withPathExit::Unsupported(UnsupportedReason)unless the caller injects a path-localMemoryPolicy(e.g.,ExactByteMemoryfor concrete bytes),IntrinsicPolicy,CallPolicy, orEffectPolicy. All policy mutations are staged transactionally per path.
Concolic Execution (execute_concolic)
execute_concolic executes a single deterministic path guided by a ConcolicTrace of typed branch, switch, indirect-target, and concrete ordinary-memory observations. It returns the consumed observations, exact path condition, and negated exploration alternatives, stopping cleanly at any missing, mismatched, or ambiguous boundary.
Proof Obligations & Validation Artifacts
ProofObligation/ProofObligationArtifact: Projects caller-selected inputs and one path's reachable outputs into solver-neutralProofTermOpDAGs (tNtopological names, per-term provenance/fidelity, typed assumption/definedness/fault/output roots) exportable to bounded JSON/RON.InstructionValidationObligation&InstructionCounterexampleArtifact: Packages a complete instruction/case validation handoff (inputs, choices, preconditions, observable roots, faults, register deltas, rewrite mappings, and bounds). External solver models can be replayed againstInstructionCounterexampleArtifactto verify mismatches and map them backward through rewrite provenance.- Rewrite Checking (
transform-checkfeature):check_fragment_transformandcheck_function_transformprovide translation-validation checks for fragment/function rewrites during fuzzing and testing.
Action Recording (archsem-record)
ActionRecorder implements IrEmitter<Value = ValueRef> to record every emitted semantic action as a self-typed SemanticAction trace without committing to any compiler IR:
ActionRecorder::finish(control)validates definition order, widths (1..=512), choice identities, memory contracts, transaction/progress placement, and terminal consistency, returning aRecordedInstructionwith stableEventIds, internedSemanticSites, andRecordedControlEffect.- With the
serdefeature enabled,RecordedInstructionserializes cleanly to JSON for inspection, cross-architecture diffing, or external transpilation.
Reference LLVM Backend (archsem-llvm)
archsem-llvm (publish = false, host-only, linking LLVM 21.1 via llvm-sys) provides LlvmEmitter, proving the framework's IR-agnostic design on a production compiler IR:
- Uniform Integer Values: Every
IrEmitter::Valueis an LLVM integer of exact bit width (1..=512); registers use width-typedallocas in the prologue initialized withfreeze undef(never raw per-useundefor poison); floating-point opsbitcastacrossfloat/double. - Choice Bindings:
LlvmEmitter::newaccepts non-persistent choices;LlvmEmitter::new_with_choice_bindingstakes aChoiceBindingEnvironmentto declare and load immutable external symbols for persistent scopes (ExecutionSession,MachineProfile,ExternallySupplied). - Conservative Lowering of Unmodeled Contracts: Unsupported guest-memory contracts, fences, and valid fall-through
OpaqueIntrinsics lower to single observable external calls retaining full typed diagnostics (MemoryLoweringDiagnostic,FenceLoweringDiagnostic,OpaqueLoweringDiagnostic). Opt-inenable_guest_fault_reporting_loads()lowersLoadTryto packed(data, fault)guest helper calls. - Register-SSA Lowering (
RegisterSsaReplaySink):Function::replay_register_ssalowers complete functions into LLVM basic blocks andphinodes (using bridge predecessors where needed) and emits external ABI boundaries@archsem.return,@archsem.jump.*, and@archsem.call.*.