Skip to content

Commit b451010

Browse files
committed
Swift Bridging: remove BridgedNode
1 parent a776234 commit b451010

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

SwiftCompilerSources/Sources/SIL/Instruction.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class Instruction : CustomStringConvertible, Hashable {
3434
final public var parentFunction: Function { parentBlock.parentFunction }
3535

3636
final public var description: String {
37-
let stdString = SILNode_debugDescription(bridgedNode)
37+
let stdString = bridged.getDebugDescription()
3838
return String(_cxxString: stdString)
3939
}
4040

@@ -138,7 +138,6 @@ public class Instruction : CustomStringConvertible, Hashable {
138138
public var bridged: BridgedInstruction {
139139
BridgedInstruction(SwiftObject(self))
140140
}
141-
var bridgedNode: BridgedNode { BridgedNode(obj: SwiftObject(self)) }
142141
}
143142

144143
extension BridgedInstruction {
@@ -165,11 +164,6 @@ public class SingleValueInstruction : Instruction, Value {
165164
}
166165

167166
public final class MultipleValueInstructionResult : Value {
168-
final public var description: String {
169-
let stdString = SILNode_debugDescription(bridgedNode)
170-
return String(_cxxString: stdString)
171-
}
172-
173167
public var parentInstruction: MultipleValueInstruction {
174168
bridged.getParent().getAs(MultipleValueInstruction.self)
175169
}
@@ -183,7 +177,6 @@ public final class MultipleValueInstructionResult : Value {
183177
var bridged: BridgedMultiValueResult {
184178
BridgedMultiValueResult(obj: SwiftObject(self))
185179
}
186-
var bridgedNode: BridgedNode { BridgedNode(obj: SwiftObject(self)) }
187180
}
188181

189182
extension BridgedMultiValueResult {

SwiftCompilerSources/Sources/SIL/Value.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public enum Ownership {
8888

8989
extension Value {
9090
public var description: String {
91-
let stdString = SILNode_debugDescription(bridgedNode)
91+
let stdString = bridged.getDebugDescription()
9292
return String(_cxxString: stdString)
9393
}
9494

@@ -120,9 +120,6 @@ extension Value {
120120
public var bridged: BridgedValue {
121121
BridgedValue(obj: SwiftObject(self as AnyObject))
122122
}
123-
var bridgedNode: BridgedNode {
124-
BridgedNode(obj: SwiftObject(self as AnyObject))
125-
}
126123
}
127124

128125
public typealias HashableValue = ObjectIdentifier

include/swift/SIL/SILBridging.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ struct BridgedValue {
7373

7474
swift::SILValue getSILValue() const { return static_cast<swift::ValueBase *>(obj); }
7575

76+
std::string getDebugDescription() const;
77+
7678
SWIFT_IMPORT_UNSAFE
7779
inline OptionalBridgedOperand getFirstUse() const;
7880

@@ -353,6 +355,8 @@ struct BridgedInstruction {
353355

354356
swift::SILInstruction * _Nonnull getInst() const { return getAs<swift::SILInstruction>(); }
355357

358+
std::string getDebugDescription() const;
359+
356360
SWIFT_IMPORT_UNSAFE
357361
OptionalBridgedInstruction getNext() const {
358362
auto iter = std::next(getInst()->getIterator());
@@ -786,10 +790,6 @@ struct BridgedSuccessorArray {
786790
SwiftInt count;
787791
};
788792

789-
typedef struct {
790-
SwiftObject obj;
791-
} BridgedNode;
792-
793793
struct BridgedVTableEntry {
794794
const swift::SILVTableEntry * _Nonnull entry;
795795

@@ -895,8 +895,6 @@ void PassContext_eraseInstruction(BridgedPassContext passContext,
895895
void PassContext_eraseBlock(BridgedPassContext passContext,
896896
BridgedBasicBlock block);
897897

898-
std::string SILNode_debugDescription(BridgedNode node);
899-
900898
BridgedInstruction SILBuilder_createBuiltinBinaryFunction(
901899
BridgedBuilder builder, llvm::StringRef name,
902900
swift::SILType operandType, swift::SILType resultType,

include/swift/SIL/SILBridgingUtils.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
namespace swift {
2727

28-
inline SILNode *castToSILNode(BridgedNode node) {
29-
return static_cast<SILNode *>(node.obj);
30-
}
31-
3228
ArrayRef<SILValue> getSILValues(BridgedValueArray values,
3329
SmallVectorImpl<SILValue> &storage);
3430

lib/SIL/Utils/SILBridging.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ std::string BridgedBasicBlock::getDebugDescription() const {
167167
// SILValue
168168
//===----------------------------------------------------------------------===//
169169

170-
std::string SILNode_debugDescription(BridgedNode node) {
170+
std::string BridgedValue::getDebugDescription() const {
171171
std::string str;
172172
llvm::raw_string_ostream os(str);
173-
castToSILNode(node)->print(os);
173+
getSILValue()->print(os);
174174
str.pop_back(); // Remove trailing newline.
175175
return str;
176176
}
@@ -253,6 +253,14 @@ std::string BridgedDefaultWitnessTable::getDebugDescription() const {
253253
// SILInstruction
254254
//===----------------------------------------------------------------------===//
255255

256+
std::string BridgedInstruction::getDebugDescription() const {
257+
std::string str;
258+
llvm::raw_string_ostream os(str);
259+
getInst()->print(os);
260+
str.pop_back(); // Remove trailing newline.
261+
return str;
262+
}
263+
256264
bool BridgedInstruction::mayAccessPointer() const {
257265
return ::mayAccessPointer(getInst());
258266
}

0 commit comments

Comments
 (0)