@@ -289,7 +289,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
289
289
290
290
// / Extra information which affects how the function is called, like
291
291
// / regparm and the calling convention.
292
- unsigned ExtInfo : 7 ;
292
+ unsigned ExtInfo : 7 ; enum { NumExtInfoBits = 7 };
293
293
};
294
294
enum { NumAnyFunctionTypeBits = NumTypeBaseBits + 7 };
295
295
static_assert (NumAnyFunctionTypeBits <= 32 , " fits in an unsigned" );
@@ -316,7 +316,7 @@ class alignas(1 << TypeAlignInBits) TypeBase {
316
316
317
317
struct SILFunctionTypeBitfields {
318
318
unsigned : NumTypeBaseBits;
319
- unsigned ExtInfo : 6 ;
319
+ unsigned ExtInfo : 6 ; enum { NumExtInfoBits = 6 };
320
320
unsigned CalleeConvention : 3 ;
321
321
unsigned HasErrorResult : 1 ;
322
322
unsigned CoroutineKind : 2 ;
@@ -2392,20 +2392,21 @@ class AnyFunctionType : public TypeBase {
2392
2392
// / \brief A class which abstracts out some details necessary for
2393
2393
// / making a call.
2394
2394
class ExtInfo {
2395
- // NOTE: If bits are added or removed, then TypeBase::AnyFunctionTypeBits
2396
- // must be updated to match.
2397
-
2395
+ // If bits are added or removed, then TypeBase::AnyFunctionTypeBits
2396
+ // and NumMaskBits must be updated, and they must match.
2397
+ //
2398
2398
// |representation|isAutoClosure|noEscape|throws|
2399
2399
// | 0 .. 3 | 4 | 5 | 6 |
2400
2400
//
2401
2401
enum : unsigned {
2402
- RepresentationMask = 0x0F ,
2403
- AutoClosureMask = 0x10 ,
2404
- NoEscapeMask = 0x20 ,
2405
- ThrowsMask = 0x40 ,
2402
+ RepresentationMask = 0xF << 0 ,
2403
+ AutoClosureMask = 1 << 4 ,
2404
+ NoEscapeMask = 1 << 5 ,
2405
+ ThrowsMask = 1 << 6 ,
2406
+ NumMaskBits = 7
2406
2407
};
2407
2408
2408
- unsigned Bits;
2409
+ unsigned Bits; // Naturally sized for speed.
2409
2410
2410
2411
ExtInfo (unsigned Bits) : Bits(Bits) {}
2411
2412
@@ -2505,7 +2506,7 @@ class AnyFunctionType : public TypeBase {
2505
2506
return ExtInfo (Bits & ~ThrowsMask);
2506
2507
}
2507
2508
2508
- uint16_t getFuncAttrKey () const {
2509
+ unsigned getFuncAttrKey () const {
2509
2510
return Bits;
2510
2511
}
2511
2512
@@ -2539,7 +2540,11 @@ class AnyFunctionType : public TypeBase {
2539
2540
: TypeBase(Kind, CanTypeContext, properties), Input(Input), Output(Output),
2540
2541
NumParams (NumParams) {
2541
2542
AnyFunctionTypeBits.ExtInfo = Info.Bits ;
2543
+ // The use of both assert() and static_assert() is intentional.
2542
2544
assert (AnyFunctionTypeBits.ExtInfo == Info.Bits && " Bits were dropped!" );
2545
+ static_assert (ExtInfo::NumMaskBits ==
2546
+ AnyFunctionTypeBitfields::NumExtInfoBits,
2547
+ " ExtInfo and AnyFunctionTypeBitfields must agree on bit size" );
2543
2548
}
2544
2549
2545
2550
public:
@@ -3249,19 +3254,20 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
3249
3254
// / \brief A class which abstracts out some details necessary for
3250
3255
// / making a call.
3251
3256
class ExtInfo {
3252
- // NOTE: If bits are added or removed, then TypeBase::SILFunctionTypeBits
3253
- // must be updated to match.
3257
+ // If bits are added or removed, then TypeBase::SILFunctionTypeBits
3258
+ // and NumMaskBits must be updated, and they must match.
3254
3259
3255
3260
// |representation|pseudogeneric| noescape |
3256
3261
// | 0 .. 3 | 4 | 5 |
3257
3262
//
3258
3263
enum : unsigned {
3259
- RepresentationMask = 0x0F ,
3260
- PseudogenericMask = 0x10 ,
3261
- NoEscapeMask = 0x20 ,
3264
+ RepresentationMask = 0xF << 0 ,
3265
+ PseudogenericMask = 1 << 4 ,
3266
+ NoEscapeMask = 1 << 5 ,
3267
+ NumMaskBits = 6
3262
3268
};
3263
3269
3264
- unsigned Bits;
3270
+ unsigned Bits; // Naturally sized for speed.
3265
3271
3266
3272
ExtInfo (unsigned Bits) : Bits(Bits) {}
3267
3273
@@ -3364,7 +3370,7 @@ class SILFunctionType final : public TypeBase, public llvm::FoldingSetNode,
3364
3370
return ExtInfo (Bits & ~NoEscapeMask);
3365
3371
}
3366
3372
3367
- uint16_t getFuncAttrKey () const {
3373
+ unsigned getFuncAttrKey () const {
3368
3374
return Bits;
3369
3375
}
3370
3376
0 commit comments