16
16
#include " swift/SIL/SILDebugScope.h"
17
17
#include " swift/SIL/SILFunction.h"
18
18
#include " swift/SIL/SILModule.h"
19
- #include " swift/SIL/SILOpenedArchetypesTracker.h"
20
19
#include " llvm/ADT/PointerUnion.h"
21
20
#include " llvm/ADT/StringExtras.h"
22
21
@@ -41,16 +40,6 @@ class SILBuilder {
41
40
// / recorded in this list.
42
41
SmallVectorImpl<SILInstruction *> *InsertedInstrs = nullptr ;
43
42
44
- // / An immutable view on the set of available opened archetypes.
45
- // / It is passed down to SILInstruction constructors and create
46
- // / methods.
47
- SILOpenedArchetypesState OpenedArchetypes;
48
-
49
- // / Maps opened archetypes to their definitions. If provided,
50
- // / can be used by the builder. It is supposed to be used
51
- // / only by SILGen or SIL deserializers.
52
- SILOpenedArchetypesTracker *OpenedArchetypesTracker = nullptr ;
53
-
54
43
public:
55
44
SILBuilder (SILFunction &F) : F(F), BB(0 ) {}
56
45
@@ -86,19 +75,6 @@ class SILBuilder {
86
75
return F.getModule ().getTypeLowering (T);
87
76
}
88
77
89
- void setOpenedArchetypesTracker (SILOpenedArchetypesTracker *Tracker) {
90
- this ->OpenedArchetypesTracker = Tracker;
91
- this ->OpenedArchetypes .setOpenedArchetypesTracker (OpenedArchetypesTracker);
92
- }
93
-
94
- SILOpenedArchetypesTracker *getOpenedArchetypesTracker () const {
95
- return OpenedArchetypesTracker;
96
- }
97
-
98
- SILOpenedArchetypesState &getOpenedArchetypes () {
99
- return OpenedArchetypes;
100
- }
101
-
102
78
void setCurrentDebugScope (const SILDebugScope *DS) { CurDebugScope = DS; }
103
79
const SILDebugScope *getCurrentDebugScope () const { return CurDebugScope; }
104
80
@@ -285,8 +261,7 @@ class SILBuilder {
285
261
SILType Result, ArrayRef<Substitution> Subs,
286
262
ArrayRef<SILValue> Args, bool isNonThrowing) {
287
263
return insert (ApplyInst::create (getSILDebugLocation (Loc), Fn, SubstFnTy,
288
- Result, Subs, Args, isNonThrowing, F,
289
- OpenedArchetypes));
264
+ Result, Subs, Args, isNonThrowing, F));
290
265
}
291
266
292
267
ApplyInst *createApply (SILLocation Loc, SILValue Fn, ArrayRef<SILValue> Args,
@@ -303,18 +278,16 @@ class SILBuilder {
303
278
SILBasicBlock *errorBB) {
304
279
return insertTerminator (TryApplyInst::create (getSILDebugLocation (Loc),
305
280
fn, substFnTy, subs, args,
306
- normalBB, errorBB, F,
307
- OpenedArchetypes));
281
+ normalBB, errorBB, F));
308
282
}
309
283
310
284
PartialApplyInst *createPartialApply (SILLocation Loc, SILValue Fn,
311
285
SILType SubstFnTy,
312
286
ArrayRef<Substitution> Subs,
313
287
ArrayRef<SILValue> Args,
314
288
SILType ClosureTy) {
315
- return insert (PartialApplyInst::create (getSILDebugLocation (Loc), Fn,
316
- SubstFnTy, Subs, Args, ClosureTy, F,
317
- OpenedArchetypes));
289
+ return insert (PartialApplyInst::create (
290
+ getSILDebugLocation (Loc), Fn, SubstFnTy, Subs, Args, ClosureTy, F));
318
291
}
319
292
320
293
BuiltinInst *createBuiltin (SILLocation Loc, Identifier Name, SILType ResultTy,
@@ -553,8 +526,8 @@ class SILBuilder {
553
526
554
527
UncheckedRefCastInst *createUncheckedRefCast (SILLocation Loc, SILValue Op,
555
528
SILType Ty) {
556
- return insert (UncheckedRefCastInst::create ( getSILDebugLocation (Loc), Op, Ty,
557
- F, OpenedArchetypes ));
529
+ return insert (new (F. getModule ()) UncheckedRefCastInst (
530
+ getSILDebugLocation (Loc), Op, Ty ));
558
531
}
559
532
560
533
UncheckedRefCastAddrInst *
@@ -566,20 +539,20 @@ class SILBuilder {
566
539
567
540
UncheckedAddrCastInst *createUncheckedAddrCast (SILLocation Loc, SILValue Op,
568
541
SILType Ty) {
569
- return insert (UncheckedAddrCastInst::create ( getSILDebugLocation (Loc), Op,
570
- Ty, F, OpenedArchetypes ));
542
+ return insert (new (F. getModule ()) UncheckedAddrCastInst (
543
+ getSILDebugLocation (Loc), Op, Ty ));
571
544
}
572
545
573
546
UncheckedTrivialBitCastInst *
574
547
createUncheckedTrivialBitCast (SILLocation Loc, SILValue Op, SILType Ty) {
575
- return insert (UncheckedTrivialBitCastInst::create (
576
- getSILDebugLocation (Loc), Op, Ty, F, OpenedArchetypes ));
548
+ return insert (new (F. getModule ()) UncheckedTrivialBitCastInst (
549
+ getSILDebugLocation (Loc), Op, Ty));
577
550
}
578
551
579
552
UncheckedBitwiseCastInst *
580
553
createUncheckedBitwiseCast (SILLocation Loc, SILValue Op, SILType Ty) {
581
- return insert (UncheckedBitwiseCastInst::create ( getSILDebugLocation (Loc), Op,
582
- Ty, F, OpenedArchetypes ));
554
+ return insert (new (F. getModule ()) UncheckedBitwiseCastInst (
555
+ getSILDebugLocation (Loc), Op, Ty ));
583
556
}
584
557
585
558
RefToBridgeObjectInst *createRefToBridgeObject (SILLocation Loc, SILValue Ref,
@@ -675,8 +648,8 @@ class SILBuilder {
675
648
676
649
UnconditionalCheckedCastInst *
677
650
createUnconditionalCheckedCast (SILLocation Loc, SILValue op, SILType destTy) {
678
- return insert (UnconditionalCheckedCastInst::create (
679
- getSILDebugLocation (Loc), op, destTy, F, OpenedArchetypes ));
651
+ return insert (new (F. getModule ()) UnconditionalCheckedCastInst (
652
+ getSILDebugLocation (Loc), op, destTy));
680
653
}
681
654
682
655
UnconditionalCheckedCastAddrInst *createUnconditionalCheckedCastAddr (
@@ -923,10 +896,11 @@ class SILBuilder {
923
896
WitnessMethodInst *createWitnessMethod (SILLocation Loc, CanType LookupTy,
924
897
ProtocolConformanceRef Conformance,
925
898
SILDeclRef Member, SILType MethodTy,
899
+ SILValue OptionalOpenedExistential,
926
900
bool Volatile = false ) {
927
901
return insert (WitnessMethodInst::create (
928
902
getSILDebugLocation (Loc), LookupTy, Conformance, Member, MethodTy,
929
- &F, OpenedArchetypes , Volatile));
903
+ &F, OptionalOpenedExistential , Volatile));
930
904
}
931
905
932
906
DynamicMethodInst *createDynamicMethod (SILLocation Loc, SILValue Operand,
@@ -938,39 +912,27 @@ class SILBuilder {
938
912
939
913
OpenExistentialAddrInst *
940
914
createOpenExistentialAddr (SILLocation Loc, SILValue Operand, SILType SelfTy) {
941
- auto *I = insert (new (F.getModule ()) OpenExistentialAddrInst (
915
+ return insert (new (F.getModule ()) OpenExistentialAddrInst (
942
916
getSILDebugLocation (Loc), Operand, SelfTy));
943
- if (OpenedArchetypesTracker)
944
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
945
- return I;
946
917
}
947
918
948
919
OpenExistentialMetatypeInst *createOpenExistentialMetatype (SILLocation Loc,
949
920
SILValue operand,
950
921
SILType selfTy) {
951
- auto *I = insert (new (F.getModule ()) OpenExistentialMetatypeInst (
922
+ return insert (new (F.getModule ()) OpenExistentialMetatypeInst (
952
923
getSILDebugLocation (Loc), operand, selfTy));
953
- if (OpenedArchetypesTracker)
954
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
955
- return I;
956
924
}
957
925
958
926
OpenExistentialRefInst *
959
927
createOpenExistentialRef (SILLocation Loc, SILValue Operand, SILType Ty) {
960
- auto *I = insert (new (F.getModule ()) OpenExistentialRefInst (
928
+ return insert (new (F.getModule ()) OpenExistentialRefInst (
961
929
getSILDebugLocation (Loc), Operand, Ty));
962
- if (OpenedArchetypesTracker)
963
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
964
- return I;
965
930
}
966
931
967
932
OpenExistentialBoxInst *
968
933
createOpenExistentialBox (SILLocation Loc, SILValue Operand, SILType Ty) {
969
- auto *I = insert (new (F.getModule ()) OpenExistentialBoxInst (
934
+ return insert (new (F.getModule ()) OpenExistentialBoxInst (
970
935
getSILDebugLocation (Loc), Operand, Ty));
971
- if (OpenedArchetypesTracker)
972
- OpenedArchetypesTracker->registerOpenedArchetypes (I);
973
- return I;
974
936
}
975
937
976
938
InitExistentialAddrInst *
@@ -980,25 +942,25 @@ class SILBuilder {
980
942
ArrayRef<ProtocolConformanceRef> Conformances) {
981
943
return insert (InitExistentialAddrInst::create (
982
944
getSILDebugLocation (Loc), Existential, FormalConcreteType,
983
- LoweredConcreteType, Conformances, &F, OpenedArchetypes ));
945
+ LoweredConcreteType, Conformances, &F));
984
946
}
985
947
986
948
InitExistentialMetatypeInst *
987
949
createInitExistentialMetatype (SILLocation Loc, SILValue metatype,
988
950
SILType existentialType,
989
951
ArrayRef<ProtocolConformanceRef> conformances) {
990
952
return insert (InitExistentialMetatypeInst::create (
991
- getSILDebugLocation (Loc), existentialType, metatype, conformances, &F,
992
- OpenedArchetypes ));
953
+ getSILDebugLocation (Loc), existentialType, metatype, conformances,
954
+ &F ));
993
955
}
994
956
995
957
InitExistentialRefInst *
996
958
createInitExistentialRef (SILLocation Loc, SILType ExistentialType,
997
959
CanType FormalConcreteType, SILValue Concrete,
998
960
ArrayRef<ProtocolConformanceRef> Conformances) {
999
961
return insert (InitExistentialRefInst::create (
1000
- getSILDebugLocation (Loc), ExistentialType, FormalConcreteType, Concrete,
1001
- Conformances, &F, OpenedArchetypes ));
962
+ getSILDebugLocation (Loc), ExistentialType, FormalConcreteType,
963
+ Concrete, Conformances, &F));
1002
964
}
1003
965
1004
966
DeinitExistentialAddrInst *createDeinitExistentialAddr (SILLocation Loc,
@@ -1030,8 +992,8 @@ class SILBuilder {
1030
992
}
1031
993
1032
994
MetatypeInst *createMetatype (SILLocation Loc, SILType Metatype) {
1033
- return insert (MetatypeInst::create ( getSILDebugLocation (Loc), Metatype,
1034
- &F, OpenedArchetypes ));
995
+ return insert (new (F. getModule ())
996
+ MetatypeInst ( getSILDebugLocation (Loc), Metatype ));
1035
997
}
1036
998
1037
999
ObjCMetatypeToObjectInst *
@@ -1344,9 +1306,9 @@ class SILBuilder {
1344
1306
SILValue op, SILType destTy,
1345
1307
SILBasicBlock *successBB,
1346
1308
SILBasicBlock *failureBB) {
1347
- return insertTerminator (CheckedCastBranchInst::create (
1348
- getSILDebugLocation (Loc), isExact, op, destTy, successBB, failureBB, F,
1349
- OpenedArchetypes ));
1309
+ return insertTerminator (new (F. getModule ()) CheckedCastBranchInst (
1310
+ getSILDebugLocation (Loc), isExact, op, destTy, successBB,
1311
+ failureBB ));
1350
1312
}
1351
1313
1352
1314
CheckedCastAddrBranchInst *
0 commit comments