RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
    • Compilation Pipeline
    • Lexer & Parser
    • High-Level IR (HIR)
    • Mid-Level IR (MIR)
    • MIR & Static Analysis
Docs>Runtime>Compiler

Compilation Pipeline

The RunMat compilation pipeline converts MATLAB source text into shared semantic and executable products. Static analysis, VM bytecode, adaptive JIT compilation, and native object emission consume those products without defining separate source-language pipelines. RunMatSession in runmat-core orchestrates compilation for a project and execution request.

Pipeline Overview

Source passes through several intermediate representations before branching into execution-specific products:

  1. Lexer & Parser: Converts raw text into a Concrete Syntax Tree (CST) and then an Abstract Syntax Tree (AST).
  2. High-Level IR (HIR): Resolves scopes, performs variable binding, and handles MATLAB-specific constructs like command-form syntax and closure captures.
  3. Module Composition: Applies project source roots, package folders, class folders, private functions, dependencies, and entrypoints to source-aware resolution.
  4. Mid-Level IR (MIR): Lowers the HIR into a Control-Flow Graph (CFG) consisting of basic blocks, suitable for dataflow analysis.
  5. Static Analysis: Performs type/shape inference and definite assignment checks on the MIR.
  6. Executable Preparation: Packages MIR, analysis facts, bytecode, source maps, and stable identities for the VM, JIT, native compilation, and tooling.

System Architecture Diagram

The following diagram maps the logical pipeline stages to the specific code entities and crates responsible for each transformation.

Loading diagram...

See crates/runmat-core/src/session/compile.rs crates/runmat-core/src/session/mod.rs for more details.


Pipeline Stages

2.1 Lexer & Parser

The first stage uses the runmat-lexer crate (powered by the logos library) to tokenize input. The runmat-parser then consumes these tokens to produce a Program AST. This stage handles MATLAB's unique syntax rules, such as the distinction between row vectors and matrix rows based on whitespace or semicolons.

For details, see Lexer & Parser.

2.2 High-Level IR (HIR)

The HIR lowering stage transforms the AST into a HirAssembly. This process uses a LoweringContext to resolve variable bindings (HirBinding) and determine whether an identifier refers to a local variable, a global, or a function call.

For details, see High-Level IR (HIR).

2.3 Module Composition

Project source roots and dependencies provide the known symbols used for cross-file calls, package-qualified names, class-folder methods, private functions, imports, and named entrypoints.

For details, see Module Composition.

2.4 Mid-Level IR (MIR)

The runmat-mir crate flattens the HIR into a Control-Flow Graph (CFG). The MIR is organized into BasicBlock structures and uses MirLocal slots to represent stack locations. VM bytecode, static analysis, JIT compilation, and native object emission retain its control-flow and binding identities.

For details, see Mid-Level IR (MIR).

2.5 MIR Analysis & Static Analysis

The AnalysisStore is populated by running dataflow passes over the MIR. This includes:

  • Definite Assignment: Ensuring variables are initialized before use.
  • Type/Shape Inference: Recording tensor dimensions and numeric types for diagnostics, VM lowering, native specialization, and placement.

For details, see MIR Analysis & Static Analysis.


2.6 Executable Preparation

RunMatSession packages MIR, analysis facts, bytecode, source maps, program identities, and the environment revision into an immutable executable unit. The VM executes its bytecode. The JIT and runmat compile lower the retained MIR and analysis through verified Native IR.

Continue with VM Interpreter & Bytecode, JIT Compiler, or Native Compilation.

On this page
  • Pipeline Overview
  • System Architecture Diagram
  • Pipeline Stages
  • 2.1 Lexer & Parser
  • 2.2 High-Level IR (HIR)
  • 2.3 Module Composition
  • 2.4 Mid-Level IR (MIR)
  • 2.5 MIR Analysis & Static Analysis
  • 2.6 Executable Preparation