@@ -615,17 +615,18 @@ class SILExtInfoBuilder {
615
615
// If bits are added or removed, then TypeBase::SILFunctionTypeBits
616
616
// and NumMaskBits must be updated, and they must match.
617
617
618
- // |representation|pseudogeneric| noescape | async | differentiability|
619
- // | 0 .. 3 | 4 | 5 | 6 | 7 .. 8 |
618
+ // |representation|pseudogeneric| noescape | concurrent | async | differentiability|
619
+ // | 0 .. 3 | 4 | 5 | 6 | 7 | 8 .. 9 |
620
620
//
621
621
enum : unsigned {
622
622
RepresentationMask = 0xF << 0 ,
623
623
PseudogenericMask = 1 << 4 ,
624
624
NoEscapeMask = 1 << 5 ,
625
- AsyncMask = 1 << 6 ,
626
- DifferentiabilityMaskOffset = 7 ,
625
+ ConcurrentMask = 1 << 6 ,
626
+ AsyncMask = 1 << 7 ,
627
+ DifferentiabilityMaskOffset = 8 ,
627
628
DifferentiabilityMask = 0x3 << DifferentiabilityMaskOffset,
628
- NumMaskBits = 9
629
+ NumMaskBits = 10
629
630
};
630
631
631
632
unsigned bits; // Naturally sized for speed.
@@ -639,10 +640,13 @@ class SILExtInfoBuilder {
639
640
: bits(bits), clangTypeInfo(clangTypeInfo.getCanonical()) {}
640
641
641
642
static constexpr unsigned makeBits (Representation rep, bool isPseudogeneric,
642
- bool isNoEscape, bool isAsync,
643
+ bool isNoEscape, bool isConcurrent,
644
+ bool isAsync,
643
645
DifferentiabilityKind diffKind) {
644
646
return ((unsigned )rep) | (isPseudogeneric ? PseudogenericMask : 0 ) |
645
- (isNoEscape ? NoEscapeMask : 0 ) | (isAsync ? AsyncMask : 0 ) |
647
+ (isNoEscape ? NoEscapeMask : 0 ) |
648
+ (isConcurrent ? ConcurrentMask : 0 ) |
649
+ (isAsync ? AsyncMask : 0 ) |
646
650
(((unsigned )diffKind << DifferentiabilityMaskOffset) &
647
651
DifferentiabilityMask);
648
652
}
@@ -652,21 +656,22 @@ class SILExtInfoBuilder {
652
656
// / non-pseudogeneric, non-differentiable.
653
657
SILExtInfoBuilder ()
654
658
: SILExtInfoBuilder(makeBits(SILFunctionTypeRepresentation::Thick, false ,
655
- false , false ,
659
+ false , false , false ,
656
660
DifferentiabilityKind::NonDifferentiable),
657
661
ClangTypeInfo (nullptr )) {}
658
662
659
663
SILExtInfoBuilder (Representation rep, bool isPseudogeneric, bool isNoEscape,
660
- bool isAsync, DifferentiabilityKind diffKind ,
661
- const clang::Type *type)
662
- : SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape, isAsync,
663
- diffKind),
664
+ bool isConcurrent, bool isAsync ,
665
+ DifferentiabilityKind diffKind, const clang::Type *type)
666
+ : SILExtInfoBuilder(makeBits(rep, isPseudogeneric, isNoEscape,
667
+ isConcurrent, isAsync, diffKind),
664
668
ClangTypeInfo(type)) {}
665
669
666
670
// Constructor for polymorphic type.
667
671
SILExtInfoBuilder (ASTExtInfoBuilder info, bool isPseudogeneric)
668
672
: SILExtInfoBuilder(makeBits(info.getSILRepresentation(), isPseudogeneric,
669
- info.isNoEscape(), info.isAsync(),
673
+ info.isNoEscape(), info.isConcurrent(),
674
+ info.isAsync(),
670
675
info.getDifferentiabilityKind()),
671
676
info.getClangTypeInfo()) {}
672
677
@@ -691,6 +696,8 @@ class SILExtInfoBuilder {
691
696
// Is this function guaranteed to be no-escape by the type system?
692
697
constexpr bool isNoEscape () const { return bits & NoEscapeMask; }
693
698
699
+ constexpr bool isConcurrent () const { return bits & ConcurrentMask; }
700
+
694
701
constexpr bool isAsync () const { return bits & AsyncMask; }
695
702
696
703
constexpr DifferentiabilityKind getDifferentiabilityKind () const {
@@ -760,6 +767,12 @@ class SILExtInfoBuilder {
760
767
clangTypeInfo);
761
768
}
762
769
LLVM_NODISCARD
770
+ SILExtInfoBuilder withConcurrent (bool isConcurrent = true ) const {
771
+ return SILExtInfoBuilder (isConcurrent ? (bits | ConcurrentMask)
772
+ : (bits & ~ConcurrentMask),
773
+ clangTypeInfo);
774
+ }
775
+ LLVM_NODISCARD
763
776
SILExtInfoBuilder withAsync (bool isAsync = true ) const {
764
777
return SILExtInfoBuilder (isAsync ? (bits | AsyncMask) : (bits & ~AsyncMask),
765
778
clangTypeInfo);
@@ -822,7 +835,7 @@ class SILExtInfo {
822
835
// / A default ExtInfo but with a Thin convention.
823
836
static SILExtInfo getThin () {
824
837
return SILExtInfoBuilder (SILExtInfoBuilder::Representation::Thin, false ,
825
- false , false ,
838
+ false , false , false ,
826
839
DifferentiabilityKind::NonDifferentiable, nullptr )
827
840
.build ();
828
841
}
@@ -846,6 +859,8 @@ class SILExtInfo {
846
859
847
860
constexpr bool isNoEscape () const { return builder.isNoEscape (); }
848
861
862
+ constexpr bool isConcurrent () const { return builder.isConcurrent (); }
863
+
849
864
constexpr bool isAsync () const { return builder.isAsync (); }
850
865
851
866
constexpr DifferentiabilityKind getDifferentiabilityKind () const {
@@ -874,6 +889,9 @@ class SILExtInfo {
874
889
return builder.withNoEscape (noEscape).build ();
875
890
}
876
891
892
+ SILExtInfo withConcurrent (bool isConcurrent = true ) const {
893
+ return builder.withConcurrent (isConcurrent).build ();
894
+ }
877
895
878
896
SILExtInfo withAsync (bool isAsync = true ) const {
879
897
return builder.withAsync (isAsync).build ();
0 commit comments