Skip to main content

Crate codegen

Crate codegen 

Source
Expand description

§solar-codegen

Solidity MIR (Mid-level Intermediate Representation) and EVM code generation for Solar.

§Architecture

HIR (from solar-sema) -> Lowering -> MIR -> Code Generation -> EVM Bytecode

§MIR Structure

  • Module: Top-level container with functions, data segments, and storage layout
  • Function: SSA-form functions with basic blocks, values, and instructions
  • BasicBlock: Sequence of instructions ending with a terminator
  • Instruction: Operations (arithmetic, memory, storage, control flow)
  • Value: SSA values (instruction results, arguments, immediates, phi nodes)

§Key Types

  • ValueId, InstId, BlockId, FunctionId: Index types for SSA values
  • MirType: Types used in MIR (UInt, Address, MemPtr, StoragePtr)
  • InstKind: Instruction variants (Add, Sub, SLoad, SStore, Call, etc.)
  • Terminator: Block terminators (Jump, Branch, Return, Revert)

Modules§

analysis
MIR analysis passes.
backend
The backend protocol.
lower
HIR to MIR lowering.
mir
Mid-level Intermediate Representation (MIR).
pass
Pass infrastructure for MIR transformations and analyses.
sema
solar-sema
transform
Optimization and transformation passes for the Solar compiler.

Structs§

AssembledCode
Result of assembly.
Assembler
Two-pass assembler for EVM bytecode.
AssemblerConfig
Configuration for EVM bytecode assembly.
BasicBlock
A basic block in the MIR.
BlockId
A unique identifier for a basic block in the MIR.
CommonSubexprEliminator
Common Subexpression Elimination pass.
DceStats
Statistics for a DCE run.
DeadCodeEliminator
Dead Code Elimination pass.
EvmArtifact
The artifact produced by the EVM backend: deployment and runtime bytecode.
EvmCodegen
EVM code generator.
EvmCodegenConfig
Configuration for the EVM backend.
EvmIrBlock
A basic block in EVM IR.
EvmIrBlockId
A unique identifier for a basic block in EVM IR.
EvmIrBlockMetadata
Block-level metadata.
EvmIrInstruction
A non-terminating untyped backend instruction.
EvmIrMetadata
Generic metadata carried by instructions and terminators.
EvmIrMetadataItem
A metadata key-value item.
EvmIrModule
An EVM IR module.
EvmIrParseError
An error produced while parsing the EVM IR text format.
EvmIrStackEffect
Stack effect metadata for one EVM IR operation.
EvmIrTerminator
A control-flow terminator.
EvmIrValue
A named untyped stack word.
EvmIrValueId
A unique identifier for an untyped stack word in EVM IR.
Function
A function in the MIR.
FunctionId
A unique identifier for a function in the MIR.
FunctionInlineInfo
Analysis result for a function’s inlineability.
InductionVariable
An induction variable in a loop.
InlineAnalyzer
Analyzes functions for inlining opportunities.
InlineConfig
Configuration for function inlining.
InlineStats
Statistics about inlining performed.
InstId
A unique identifier for an instruction in the MIR.
InstSimplifier
Local MIR instruction simplification pass.
Instruction
An instruction in the MIR.
JumpThreader
Jump threading optimization pass.
JumpThreadingStats
Statistics from jump threading optimization.
Label
A label identifier.
Liveness
Liveness analysis results for a function.
LivenessInfo
Per-instruction liveness information.
Loop
A natural loop in the control flow graph.
LoopAnalyzer
Loop analyzer that detects and analyzes loops in MIR functions.
LoopInfo
Result of loop analysis for a function.
LoopOptConfig
Loop optimization pass configuration.
LoopOptStats
Statistics from loop optimization.
LoopOptimizer
Loop optimizer.
Lowerer
Lowering context for converting HIR to MIR.
Module
A MIR module representing a compiled contract.
SpillManager
Manages spill slots for values that cannot fit on the stack.
SpillSlot
A slot in memory where a spilled value is stored.
StackModel
Represents the current state of the EVM stack.
StackScheduler
Stack scheduler that generates stack manipulation operations.
ValueId
A unique identifier for a value in the MIR.

Enums§

EvmIrBlockHotness
Block hotness metadata.
EvmIrOperand
An instruction or terminator operand.
EvmIrTerminatorKind
Control-flow terminators in EVM IR.
Immediate
An immediate constant value.
InlineDecision
Inlining decision for a function.
InstKind
The kind of an instruction.
MirType
Types used in MIR.
OptLevel
Optimization level for the compiler.
Terminator
A block terminator instruction.
Value
An SSA value in the MIR.

Constants§

IMMUTABLE_SCRATCH_BASE
Constructor scratch memory used to stage immutable words before appending them to runtime bytecode.

Traits§

Backend
A code generation backend that lowers MIR to a target artifact.

Functions§

parse_evm_ir_module
Parses an EVM IR module from the text format.

Type Aliases§

FxHashMap
A HashMap using FxHasher as its hasher.