Skip to content

Commit 354ce41

Browse files
committed
SIL: Add type lowering APIs to SILFunction
For now these just forward to methods on the module's TypeLowering, but soon they will use the SILFunction's resilience expansion.
1 parent e648016 commit 354ce41

File tree

4 files changed

+68
-11
lines changed

4 files changed

+68
-11
lines changed

include/swift/SIL/SILFunction.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class SILModule;
3838
class SILFunctionBuilder;
3939
class SILProfiler;
4040

41+
namespace Lowering {
42+
class TypeLowering;
43+
class AbstractionPattern;
44+
}
45+
4146
enum IsBare_t { IsNotBare, IsBare };
4247
enum IsTransparent_t { IsNotTransparent, IsTransparent };
4348
enum Inline_t { InlineDefault, NoInline, AlwaysInline };
@@ -464,6 +469,19 @@ class SILFunction
464469
: ResilienceExpansion::Maximal);
465470
}
466471

472+
const Lowering::TypeLowering &
473+
getTypeLowering(Lowering::AbstractionPattern orig, Type subst);
474+
475+
const Lowering::TypeLowering &getTypeLowering(Type t) const;
476+
477+
SILType getLoweredType(Lowering::AbstractionPattern orig, Type subst) const;
478+
479+
SILType getLoweredType(Type t) const;
480+
481+
SILType getLoweredLoadableType(Type t) const;
482+
483+
const Lowering::TypeLowering &getTypeLowering(SILType type) const;
484+
467485
/// Returns true if this function has a calling convention that has a self
468486
/// argument.
469487
bool hasSelfParam() const {

include/swift/SIL/TypeLowering.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,13 +769,16 @@ class TypeConverter {
769769
ResilienceExpansion::Minimal);
770770

771771
// Returns the lowered SIL type for a Swift type.
772-
SILType getLoweredType(Type t) {
773-
return getTypeLowering(t, ResilienceExpansion::Minimal).getLoweredType();
772+
SILType getLoweredType(Type t, ResilienceExpansion forExpansion
773+
= ResilienceExpansion::Minimal) {
774+
return getTypeLowering(t, forExpansion).getLoweredType();
774775
}
775776

776777
// Returns the lowered SIL type for a Swift type.
777-
SILType getLoweredType(AbstractionPattern origType, Type substType) {
778-
return getTypeLowering(origType, substType, ResilienceExpansion::Minimal)
778+
SILType getLoweredType(AbstractionPattern origType, Type substType,
779+
ResilienceExpansion forExpansion =
780+
ResilienceExpansion::Minimal) {
781+
return getTypeLowering(origType, substType, forExpansion)
779782
.getLoweredType();
780783
}
781784

lib/SIL/SILFunction.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,43 @@ bool SILFunction::isNoReturnFunction() const {
226226
.isNoReturnFunction();
227227
}
228228

229+
const TypeLowering &
230+
SILFunction::getTypeLowering(AbstractionPattern orig, Type subst) {
231+
// FIXME: Expansion
232+
return getModule().Types.getTypeLowering(orig, subst,
233+
ResilienceExpansion::Minimal);
234+
}
235+
236+
const TypeLowering &SILFunction::getTypeLowering(Type t) const {
237+
// FIXME: Expansion
238+
return getModule().Types.getTypeLowering(t, ResilienceExpansion::Minimal);
239+
}
240+
241+
SILType
242+
SILFunction::getLoweredType(AbstractionPattern orig, Type subst) const {
243+
// FIXME: Expansion
244+
return getModule().Types.getLoweredType(orig, subst,
245+
ResilienceExpansion::Minimal);
246+
}
247+
248+
SILType SILFunction::getLoweredType(Type t) const {
249+
// FIXME: Expansion
250+
return getModule().Types.getLoweredType(t,
251+
ResilienceExpansion::Minimal);
252+
}
253+
254+
SILType SILFunction::getLoweredLoadableType(Type t) const {
255+
// FIXME: Expansion
256+
return getModule().Types.getLoweredLoadableType(t,
257+
ResilienceExpansion::Minimal);
258+
}
259+
260+
const TypeLowering &SILFunction::getTypeLowering(SILType type) const {
261+
// FIXME: Expansion
262+
return getModule().Types.getTypeLowering(type,
263+
ResilienceExpansion::Minimal);
264+
}
265+
229266
SILBasicBlock *SILFunction::createBasicBlock() {
230267
return new (getModule()) SILBasicBlock(this, nullptr, false);
231268
}

lib/SILGen/SILGenFunction.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -495,27 +495,26 @@ class LLVM_LIBRARY_VISIBILITY SILGenFunction
495495
SILOptions &getOptions() { return getModule().getOptions(); }
496496

497497
const TypeLowering &getTypeLowering(AbstractionPattern orig, Type subst) {
498-
return SGM.Types.getTypeLowering(orig, subst);
498+
return F.getTypeLowering(orig, subst);
499499
}
500500
const TypeLowering &getTypeLowering(Type t) {
501-
return SGM.Types.getTypeLowering(t);
501+
return F.getTypeLowering(t);
502502
}
503503
CanSILFunctionType getSILFunctionType(AbstractionPattern orig,
504504
CanFunctionType substFnType) {
505505
return SGM.Types.getSILFunctionType(orig, substFnType);
506506
}
507507
SILType getLoweredType(AbstractionPattern orig, Type subst) {
508-
return SGM.Types.getLoweredType(orig, subst);
508+
return F.getLoweredType(orig, subst);
509509
}
510510
SILType getLoweredType(Type t) {
511-
return SGM.Types.getLoweredType(t);
511+
return F.getLoweredType(t);
512512
}
513513
SILType getLoweredLoadableType(Type t) {
514-
return SGM.Types.getLoweredLoadableType(t);
514+
return F.getLoweredLoadableType(t);
515515
}
516-
517516
const TypeLowering &getTypeLowering(SILType type) {
518-
return SGM.Types.getTypeLowering(type);
517+
return F.getTypeLowering(type);
519518
}
520519

521520
SILType getSILType(SILParameterInfo param) const {

0 commit comments

Comments
 (0)