Factory.ai

Open-Source Wikis

/

Swift

/

Systems

apple/swift

Systems

The Swift toolchain is a layered pipeline. This section documents each major subsystem on its own page. Read Architecture first for the global picture, then dive into the subsystem(s) relevant to your change.

Compilation pipeline

Page Layer
Frontend and driver The swift / swift-frontend entry points.
Parser Lexing, parsing, and lib/ASTGen/ (Swift-implemented parsing).
AST Declarations, types, expressions, and the request evaluator.
Sema Type checking and the constraint solver.
SILGen Lowering AST to raw SIL.
SIL and the SIL optimizer The SIL IR and pass pipeline.
IRGen Lowering canonical SIL to LLVM IR.
ClangImporter Importing C and Objective-C declarations into Swift.
Serialization and module loading .swiftmodule, .swiftinterface, deserialization.
Runtime The C/C++ runtime that supports Swift programs.
SwiftCompilerSources Swift-implemented compiler subsystems.
IDE support and SourceKit lib/IDE/, lib/Index/, tools/SourceKit/.

Cross-cutting

The compiler also has cross-cutting components used by multiple stages:

  • Demangling -- lib/Demangling/ and the duplicate copy in stdlib/public/Demangling/. See Runtime for why there are two.
  • Macros -- lib/Macros/, plus stdlib/public/CompatibilityOverride/ and the swift-syntax repo for the macro-expansion library.
  • Localization -- lib/Localization/ and localization/.
  • Symbol-graph generation -- lib/SymbolGraphGen/ and tools/swift-symbolgraph-extract.
  • Markup -- lib/Markup/ parses doc comments.
  • Threading -- lib/Threading/ and stdlib/public/Threading/ provide a portable threading layer used by both compiler and runtime.

How the systems compose

graph TD
    Driver[Driver and Frontend] --> Parser[Parser + ASTGen]
    Parser --> AST
    AST --> Sema
    AST --> ClangImporter
    AST --> Serialization[Serialization]
    Sema --> SILGen
    SILGen --> SILOpt[SIL + SILOptimizer]
    SILOpt --> IRGen
    SILOpt --> SCS[SwiftCompilerSources]
    SCS --> SILOpt
    Sema --> IDE[IDE + SourceKit]
    Sema --> SymbolGraph[SymbolGraphGen]
    IRGen --> LLVMIR[LLVM IR]
    Runtime[Swift runtime] -.linked into.- LLVMIR

The compiler is a request graph; the diagram is a simplification. Many "downstream" components actually call back into earlier stages (e.g., IRGen calls into Sema for type-layout queries; SourceKit drives partial type-checking).

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Systems – Swift wiki | Factory