How swiftlang/swift works
Swift is a programming language implementation: developers write Swift programs, which the compiler analyzes and optimizes; the standard library and platform runtimes provide the facilities those programs use. The tree and excerpts support compiler AST, storage type-checking, diagnostics, SIL optimization, standard-library string storage, and runtime/overlay subsystems. Several major capabilities are documented or visible in the tree but their implementation and wiring were not sampled, so those branches are shown without speculative call relationships.
Main entry points: PassPipeline.cpp Pass pipeline · AST AST and types · TypeCheckStorage.cpp Storage type-checking · Optimizer Optimizer passes
Components 17
Compiler
- AST and types
SwiftCompilerSources/Sources/AST - Storage type-checking
lib/Sema/TypeCheckStorage.cpp - Diagnostics
lib/AST/DiagnosticEngine.cpp - SIL representation
SwiftCompilerSources/Sources/SIL - SIL generation
lib/SILGen/StorageRefResult.h
SIL Optimizer
- Pass pipeline
lib/SILOptimizer/PassManager/PassPipeline.cpp - Access analysis
lib/SILOptimizer/Analysis/AccessStorageAnalysis.cpp - Phi storage optimization
lib/SILOptimizer/Mandatory/PhiStorageOptimizer.cpp - Optimizer passes
SwiftCompilerSources/Sources/Optimizer
Library and Runtime
- String storage
stdlib/public/core/StringStorage.swift - Core runtime
Runtimes/Core - Supplemental libraries
Runtimes/Supplemental
Platform Interop
- Platform overlays
Runtimes/Overlay - COM support
Runtimes/Supplemental/COM/Sources/COM
Other components
- Swift developer
- Swift program
- C and Objective-C
Connections 14
- Swift developer → Swift program: writes
- Swift program → AST and types: analyzed as
- AST and types → Storage type-checking: type-checked by
- Storage type-checking → Diagnostics: reports issues
- SIL generation → SIL representation: builds
- Pass pipeline → Optimizer passes: schedules passes
- Pass pipeline → Phi storage optimization: adds optimization
- Access analysis → Optimizer passes: provides analysis
- Swift program → String storage: uses library
- Swift program → Core runtime: uses runtime
- Swift program → Supplemental libraries: may use
- Swift program → Platform overlays: may use
- Swift program → COM support: may use
- C and Objective-C → Platform overlays: interoperates through