@@ -33,153 +33,15 @@ SILGenModule &SILGenBuilder::getSILGenModule() const { return SGF.SGM; }
33
33
// ===----------------------------------------------------------------------===//
34
34
35
35
SILGenBuilder::SILGenBuilder (SILGenFunction &SGF)
36
- : SILBuilder (SGF.F ), SGF(SGF) {}
36
+ : SILGenSILBuilder (SGF), SGF(SGF) {}
37
37
38
38
SILGenBuilder::SILGenBuilder (SILGenFunction &SGF, SILBasicBlock *insertBB,
39
39
SmallVectorImpl<SILInstruction *> *insertedInsts)
40
- : SILBuilder( insertBB, insertedInsts), SGF(SGF) {}
40
+ : SILGenSILBuilder(SGF, insertBB, insertedInsts), SGF(SGF) {}
41
41
42
42
SILGenBuilder::SILGenBuilder (SILGenFunction &SGF, SILBasicBlock *insertBB,
43
43
SILBasicBlock::iterator insertInst)
44
- : SILBuilder(insertBB, insertInst), SGF(SGF) {}
45
-
46
- // ===----------------------------------------------------------------------===//
47
- // Instruction Emission + Conformance Endowed APIs
48
- // ===----------------------------------------------------------------------===//
49
- //
50
- // This section contains wrappers around SILBuilder SILValue APIs that add extra
51
- // conformances. These are the only places where we should be accessing
52
- // SILBuilder APIs directly.
53
- //
54
-
55
- MetatypeInst *SILGenBuilder::createMetatype (SILLocation loc, SILType metatype) {
56
- auto theMetatype = metatype.castTo <MetatypeType>();
57
- // Getting a nontrivial metatype requires forcing any conformances necessary
58
- // to instantiate the type.
59
- switch (theMetatype->getRepresentation ()) {
60
- case MetatypeRepresentation::Thin:
61
- break ;
62
- case MetatypeRepresentation::Thick:
63
- case MetatypeRepresentation::ObjC: {
64
- // Walk the type recursively to look for substitutions we may need.
65
- theMetatype.getInstanceType ().findIf ([&](Type t) -> bool {
66
- auto *decl = t->getAnyNominal ();
67
- if (!decl)
68
- return false ;
69
-
70
- if (isa<ProtocolDecl>(decl))
71
- return false ;
72
-
73
- auto *genericSig = decl->getGenericSignature ();
74
- if (!genericSig)
75
- return false ;
76
-
77
- auto subMap = t->getContextSubstitutionMap (getSILGenModule ().SwiftModule ,
78
- decl);
79
- getSILGenModule ().useConformancesFromSubstitutions (subMap);
80
- return false ;
81
- });
82
-
83
- break ;
84
- }
85
- }
86
-
87
- return SILBuilder::createMetatype (loc, metatype);
88
- }
89
-
90
- ApplyInst *SILGenBuilder::createApply (SILLocation loc, SILValue fn,
91
- SILType substFnTy, SILType result,
92
- SubstitutionMap subs,
93
- ArrayRef<SILValue> args) {
94
- getSILGenModule ().useConformancesFromSubstitutions (subs);
95
- return SILBuilder::createApply (loc, fn, subs, args, false );
96
- }
97
-
98
- TryApplyInst *
99
- SILGenBuilder::createTryApply (SILLocation loc, SILValue fn, SILType substFnTy,
100
- SubstitutionMap subs, ArrayRef<SILValue> args,
101
- SILBasicBlock *normalBB, SILBasicBlock *errorBB) {
102
- getSILGenModule ().useConformancesFromSubstitutions (subs);
103
- return SILBuilder::createTryApply (loc, fn, subs, args, normalBB, errorBB);
104
- }
105
-
106
- BeginApplyInst *
107
- SILGenBuilder::createBeginApply (SILLocation loc, SILValue fn,
108
- SubstitutionMap subs,
109
- ArrayRef<SILValue> args) {
110
- getSILGenModule ().useConformancesFromSubstitutions (subs);
111
- return SILBuilder::createBeginApply (loc, fn, subs, args, false );
112
- }
113
-
114
- PartialApplyInst *
115
- SILGenBuilder::createPartialApply (SILLocation loc, SILValue fn,
116
- SILType substFnTy, SubstitutionMap subs,
117
- ArrayRef<SILValue> args, SILType closureTy) {
118
- getSILGenModule ().useConformancesFromSubstitutions (subs);
119
- return SILBuilder::createPartialApply (
120
- loc, fn, subs, args,
121
- closureTy.getAs <SILFunctionType>()->getCalleeConvention ());
122
- }
123
-
124
-
125
- BuiltinInst *SILGenBuilder::createBuiltin (SILLocation loc, Identifier name,
126
- SILType resultTy,
127
- SubstitutionMap subs,
128
- ArrayRef<SILValue> args) {
129
- getSILGenModule ().useConformancesFromSubstitutions (subs);
130
- return SILBuilder::createBuiltin (loc, name, resultTy, subs, args);
131
- }
132
-
133
- InitExistentialAddrInst *SILGenBuilder::createInitExistentialAddr (
134
- SILLocation loc, SILValue existential, CanType formalConcreteType,
135
- SILType loweredConcreteType,
136
- ArrayRef<ProtocolConformanceRef> conformances) {
137
- for (auto conformance : conformances)
138
- getSILGenModule ().useConformance (conformance);
139
-
140
- return SILBuilder::createInitExistentialAddr (
141
- loc, existential, formalConcreteType, loweredConcreteType, conformances);
142
- }
143
-
144
- InitExistentialValueInst *SILGenBuilder::createInitExistentialValue (
145
- SILLocation Loc, SILType ExistentialType, CanType FormalConcreteType,
146
- SILValue Concrete, ArrayRef<ProtocolConformanceRef> Conformances) {
147
- for (auto conformance : Conformances)
148
- getSILGenModule ().useConformance (conformance);
149
-
150
- return SILBuilder::createInitExistentialValue (
151
- Loc, ExistentialType, FormalConcreteType, Concrete, Conformances);
152
- }
153
-
154
- InitExistentialMetatypeInst *SILGenBuilder::createInitExistentialMetatype (
155
- SILLocation loc, SILValue metatype, SILType existentialType,
156
- ArrayRef<ProtocolConformanceRef> conformances) {
157
- for (auto conformance : conformances)
158
- getSILGenModule ().useConformance (conformance);
159
-
160
- return SILBuilder::createInitExistentialMetatype (
161
- loc, metatype, existentialType, conformances);
162
- }
163
-
164
- InitExistentialRefInst *SILGenBuilder::createInitExistentialRef (
165
- SILLocation loc, SILType existentialType, CanType formalConcreteType,
166
- SILValue concreteValue, ArrayRef<ProtocolConformanceRef> conformances) {
167
- for (auto conformance : conformances)
168
- getSILGenModule ().useConformance (conformance);
169
-
170
- return SILBuilder::createInitExistentialRef (
171
- loc, existentialType, formalConcreteType, concreteValue, conformances);
172
- }
173
-
174
- AllocExistentialBoxInst *SILGenBuilder::createAllocExistentialBox (
175
- SILLocation loc, SILType existentialType, CanType concreteType,
176
- ArrayRef<ProtocolConformanceRef> conformances) {
177
- for (auto conformance : conformances)
178
- getSILGenModule ().useConformance (conformance);
179
-
180
- return SILBuilder::createAllocExistentialBox (loc, existentialType,
181
- concreteType, conformances);
182
- }
44
+ : SILGenSILBuilder(SGF, insertBB, insertInst), SGF(SGF) {}
183
45
184
46
// ===----------------------------------------------------------------------===//
185
47
// Managed Value APIs
@@ -209,8 +71,8 @@ SILGenBuilder::createConvertFunction(SILLocation loc, ManagedValue fn,
209
71
SILType resultTy,
210
72
bool withoutActuallyEscaping) {
211
73
CleanupCloner cloner (*this , fn);
212
- SILValue result = SILBuilder:: createConvertFunction (
213
- loc, fn. forward ( getSILGenFunction ()), resultTy, withoutActuallyEscaping);
74
+ SILValue result = createConvertFunction (loc, fn. forward ( getSILGenFunction ()),
75
+ resultTy, withoutActuallyEscaping);
214
76
return cloner.clone (result);
215
77
}
216
78
@@ -741,7 +603,7 @@ ManagedValue SILGenBuilder::createUncheckedBitCast(SILLocation loc,
741
603
CleanupCloner cloner (*this , value);
742
604
SILValue cast = createUncheckedBitCast (loc, value.getValue (), type);
743
605
744
- // Currently SILBuilder:: createUncheckedBitCast only produces these
606
+ // Currently createUncheckedBitCast only produces these
745
607
// instructions. We assert here to make sure if this changes, this code is
746
608
// updated.
747
609
assert ((isa<UncheckedTrivialBitCastInst>(cast) ||
@@ -962,14 +824,14 @@ void SILGenBuilder::emitDestructureValueOperation(
962
824
SILLocation loc, ManagedValue value,
963
825
llvm::function_ref<void (unsigned , ManagedValue)> func) {
964
826
CleanupCloner cloner (*this , value);
965
- SILBuilder:: emitDestructureValueOperation (
966
- loc, value. forward (SGF), [&](unsigned index, SILValue subValue) {
967
- return func (index, cloner.clone (subValue));
968
- });
827
+ emitDestructureValueOperation (loc, value. forward (SGF),
828
+ [&](unsigned index, SILValue subValue) {
829
+ return func (index, cloner.clone (subValue));
830
+ });
969
831
}
970
832
971
833
ManagedValue SILGenBuilder::createProjectBox (SILLocation loc, ManagedValue mv,
972
834
unsigned index) {
973
- auto *pbi = SILBuilder:: createProjectBox (loc, mv.getValue (), index);
835
+ auto *pbi = createProjectBox (loc, mv.getValue (), index);
974
836
return ManagedValue::forUnmanaged (pbi);
975
837
}
0 commit comments