@@ -71,50 +71,49 @@ MetatypeInst *SILGenBuilder::createMetatype(SILLocation loc, SILType metatype) {
71
71
return SILBuilder::createMetatype (loc, metatype);
72
72
}
73
73
74
- ApplyInst *SILGenBuilder::createApply (SILLocation Loc, SILValue Fn,
75
- SILType SubstFnTy, SILType Result,
76
- SubstitutionList Subs,
77
- ArrayRef<SILValue> Args) {
78
- getSILGenModule ().useConformancesFromSubstitutions (Subs);
79
- return SILBuilder::createApply (Loc, Fn, SubstFnTy, Result, Subs, Args, false );
80
- }
81
-
82
- TryApplyInst *SILGenBuilder::createTryApply (SILLocation loc, SILValue Fn,
83
- SILType substFnTy,
84
- SubstitutionList subs,
85
- ArrayRef<SILValue> args,
86
- SILBasicBlock *normalBB,
87
- SILBasicBlock *errorBB) {
74
+ ApplyInst *SILGenBuilder::createApply (SILLocation loc, SILValue fn,
75
+ SILType substFnTy, SILType result,
76
+ SubstitutionList subs,
77
+ ArrayRef<SILValue> args) {
88
78
getSILGenModule ().useConformancesFromSubstitutions (subs);
89
- return SILBuilder::createTryApply (loc, Fn, substFnTy, subs, args, normalBB,
79
+ return SILBuilder::createApply (loc, fn, substFnTy, result, subs, args, false );
80
+ }
81
+
82
+ TryApplyInst *
83
+ SILGenBuilder::createTryApply (SILLocation loc, SILValue fn, SILType substFnTy,
84
+ SubstitutionList subs, ArrayRef<SILValue> args,
85
+ SILBasicBlock *normalBB, SILBasicBlock *errorBB) {
86
+ getSILGenModule ().useConformancesFromSubstitutions (subs);
87
+ return SILBuilder::createTryApply (loc, fn, substFnTy, subs, args, normalBB,
90
88
errorBB);
91
89
}
92
90
93
- PartialApplyInst *SILGenBuilder::createPartialApply (
94
- SILLocation Loc, SILValue Fn, SILType SubstFnTy,
95
- SubstitutionList Subs, ArrayRef<SILValue> Args, SILType ClosureTy) {
96
- getSILGenModule ().useConformancesFromSubstitutions (Subs);
97
- return SILBuilder::createPartialApply (Loc, Fn, SubstFnTy, Subs, Args,
98
- ClosureTy);
91
+ PartialApplyInst *
92
+ SILGenBuilder::createPartialApply (SILLocation loc, SILValue fn,
93
+ SILType substFnTy, SubstitutionList subs,
94
+ ArrayRef<SILValue> args, SILType closureTy) {
95
+ getSILGenModule ().useConformancesFromSubstitutions (subs);
96
+ return SILBuilder::createPartialApply (loc, fn, substFnTy, subs, args,
97
+ closureTy);
99
98
}
100
99
101
- BuiltinInst *SILGenBuilder::createBuiltin (SILLocation Loc , Identifier Name ,
102
- SILType ResultTy ,
103
- SubstitutionList Subs ,
104
- ArrayRef<SILValue> Args ) {
105
- getSILGenModule ().useConformancesFromSubstitutions (Subs );
106
- return SILBuilder::createBuiltin (Loc, Name, ResultTy, Subs, Args );
100
+ BuiltinInst *SILGenBuilder::createBuiltin (SILLocation loc , Identifier name ,
101
+ SILType resultTy ,
102
+ SubstitutionList subs ,
103
+ ArrayRef<SILValue> args ) {
104
+ getSILGenModule ().useConformancesFromSubstitutions (subs );
105
+ return SILBuilder::createBuiltin (loc, name, resultTy, subs, args );
107
106
}
108
107
109
108
InitExistentialAddrInst *SILGenBuilder::createInitExistentialAddr (
110
- SILLocation Loc , SILValue Existential , CanType FormalConcreteType ,
111
- SILType LoweredConcreteType ,
112
- ArrayRef<ProtocolConformanceRef> Conformances ) {
113
- for (auto conformance : Conformances )
109
+ SILLocation loc , SILValue existential , CanType formalConcreteType ,
110
+ SILType loweredConcreteType ,
111
+ ArrayRef<ProtocolConformanceRef> conformances ) {
112
+ for (auto conformance : conformances )
114
113
getSILGenModule ().useConformance (conformance);
115
114
116
115
return SILBuilder::createInitExistentialAddr (
117
- Loc, Existential, FormalConcreteType, LoweredConcreteType, Conformances );
116
+ loc, existential, formalConcreteType, loweredConcreteType, conformances );
118
117
}
119
118
120
119
InitExistentialMetatypeInst *SILGenBuilder::createInitExistentialMetatype (
@@ -128,111 +127,115 @@ InitExistentialMetatypeInst *SILGenBuilder::createInitExistentialMetatype(
128
127
}
129
128
130
129
InitExistentialRefInst *SILGenBuilder::createInitExistentialRef (
131
- SILLocation Loc , SILType ExistentialType , CanType FormalConcreteType ,
132
- SILValue Concrete , ArrayRef<ProtocolConformanceRef> Conformances ) {
133
- for (auto conformance : Conformances )
130
+ SILLocation loc , SILType existentialType , CanType formalConcreteType ,
131
+ SILValue concreteValue , ArrayRef<ProtocolConformanceRef> conformances ) {
132
+ for (auto conformance : conformances )
134
133
getSILGenModule ().useConformance (conformance);
135
134
136
135
return SILBuilder::createInitExistentialRef (
137
- Loc, ExistentialType, FormalConcreteType, Concrete, Conformances );
136
+ loc, existentialType, formalConcreteType, concreteValue, conformances );
138
137
}
139
138
140
139
AllocExistentialBoxInst *SILGenBuilder::createAllocExistentialBox (
141
- SILLocation Loc , SILType ExistentialType , CanType ConcreteType ,
142
- ArrayRef<ProtocolConformanceRef> Conformances ) {
143
- for (auto conformance : Conformances )
140
+ SILLocation loc , SILType existentialType , CanType concreteType ,
141
+ ArrayRef<ProtocolConformanceRef> conformances ) {
142
+ for (auto conformance : conformances )
144
143
getSILGenModule ().useConformance (conformance);
145
144
146
- return SILBuilder::createAllocExistentialBox (Loc, ExistentialType ,
147
- ConcreteType, Conformances );
145
+ return SILBuilder::createAllocExistentialBox (loc, existentialType ,
146
+ concreteType, conformances );
148
147
}
149
148
150
- ManagedValue SILGenBuilder::createStructExtract (SILLocation Loc ,
151
- ManagedValue Base ,
152
- VarDecl *Decl ) {
153
- ManagedValue BorrowedBase = gen.emitManagedBeginBorrow (Loc, Base .getValue ());
154
- SILValue StructExtract =
155
- SILBuilder::createStructExtract (Loc, BorrowedBase .getValue (), Decl );
156
- return ManagedValue::forUnmanaged (StructExtract );
149
+ ManagedValue SILGenBuilder::createStructExtract (SILLocation loc ,
150
+ ManagedValue base ,
151
+ VarDecl *decl ) {
152
+ ManagedValue borrowedBase = gen.emitManagedBeginBorrow (loc, base .getValue ());
153
+ SILValue extract =
154
+ SILBuilder::createStructExtract (loc, borrowedBase .getValue (), decl );
155
+ return ManagedValue::forUnmanaged (extract );
157
156
}
158
157
159
- ManagedValue SILGenBuilder::createCopyValue (SILLocation Loc ,
160
- ManagedValue OriginalValue ) {
161
- SILValue Result = SILBuilder::createCopyValue (Loc, OriginalValue .getValue ());
162
- return gen.emitManagedRValueWithCleanup (Result );
158
+ ManagedValue SILGenBuilder::createCopyValue (SILLocation loc ,
159
+ ManagedValue originalValue ) {
160
+ SILValue result = SILBuilder::createCopyValue (loc, originalValue .getValue ());
161
+ return gen.emitManagedRValueWithCleanup (result );
163
162
}
164
163
165
- ManagedValue SILGenBuilder::createCopyUnownedValue (SILLocation Loc ,
166
- ManagedValue OriginalValue ) {
167
- auto UnownedType = OriginalValue .getType ().castTo <UnownedStorageType>();
168
- assert (UnownedType ->isLoadable (ResilienceExpansion::Maximal));
169
- (void )UnownedType ;
164
+ ManagedValue SILGenBuilder::createCopyUnownedValue (SILLocation loc ,
165
+ ManagedValue originalValue ) {
166
+ auto unownedType = originalValue .getType ().castTo <UnownedStorageType>();
167
+ assert (unownedType ->isLoadable (ResilienceExpansion::Maximal));
168
+ (void )unownedType ;
170
169
171
- SILValue Result =
172
- SILBuilder::createCopyUnownedValue (Loc, OriginalValue .getValue ());
173
- return gen.emitManagedRValueWithCleanup (Result );
170
+ SILValue result =
171
+ SILBuilder::createCopyUnownedValue (loc, originalValue .getValue ());
172
+ return gen.emitManagedRValueWithCleanup (result );
174
173
}
175
174
176
175
ManagedValue
177
- SILGenBuilder::createUnsafeCopyUnownedValue (SILLocation Loc,
178
- ManagedValue OriginalValue) {
179
- auto UnmanagedType = OriginalValue.getType ().getAs <UnmanagedStorageType>();
180
- SILValue Result = SILBuilder::createUnmanagedToRef (
181
- Loc, OriginalValue.getValue (),
182
- SILType::getPrimitiveObjectType (UnmanagedType.getReferentType ()));
183
- SILBuilder::createUnmanagedRetainValue (Loc, Result);
184
- return gen.emitManagedRValueWithCleanup (Result);
185
- }
186
-
187
- ManagedValue SILGenBuilder::createOwnedPHIArgument (SILType Type) {
188
- SILPHIArgument *Arg =
189
- getInsertionBB ()->createPHIArgument (Type, ValueOwnershipKind::Owned);
190
- return gen.emitManagedRValueWithCleanup (Arg);
191
- }
192
-
193
- ManagedValue SILGenBuilder::createAllocRef (SILLocation Loc, SILType RefType, bool objc, bool canAllocOnStack,
194
- ArrayRef<SILType> InputElementTypes,
195
- ArrayRef<ManagedValue> InputElementCountOperands) {
196
- llvm::SmallVector<SILType, 8 > ElementTypes (InputElementTypes.begin (),
197
- InputElementTypes.end ());
198
- llvm::SmallVector<SILValue, 8 > ElementCountOperands;
199
- std::transform (std::begin (InputElementCountOperands),
200
- std::end (InputElementCountOperands),
201
- std::back_inserter (ElementCountOperands),
202
- [](ManagedValue M) -> SILValue { return M.getValue (); });
203
-
204
- AllocRefInst *ARI =
205
- SILBuilder::createAllocRef (Loc, RefType, objc, canAllocOnStack,
206
- ElementTypes, ElementCountOperands);
207
- return gen.emitManagedRValueWithCleanup (ARI);
208
- }
209
-
210
- ManagedValue SILGenBuilder::createAllocRefDynamic (SILLocation Loc, ManagedValue Operand, SILType RefType, bool objc,
211
- ArrayRef<SILType> InputElementTypes,
212
- ArrayRef<ManagedValue> InputElementCountOperands) {
213
- llvm::SmallVector<SILType, 8 > ElementTypes (InputElementTypes.begin (),
214
- InputElementTypes.end ());
215
- llvm::SmallVector<SILValue, 8 > ElementCountOperands;
216
- std::transform (std::begin (InputElementCountOperands),
217
- std::end (InputElementCountOperands),
218
- std::back_inserter (ElementCountOperands),
219
- [](ManagedValue M) -> SILValue { return M.getValue (); });
220
-
221
- AllocRefDynamicInst *ARDI =
222
- SILBuilder::createAllocRefDynamic (Loc, Operand.getValue (), RefType, objc,
223
- ElementTypes, ElementCountOperands);
224
- return gen.emitManagedRValueWithCleanup (ARDI);
225
- }
226
-
227
- ManagedValue SILGenBuilder::createTupleExtract (SILLocation Loc, ManagedValue Base, unsigned Index,
228
- SILType Type) {
229
- ManagedValue BorrowedBase = gen.emitManagedBeginBorrow (Loc, Base.getValue ());
230
- SILValue TupleExtract =
231
- SILBuilder::createTupleExtract (Loc, BorrowedBase.getValue (), Index, Type);
232
- return ManagedValue::forUnmanaged (TupleExtract);
233
- }
234
-
235
- ManagedValue SILGenBuilder::createTupleExtract (SILLocation Loc, ManagedValue Value, unsigned Index) {
236
- SILType Type = Value.getType ().getTupleElementType (Index);
237
- return createTupleExtract (Loc, Value, Index, Type);
176
+ SILGenBuilder::createUnsafeCopyUnownedValue (SILLocation loc,
177
+ ManagedValue originalValue) {
178
+ auto unmanagedType = originalValue.getType ().getAs <UnmanagedStorageType>();
179
+ SILValue result = SILBuilder::createUnmanagedToRef (
180
+ loc, originalValue.getValue (),
181
+ SILType::getPrimitiveObjectType (unmanagedType.getReferentType ()));
182
+ SILBuilder::createUnmanagedRetainValue (loc, result);
183
+ return gen.emitManagedRValueWithCleanup (result);
184
+ }
185
+
186
+ ManagedValue SILGenBuilder::createOwnedPHIArgument (SILType type) {
187
+ SILPHIArgument *arg =
188
+ getInsertionBB ()->createPHIArgument (type, ValueOwnershipKind::Owned);
189
+ return gen.emitManagedRValueWithCleanup (arg);
190
+ }
191
+
192
+ ManagedValue SILGenBuilder::createAllocRef (
193
+ SILLocation loc, SILType refType, bool objc, bool canAllocOnStack,
194
+ ArrayRef<SILType> inputElementTypes,
195
+ ArrayRef<ManagedValue> inputElementCountOperands) {
196
+ llvm::SmallVector<SILType, 8 > elementTypes (inputElementTypes.begin (),
197
+ inputElementTypes.end ());
198
+ llvm::SmallVector<SILValue, 8 > elementCountOperands;
199
+ std::transform (std::begin (inputElementCountOperands),
200
+ std::end (inputElementCountOperands),
201
+ std::back_inserter (elementCountOperands),
202
+ [](ManagedValue mv) -> SILValue { return mv.getValue (); });
203
+
204
+ AllocRefInst *i = SILBuilder::createAllocRef (
205
+ loc, refType, objc, canAllocOnStack, elementTypes, elementCountOperands);
206
+ return gen.emitManagedRValueWithCleanup (i);
207
+ }
208
+
209
+ ManagedValue SILGenBuilder::createAllocRefDynamic (
210
+ SILLocation loc, ManagedValue operand, SILType refType, bool objc,
211
+ ArrayRef<SILType> inputElementTypes,
212
+ ArrayRef<ManagedValue> inputElementCountOperands) {
213
+ llvm::SmallVector<SILType, 8 > elementTypes (inputElementTypes.begin (),
214
+ inputElementTypes.end ());
215
+ llvm::SmallVector<SILValue, 8 > elementCountOperands;
216
+ std::transform (std::begin (inputElementCountOperands),
217
+ std::end (inputElementCountOperands),
218
+ std::back_inserter (elementCountOperands),
219
+ [](ManagedValue mv) -> SILValue { return mv.getValue (); });
220
+
221
+ AllocRefDynamicInst *i =
222
+ SILBuilder::createAllocRefDynamic (loc, operand.getValue (), refType, objc,
223
+ elementTypes, elementCountOperands);
224
+ return gen.emitManagedRValueWithCleanup (i);
225
+ }
226
+
227
+ ManagedValue SILGenBuilder::createTupleExtract (SILLocation loc,
228
+ ManagedValue base,
229
+ unsigned index, SILType type) {
230
+ ManagedValue borrowedBase = gen.emitManagedBeginBorrow (loc, base.getValue ());
231
+ SILValue extract =
232
+ SILBuilder::createTupleExtract (loc, borrowedBase.getValue (), index, type);
233
+ return ManagedValue::forUnmanaged (extract);
234
+ }
235
+
236
+ ManagedValue SILGenBuilder::createTupleExtract (SILLocation loc,
237
+ ManagedValue value,
238
+ unsigned index) {
239
+ SILType type = value.getType ().getTupleElementType (index);
240
+ return createTupleExtract (loc, value, index, type);
238
241
}
0 commit comments