mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
SwiftCompilerSources: move SIL-related Context APIs from Optimizer to the SIL module
This commit is contained in:
@@ -27,6 +27,10 @@ public struct Operand : CustomStringConvertible, NoReflectionChildren, Equatable
|
||||
|
||||
public var value: Value { bridged.getValue().value }
|
||||
|
||||
public func set(to value: Value, _ context: some MutatingContext) {
|
||||
instruction.setOperand(at: index, to: value, context)
|
||||
}
|
||||
|
||||
public static func ==(lhs: Operand, rhs: Operand) -> Bool {
|
||||
return lhs.bridged.op == rhs.bridged.op
|
||||
}
|
||||
@@ -45,6 +49,12 @@ public struct Operand : CustomStringConvertible, NoReflectionChildren, Equatable
|
||||
|
||||
public func canAccept(ownership: Ownership) -> Bool { bridged.canAcceptOwnership(ownership._bridged) }
|
||||
|
||||
public func changeOwnership(from: Ownership, to: Ownership, _ context: some MutatingContext) {
|
||||
context.notifyInstructionsChanged()
|
||||
bridged.changeOwnership(from._bridged, to._bridged)
|
||||
context.notifyInstructionChanged(instruction)
|
||||
}
|
||||
|
||||
public var description: String { "operand #\(index) of \(instruction)" }
|
||||
}
|
||||
|
||||
@@ -185,6 +195,12 @@ extension Sequence where Element == Operand {
|
||||
public func users<I: Instruction>(ofType: I.Type) -> LazyMapSequence<LazyFilterSequence<Self>, I> {
|
||||
self.lazy.filter{ $0.instruction is I }.lazy.map { $0.instruction as! I }
|
||||
}
|
||||
|
||||
public func replaceAll(with replacement: Value, _ context: some MutatingContext) {
|
||||
for use in self {
|
||||
use.set(to: replacement, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Value {
|
||||
|
||||
Reference in New Issue
Block a user