Skip to content

Commit 783dd20

Browse files
committed
[NFC] Set up the conversion peephole to turn back into normal conversions.
1 parent 1609384 commit 783dd20

File tree

3 files changed

+138
-120
lines changed

3 files changed

+138
-120
lines changed

lib/SILGen/Conversion.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ class Conversion {
3737
/// implicit force cast.
3838
ForceAndBridgeToObjC,
3939

40+
/// Force an optional value.
41+
ForceOptional,
42+
4043
/// A bridging conversion from a foreign type.
4144
BridgeFromObjC,
4245

@@ -61,6 +64,7 @@ class Conversion {
6164
switch (kind) {
6265
case BridgeToObjC:
6366
case ForceAndBridgeToObjC:
67+
case ForceOptional:
6468
case BridgeFromObjC:
6569
case BridgeResultFromObjC:
6670
case AnyErasure:
@@ -80,6 +84,7 @@ class Conversion {
8084

8185
case BridgeToObjC:
8286
case ForceAndBridgeToObjC:
87+
case ForceOptional:
8388
case BridgeFromObjC:
8489
case BridgeResultFromObjC:
8590
case AnyErasure:
@@ -114,6 +119,7 @@ class Conversion {
114119
switch (kind) {
115120
case BridgeToObjC:
116121
case ForceAndBridgeToObjC:
122+
case ForceOptional:
117123
case BridgeFromObjC:
118124
case BridgeResultFromObjC:
119125
case AnyErasure:
@@ -238,6 +244,24 @@ class Conversion {
238244
return Types.get<BridgingTypes>(Kind).LoweredResultType;
239245
}
240246

247+
CanType getSourceType() const {
248+
if (isBridging())
249+
return getBridgingSourceType();
250+
return getReabstractionInputSubstType();
251+
}
252+
253+
CanType getResultType() const {
254+
if (isBridging())
255+
return getBridgingResultType();
256+
return getReabstractionOutputSubstType();
257+
}
258+
259+
SILType getLoweredResultType() const {
260+
if (isBridging())
261+
return getBridgingLoweredResultType();
262+
return getReabstractionOutputLoweredType();
263+
}
264+
241265
ManagedValue emit(SILGenFunction &SGF, SILLocation loc,
242266
ManagedValue source, SGFContext ctxt) const;
243267

0 commit comments

Comments
 (0)