Skip to content

Commit e2129b5

Browse files
committed
SwiftCompilerSources: move the SSAUpdater utility from the Optimizer to the SIL module
1 parent 65c9828 commit e2129b5

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

SwiftCompilerSources/Sources/Optimizer/Utilities/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ swift_compiler_sources(Optimizer
2121
OptUtils.swift
2222
OwnershipLiveness.swift
2323
PhiUpdater.swift
24-
SSAUpdater.swift
2524
StaticInitCloner.swift
2625
Test.swift
2726
Verifier.swift

SwiftCompilerSources/Sources/SIL/Utilities/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ swift_compiler_sources(SIL
1010
AccessUtils.swift
1111
SequenceUtilities.swift
1212
SmallProjectionPath.swift
13+
SSAUpdater.swift
1314
WalkUtils.swift
1415
)
1516

SwiftCompilerSources/Sources/Optimizer/Utilities/SSAUpdater.swift renamed to SwiftCompilerSources/Sources/SIL/Utilities/SSAUpdater.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,23 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
import SIL
14-
import OptimizerBridging
13+
import SILBridging
1514

1615
/// Utility for updating SSA for a set of SIL instructions defined in multiple blocks.
17-
struct SSAUpdater<Context: MutatingContext> {
16+
public struct SSAUpdater<Context: MutatingContext> {
1817
let context: Context
1918

20-
init(function: Function, type: Type, ownership: Ownership,
21-
_ context: Context) {
19+
public init(function: Function, type: Type, ownership: Ownership, _ context: Context) {
2220
self.context = context
23-
context._bridged.SSAUpdater_initialize(function.bridged, type.bridged,
24-
ownership._bridged)
21+
context._bridged.SSAUpdater_initialize(function.bridged, type.bridged, ownership._bridged)
2522
}
2623

27-
mutating func addAvailableValue(_ value: Value, in block: BasicBlock) {
24+
public mutating func addAvailableValue(_ value: Value, in block: BasicBlock) {
2825
context._bridged.SSAUpdater_addAvailableValue(block.bridged, value.bridged)
2926
}
3027

3128
/// Construct SSA for a value that is live at the *end* of a basic block.
32-
mutating func getValue(atEndOf block: BasicBlock) -> Value {
29+
public mutating func getValue(atEndOf block: BasicBlock) -> Value {
3330
context.notifyInstructionsChanged()
3431
return context._bridged.SSAUpdater_getValueAtEndOfBlock(block.bridged).value
3532
}
@@ -46,12 +43,12 @@ struct SSAUpdater<Context: MutatingContext> {
4643
/// cond_br bb2, bb3
4744
///
4845
/// In this case we need to insert a phi argument in bb2, merging %1 and %2.
49-
mutating func getValue(inMiddleOf block: BasicBlock) -> Value {
46+
public mutating func getValue(inMiddleOf block: BasicBlock) -> Value {
5047
context.notifyInstructionsChanged()
5148
return context._bridged.SSAUpdater_getValueInMiddleOfBlock(block.bridged).value
5249
}
5350

54-
var insertedPhis: [Phi] {
51+
public var insertedPhis: [Phi] {
5552
var phis = [Phi]()
5653
let numPhis = context._bridged.SSAUpdater_getNumInsertedPhis()
5754
phis.reserveCapacity(numPhis)

0 commit comments

Comments
 (0)