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 instdlib/public/Demangling/. See Runtime for why there are two. - Macros --
lib/Macros/, plusstdlib/public/CompatibilityOverride/and theswift-syntaxrepo for the macro-expansion library. - Localization --
lib/Localization/andlocalization/. - Symbol-graph generation --
lib/SymbolGraphGen/andtools/swift-symbolgraph-extract. - Markup --
lib/Markup/parses doc comments. - Threading --
lib/Threading/andstdlib/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.- LLVMIRThe 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.
Previous
Tooling
Next
Frontend and driver