@@ -4029,6 +4029,22 @@ class FunctionType : public Type {
4029
4029
// / because TrailingObjects cannot handle repeated types.
4030
4030
struct ExceptionType { QualType Type; };
4031
4031
4032
+ // / A simple holder for various uncommon bits which do not fit in
4033
+ // / FunctionTypeBitfields. Aligned to alignof(void *) to maintain the
4034
+ // / alignment of subsequent objects in TrailingObjects.
4035
+ struct alignas (void *) FunctionTypeExtraBitfields {
4036
+ // / The number of types in the exception specification.
4037
+ // / A whole unsigned is not needed here and according to
4038
+ // / [implimits] 8 bits would be enough here.
4039
+ unsigned NumExceptionType : 10 ;
4040
+
4041
+ LLVM_PREFERRED_TYPE (bool )
4042
+ unsigned HasArmTypeAttributes : 1 ;
4043
+
4044
+ FunctionTypeExtraBitfields ()
4045
+ : NumExceptionType (0 ), HasArmTypeAttributes (false ) {}
4046
+ };
4047
+
4032
4048
// / The AArch64 SME ACLE (Arm C/C++ Language Extensions) define a number
4033
4049
// / of function type attributes that can be set on function types, including
4034
4050
// / function pointers.
@@ -4042,7 +4058,8 @@ class FunctionType : public Type {
4042
4058
SME_ZAMask = 0b111 << SME_ZAShift,
4043
4059
4044
4060
SME_AttributeMask = 0b111'111 // We only support maximum 6 bits because of
4045
- // the bitmask in FunctionTypeExtraBitfields.
4061
+ // the bitmask in FunctionTypeArmAttributes
4062
+ // and ExtProtoInfo.
4046
4063
};
4047
4064
4048
4065
enum ArmStateValue : unsigned {
@@ -4057,20 +4074,15 @@ class FunctionType : public Type {
4057
4074
return (ArmStateValue)((AttrBits & SME_ZAMask) >> SME_ZAShift);
4058
4075
}
4059
4076
4060
- // / A simple holder for various uncommon bits which do not fit in
4061
- // / FunctionTypeBitfields. Aligned to alignof(void *) to maintain the
4062
- // / alignment of subsequent objects in TrailingObjects.
4063
- struct alignas (void *) FunctionTypeExtraBitfields {
4064
- // / The number of types in the exception specification.
4065
- // / A whole unsigned is not needed here and according to
4066
- // / [implimits] 8 bits would be enough here.
4067
- unsigned NumExceptionType : 10 ;
4068
-
4077
+ // / A holder for Arm type attributes as described in the Arm C/C++
4078
+ // / Language extensions which are not particularly common to all
4079
+ // / types and therefore accounted separately from FunctionTypeBitfields.
4080
+ struct alignas (void *) FunctionTypeArmAttributes {
4069
4081
// / Any AArch64 SME ACLE type attributes that need to be propagated
4070
4082
// / on declarations and function pointers.
4071
4083
unsigned AArch64SMEAttributes : 6 ;
4072
- FunctionTypeExtraBitfields ()
4073
- : NumExceptionType ( 0 ), AArch64SMEAttributes (SME_NormalFunction) {}
4084
+
4085
+ FunctionTypeArmAttributes () : AArch64SMEAttributes (SME_NormalFunction) {}
4074
4086
};
4075
4087
4076
4088
protected:
@@ -4169,7 +4181,8 @@ class FunctionProtoType final
4169
4181
public llvm::FoldingSetNode,
4170
4182
private llvm::TrailingObjects<
4171
4183
FunctionProtoType, QualType, SourceLocation,
4172
- FunctionType::FunctionTypeExtraBitfields, FunctionType::ExceptionType,
4184
+ FunctionType::FunctionTypeExtraBitfields,
4185
+ FunctionType::FunctionTypeArmAttributes, FunctionType::ExceptionType,
4173
4186
Expr *, FunctionDecl *, FunctionType::ExtParameterInfo, Qualifiers> {
4174
4187
friend class ASTContext ; // ASTContext creates these.
4175
4188
friend TrailingObjects;
@@ -4276,7 +4289,11 @@ class FunctionProtoType final
4276
4289
4277
4290
bool requiresFunctionProtoTypeExtraBitfields () const {
4278
4291
return ExceptionSpec.Type == EST_Dynamic ||
4279
- AArch64SMEAttributes != SME_NormalFunction;
4292
+ requiresFunctionProtoTypeArmAttributes ();
4293
+ }
4294
+
4295
+ bool requiresFunctionProtoTypeArmAttributes () const {
4296
+ return AArch64SMEAttributes != SME_NormalFunction;
4280
4297
}
4281
4298
4282
4299
void setArmSMEAttribute (AArch64SMETypeAttributes Kind, bool Enable = true ) {
@@ -4296,6 +4313,10 @@ class FunctionProtoType final
4296
4313
return isVariadic ();
4297
4314
}
4298
4315
4316
+ unsigned numTrailingObjects (OverloadToken<FunctionTypeArmAttributes>) const {
4317
+ return hasArmTypeAttributes ();
4318
+ }
4319
+
4299
4320
unsigned numTrailingObjects (OverloadToken<FunctionTypeExtraBitfields>) const {
4300
4321
return hasExtraBitfields ();
4301
4322
}
@@ -4384,6 +4405,12 @@ class FunctionProtoType final
4384
4405
4385
4406
}
4386
4407
4408
+ bool hasArmTypeAttributes () const {
4409
+ return FunctionTypeBits.HasExtraBitfields &&
4410
+ getTrailingObjects<FunctionTypeExtraBitfields>()
4411
+ ->HasArmTypeAttributes ;
4412
+ }
4413
+
4387
4414
bool hasExtQualifiers () const {
4388
4415
return FunctionTypeBits.HasExtQuals ;
4389
4416
}
@@ -4595,9 +4622,9 @@ class FunctionProtoType final
4595
4622
// / Return a bitmask describing the SME attributes on the function type, see
4596
4623
// / AArch64SMETypeAttributes for their values.
4597
4624
unsigned getAArch64SMEAttributes () const {
4598
- if (!hasExtraBitfields ())
4625
+ if (!hasArmTypeAttributes ())
4599
4626
return SME_NormalFunction;
4600
- return getTrailingObjects<FunctionTypeExtraBitfields >()
4627
+ return getTrailingObjects<FunctionTypeArmAttributes >()
4601
4628
->AArch64SMEAttributes ;
4602
4629
}
4603
4630
0 commit comments