@@ -495,16 +495,17 @@ class SILExtInfoBuilder {
495495 // If bits are added or removed, then TypeBase::SILFunctionTypeBits
496496 // and NumMaskBits must be updated, and they must match.
497497
498- // |representation|pseudogeneric| noescape |differentiability|
499- // | 0 .. 3 | 4 | 5 | 6 .. 7 |
498+ // |representation|pseudogeneric| noescape | async | differentiability|
499+ // | 0 .. 3 | 4 | 5 | 6 | 7 .. 8 |
500500 //
501501 enum : unsigned {
502502 RepresentationMask = 0xF << 0 ,
503503 PseudogenericMask = 1 << 4 ,
504504 NoEscapeMask = 1 << 5 ,
505- DifferentiabilityMaskOffset = 6 ,
505+ AsyncMask = 1 << 6 ,
506+ DifferentiabilityMaskOffset = 7 ,
506507 DifferentiabilityMask = 0x3 << DifferentiabilityMaskOffset,
507- NumMaskBits = 8
508+ NumMaskBits = 9
508509 };
509510
510511 unsigned bits; // Naturally sized for speed.
@@ -523,10 +524,11 @@ class SILExtInfoBuilder {
523524
524525 // Constructor for polymorphic type.
525526 SILExtInfoBuilder (Representation rep, bool isPseudogeneric, bool isNoEscape,
526- DifferentiabilityKind diffKind, const clang::Type *type)
527+ bool isAsync, DifferentiabilityKind diffKind,
528+ const clang::Type *type)
527529 : SILExtInfoBuilder(
528530 ((unsigned )rep) | (isPseudogeneric ? PseudogenericMask : 0 ) |
529- (isNoEscape ? NoEscapeMask : 0 ) |
531+ (isNoEscape ? NoEscapeMask : 0 ) | (isAsync ? AsyncMask : 0 ) |
530532 (((unsigned )diffKind << DifferentiabilityMaskOffset) &
531533 DifferentiabilityMask),
532534 ClangTypeInfo (type)) {}
@@ -552,6 +554,8 @@ class SILExtInfoBuilder {
552554 // Is this function guaranteed to be no-escape by the type system?
553555 constexpr bool isNoEscape () const { return bits & NoEscapeMask; }
554556
557+ constexpr bool isAsync () const { return bits & AsyncMask; }
558+
555559 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
556560 return DifferentiabilityKind ((bits & DifferentiabilityMask) >>
557561 DifferentiabilityMaskOffset);
@@ -616,6 +620,10 @@ class SILExtInfoBuilder {
616620 : (bits & ~NoEscapeMask),
617621 clangTypeInfo);
618622 }
623+ SILExtInfoBuilder withAsync (bool isAsync = true ) const {
624+ return SILExtInfoBuilder (isAsync ? (bits | AsyncMask) : (bits & ~AsyncMask),
625+ clangTypeInfo);
626+ }
619627 SILExtInfoBuilder
620628 withDifferentiabilityKind (DifferentiabilityKind differentiability) const {
621629 return SILExtInfoBuilder (
@@ -657,8 +665,8 @@ class SILExtInfo {
657665
658666 static SILExtInfo getThin () {
659667 return SILExtInfoBuilder (SILExtInfoBuilder::Representation::Thin, false ,
660- false , DifferentiabilityKind::NonDifferentiable ,
661- nullptr )
668+ false , false ,
669+ DifferentiabilityKind::NonDifferentiable, nullptr )
662670 .build ();
663671 }
664672
@@ -681,6 +689,8 @@ class SILExtInfo {
681689
682690 constexpr bool isNoEscape () const { return builder.isNoEscape (); }
683691
692+ constexpr bool isAsync () const { return builder.isAsync (); }
693+
684694 constexpr DifferentiabilityKind getDifferentiabilityKind () const {
685695 return builder.getDifferentiabilityKind ();
686696 }
0 commit comments