Skip to content

Commit 4445373

Browse files
committed
Swift Bridging: use C++ instead of C bridging for BridgedInstruction
1 parent c4f5bab commit 4445373

File tree

10 files changed

+460
-511
lines changed

10 files changed

+460
-511
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ struct FunctionPassContext : MutatingContext {
102102
var notifyInstructionChanged: (Instruction) -> () { return { inst in } }
103103

104104
func continueWithNextSubpassRun(for inst: Instruction? = nil) -> Bool {
105-
let bridgedInst = OptionalBridgedInstruction(obj: inst?.bridged.obj)
105+
let bridgedInst = OptionalBridgedInstruction(inst?.bridged.obj)
106106
return PassContext_continueWithNextSubpassRun(_bridged, bridgedInst) != 0
107107
}
108108

@@ -278,15 +278,15 @@ extension Instruction {
278278
context.notifyCallsChanged()
279279
}
280280
context.notifyInstructionsChanged()
281-
SILInstruction_setOperand(bridged, index, value.bridged)
281+
bridged.setOperand(index, value.bridged)
282282
context.notifyInstructionChanged(self)
283283
}
284284
}
285285

286286
extension RefCountingInst {
287287
func setAtomicity(isAtomic: Bool, _ context: some MutatingContext) {
288288
context.notifyInstructionsChanged()
289-
RefCountingInst_setIsAtomic(bridged, isAtomic)
289+
bridged.RefCountingInst_setIsAtomic(isAtomic)
290290
context.notifyInstructionChanged(self)
291291
}
292292
}

SwiftCompilerSources/Sources/SIL/ApplySite.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ extension ApplySite {
7171
///
7272
/// This does not include the callee function operand.
7373
public var argumentOperands: OperandArray {
74-
let numArgs = ApplySite_getNumArguments(bridged)
74+
let numArgs = bridged.ApplySite_getNumArguments()
7575
let offset = ApplyOperands.firstArgumentIndex
7676
return operands[offset..<(numArgs + offset)]
7777
}
@@ -84,7 +84,7 @@ extension ApplySite {
8484
}
8585

8686
public var substitutionMap: SubstitutionMap {
87-
SubstitutionMap(ApplySite_getSubstitutionMap(bridged))
87+
SubstitutionMap(bridged.ApplySite_getSubstitutionMap())
8888
}
8989

9090
/// Returns the argument index of an operand.
@@ -106,7 +106,7 @@ extension ApplySite {
106106
}
107107

108108
public func getArgumentConvention(calleeArgIndex: Int) -> ArgumentConvention {
109-
return ApplySite_getArgumentConvention(bridged, calleeArgIndex).convention
109+
return bridged.ApplySite_getArgumentConvention(calleeArgIndex).convention
110110
}
111111

112112
public var referencedFunction: Function? {
@@ -138,6 +138,6 @@ extension FullApplySite {
138138
///
139139
/// 0 if the callee has a direct or no return value and 1, if it has an indirect return value.
140140
public var numIndirectResultArguments: Int {
141-
return FullApplySite_numIndirectResultArguments(bridged)
141+
return bridged.FullApplySite_numIndirectResultArguments()
142142
}
143143
}

SwiftCompilerSources/Sources/SIL/Builder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct Builder {
3333
insertAtEnd: OptionalBridgedBasicBlock.none,
3434
loc: location.bridged)
3535
case .atEndOf(let block):
36-
return BridgedBuilder(insertBefore: OptionalBridgedInstruction.none,
36+
return BridgedBuilder(insertBefore: OptionalBridgedInstruction(),
3737
insertAtEnd: block.bridged.optional,
3838
loc: location.bridged)
3939
}

0 commit comments

Comments
 (0)