Skip to content

Commit 82d9da5

Browse files
committed
Swift Bridging: use C++ instead of C bridging for BridgedMultiValueResult
1 parent 47ac2d2 commit 82d9da5

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,14 @@ public final class MultipleValueInstructionResult : Value {
171171
}
172172

173173
public var parentInstruction: MultipleValueInstruction {
174-
MultiValueInstResult_getParent(bridged).getAs(MultipleValueInstruction.self)
174+
bridged.getParent().getAs(MultipleValueInstruction.self)
175175
}
176176

177177
public var definingInstruction: Instruction? { parentInstruction }
178178

179179
public var parentBlock: BasicBlock { parentInstruction.parentBlock }
180180

181-
public var index: Int { MultiValueInstResult_getIndex(bridged) }
181+
public var index: Int { bridged.getIndex() }
182182

183183
var bridged: BridgedMultiValueResult {
184184
BridgedMultiValueResult(obj: SwiftObject(self))

include/swift/SIL/SILBridging.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ struct BridgedGlobalVar {
315315

316316
struct BridgedMultiValueResult {
317317
SwiftObject obj;
318+
319+
swift::MultipleValueInstructionResult * _Nonnull getMVResult() const {
320+
return static_cast<swift::MultipleValueInstructionResult *>(obj);
321+
}
322+
323+
SWIFT_IMPORT_UNSAFE
324+
inline BridgedInstruction getParent() const;
325+
326+
SwiftInt getIndex() const {
327+
return (SwiftInt)getMVResult()->getIndex();
328+
}
318329
};
319330

320331
struct OptionalBridgedInstruction {
@@ -892,9 +903,6 @@ SILLocation_getAutogeneratedLocation(swift::SILDebugLocation loc);
892903
bool SILLocation_equal(swift::SILDebugLocation lhs, swift::SILDebugLocation rhs);
893904
bool SILLocation_hasSameSourceLocation(swift::SILDebugLocation lhs, swift::SILDebugLocation rhs);
894905

895-
BridgedInstruction MultiValueInstResult_getParent(BridgedMultiValueResult result);
896-
SwiftInt MultiValueInstResult_getIndex(BridgedMultiValueResult result);
897-
898906
BridgedInstruction SILBuilder_createBuiltinBinaryFunction(
899907
BridgedBuilder builder, llvm::StringRef name,
900908
swift::SILType operandType, swift::SILType resultType,
@@ -967,6 +975,10 @@ OptionalBridgedBasicBlock BridgedFunction::getLastBlock() const {
967975
return {getFunction()->empty() ? nullptr : &*getFunction()->rbegin()};
968976
}
969977

978+
BridgedInstruction BridgedMultiValueResult::getParent() const {
979+
return {getMVResult()->getParent()};
980+
}
981+
970982
BridgedBasicBlock BridgedInstruction::getParent() const {
971983
assert(!getInst()->isStaticInitializerInst() &&
972984
"cannot get the parent of a static initializer instruction");

lib/SIL/Utils/SILBridging.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,15 +306,6 @@ bool BridgedInstruction::mayBeDeinitBarrierNotConsideringSideEffects() const {
306306
return ::mayBeDeinitBarrierNotConsideringSideEffects(getInst());
307307
}
308308

309-
BridgedInstruction MultiValueInstResult_getParent(BridgedMultiValueResult result) {
310-
return {static_cast<MultipleValueInstructionResult *>(result.obj)->getParent()};
311-
}
312-
313-
SwiftInt MultiValueInstResult_getIndex(BridgedMultiValueResult result) {
314-
auto *rs = static_cast<MultipleValueInstructionResult *>(result.obj);
315-
return (SwiftInt)rs->getIndex();
316-
}
317-
318309
//===----------------------------------------------------------------------===//
319310
// SILBuilder
320311
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)