Compiler, LSP & Exporters

Architectura separates authoring-time host tooling from the runtime semantic libraries: archsemc, archsem-lang, archsem-lsp, archsem-gen, archsem-export, and archsem-uops-info are host-only tools and are never cargo build dependencies of archsem-core, archsem-x86, or archsem-arm64.

archsemc: The Asem Compiler CLI

archsemc drives archsem-lang to type-check, verify, format, inspect, and emit Rust modules or portable .asemc packages from .asem sources.

Commands & Flags

# Parse, type-check, and run the canonical verifier (add --lint for static lints)
archsemc check [--lint] [--deny-dead-values] <file.asem>

# Emit checked-in Rust to stdout
archsemc build --emit rust <file.asem>

# Write or drift-check a generated Rust file (--out <path> is REQUIRED with --write or --check)
archsemc build --emit rust --out archsem-x86/src/generated/opmask_programs.rs --write semantics/x86/opmask.asem
archsemc build --emit rust --out archsem-x86/src/generated/opmask_programs.rs --check semantics/x86/opmask.asem

# Use --source-label to set a custom provenance banner path (used by ARM64 modules)
archsemc build --emit rust --source-label semantics/arm64/<name>.asem \
  --out archsem-arm64/src/programs/<name>.rs --write semantics/arm64/<name>.asem

# Emit a portable, re-verifiable .asemc package
archsemc build --emit asemc --out path/to/output.asemc --write <file.asem>

# Check or normalize canonical whitespace (LF, 4-space tabs, no trailing spaces)
archsemc fmt --check <file.asem>
archsemc fmt --write <file.asem>

[!IMPORTANT] When running archsemc build with --write or --check, you must pass --out <path>. Omitting --out defaults to --stdout (and returns an error if --write or --check is specified).

archsemc schematic: Symbolic & Graph View

archsemc schematic reconstructs a verified program into folded, architecturally named expressions (using the file's register declarations and ISA flag spellings):

archsemc schematic semantics/arm64/conditional_ops.asem --program CCMP
program CCMP    route "CCMP"    arm64.conditional_ops ยท 22 slot(s), 27 top-level op(s)
  reads    op0  op1  cond
  writes   N  Z  C  V
  memory   none
  control  fall-through
  render   complete

  %cond : 1 = cond_holds(insn.cond)
  %r    : W = op0 - op1
  N <- %cond ? %r <s 0 : imm(op2)[3]
  Z <- %cond ? %r == 0 : imm(op2)[2]
  C <- %cond ? op0 >=u op1 : imm(op2)[1]
  V <- %cond ? ((op0 ^ op1) & (op0 ^ %r)) <s 0 : imm(op2)[0]
  end fall-through

Pass --emit dot for Graphviz DOT or --emit json for machine-readable dataflow graphs (--internal includes non-routed subprograms; --out <path> writes to disk). The archsem-lang test suite enforces render complete across the entire checked-in semantics/ corpus.

archsem-lsp & the Zed Extension (editors/zed/asem)

archsem-lsp is the Language Server Protocol front end for Asem:

archsem-lsp [--trace FILE]        # Speak LSP over stdin/stdout
archsem-lsp --check-json NAME     # Compile stdin and emit JSON diagnostics (isolated subprocess)

It provides:

  • Live diagnostics from the canonical archsem-core verifier (including imported declarations)
  • Hover information showing verified slot and top-level micro-op counts
  • Inlay hints displaying allocated @slot numbers on let bindings
  • Completion and full semantic token highlighting (Asem has no tree-sitter grammar; highlighting is driven by LSP semantic tokens)

The companion Zed editor extension lives in editors/zed/asem (targeting wasm32-wasip2). Configure Zed with "semantic_tokens": "full" and "inlay_hints": { "enabled": true } under "languages": { "Asem": { ... } }, and install via editors/zed/asem/install.ps1 (or Zed's install dev extension).

archsem-export: Semantic Table & Coverage Export

archsem-export (publish = false, host-only) exports audited declarative tables, resolved SemPrograms, ImplementationDispositions, and decoder-catalog coverage as JSON:

archsem-export x86 > x86.json
archsem-export arm64 > arm64.json
archsem-export coverage x86 > x86-coverage.json
archsem-export coverage arm64 > arm64-coverage.json
archsem-export coverage x86 --profile x86.avx > x86-avx-coverage.json
archsem-export inspect x86 4801d8
archsem-export inspect arm64 d2800020

Coverage generation independently resolves each decoder form's implementation disposition (implemented, implemented_with_opaque_boundary, explicit_opaque, explicit_unsupported) and validates that every reviewed CoverageLabel (Faithful, Partial, Opaque, Absent) matches its implementation before emitting JSON.

archsem-uops-info: Offline Performance Importer

archsem-uops-info (publish = false, host-only) imports a caller-supplied, pinned uops.info instructions.xml snapshot offline (performing no network access during generation) using a crosswalk CSV (xed_iform,iced_code,mode):

archsem-uops-info \
  --input path/to/instructions.xml \
  --crosswalk path/to/crosswalk.csv \
  --output x86_perf.json \
  --coverage x86_perf_coverage.json \
  [--dataset-version LABEL] [--dataset-date YYYY-MM-DD]

It validates exact case-sensitive iced Code spellings and execution modes (16, 32, 64), hashes the input XML with SHA-256 for provenance, and emits archsem-x86::performance dataset artifacts and coverage reports.