Skip to content

Commit bb160e7

Browse files
committed
[Sema][AArch64] Add parsing support for arm_sve_vector_bits attribute
Summary: This patch implements parsing support for the 'arm_sve_vector_bits' type attribute, defined by the Arm C Language Extensions (ACLE, version 00bet5, section 3.7.3) for SVE [1]. The purpose of this attribute is to define fixed-length (VLST) versions of existing sizeless types (VLAT). For example: #if __ARM_FEATURE_SVE_BITS==512 typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512))); #endif Creates a type 'fixed_svint32_t' that is a fixed-length version of 'svint32_t' that is normal-sized (rather than sizeless) and contains exactly 512 bits. Unlike 'svint32_t', this type can be used in places such as structs and arrays where sizeless types can't. Implemented in this patch is the following: * Defined and tested attribute taking single argument. * Checks the argument is an integer constant expression. * Attribute can only be attached to a single SVE vector or predicate type, excluding tuple types such as svint32x4_t. * Added the `-msve-vector-bits=<bits>` flag. When specified the `__ARM_FEATURE_SVE_BITS__EXPERIMENTAL` macro is defined. * Added a language option to store the vector size specified by the `-msve-vector-bits=<bits>` flag. This is used to validate `N == __ARM_FEATURE_SVE_BITS`, where N is the number of bits passed to the attribute and `__ARM_FEATURE_SVE_BITS` is the feature macro defined under the same flag. The `__ARM_FEATURE_SVE_BITS` macro will be made non-experimental in the final patch of the series. [1] https://developer.arm.com/documentation/100987/latest This is patch 1/4 of a patch series. Reviewers: sdesmalen, rsandifo-arm, efriedma, ctetreau, cameron.mcinally, rengolin, aaron.ballman Reviewed By: sdesmalen, aaron.ballman Differential Revision: https://reviews.llvm.org/D83550
1 parent 62fd7f7 commit bb160e7

17 files changed

+336
-8
lines changed

clang/include/clang/AST/Type.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1925,6 +1925,11 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
19251925
bool isSizelessType() const;
19261926
bool isSizelessBuiltinType() const;
19271927

1928+
/// Determines if this is a sizeless type supported by the
1929+
/// 'arm_sve_vector_bits' type attribute, which can be applied to a single
1930+
/// SVE vector or predicate, excluding tuple types such as svint32x4_t.
1931+
bool isVLSTBuiltinType() const;
1932+
19281933
/// Types are partitioned into 3 broad categories (C99 6.2.5p1):
19291934
/// object types, function types, and incomplete types.
19301935

clang/include/clang/Basic/Attr.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,12 @@ def NeonVectorType : TypeAttr {
15321532
let ASTNode = 0;
15331533
}
15341534

1535+
def ArmSveVectorBits : TypeAttr {
1536+
let Spellings = [GNU<"arm_sve_vector_bits">];
1537+
let Args = [IntArgument<"NumBits">];
1538+
let Documentation = [ArmSveVectorBitsDocs];
1539+
}
1540+
15351541
def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr<TargetARM> {
15361542
let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
15371543
let Documentation = [ArmMveStrictPolymorphismDocs];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4855,6 +4855,43 @@ close the handle. It is also assumed to require an open handle to work with.
48554855
}];
48564856
}
48574857

4858+
def ArmSveVectorBitsDocs : Documentation {
4859+
let Category = DocCatType;
4860+
let Content = [{
4861+
The ``arm_sve_vector_bits(N)`` attribute is defined by the Arm C Language
4862+
Extensions (ACLE) for SVE. It is used to define fixed-length (VLST) variants of
4863+
sizeless types (VLAT).
4864+
4865+
For example:
4866+
4867+
.. code-block:: c
4868+
4869+
#include <arm_sve.h>
4870+
4871+
#if __ARM_FEATURE_SVE_BITS==512
4872+
typedef svint32_t fixed_svint32_t __attribute__((arm_sve_vector_bits(512)));
4873+
#endif
4874+
4875+
Creates a type ``fixed_svint32_t`` that is a fixed-length variant of
4876+
``svint32_t`` that contains exactly 512-bits. Unlike ``svint32_t``, this type
4877+
can be used in globals, structs, unions, and arrays, all of which are
4878+
unsupported for sizeless types.
4879+
4880+
The attribute can be attached to a single SVE vector (such as ``svint32_t``) or
4881+
to the SVE predicate type ``svbool_t``, this excludes tuple types such as
4882+
``svint32x4_t``. The behavior of the attribute is undefined unless
4883+
``N==__ARM_FEATURE_SVE_BITS``, the implementation defined feature macro that is
4884+
enabled under the ``-msve-vector-bits`` flag.
4885+
4886+
NOTE: This feature is currently WIP, the ``-msve-vector-bits=`` flag defines
4887+
the ``__ARM_FEATURE_SVE_BITS_EXPERIMENTAL`` macro. This feature is complete
4888+
when experimental is dropped.
4889+
4890+
For more information See `Arm C Language Extensions for SVE
4891+
<https://developer.arm.com/documentation/100987/latest>`_ for more information.
4892+
}];
4893+
}
4894+
48584895
def ArmMveStrictPolymorphismDocs : Documentation {
48594896
let Category = DocCatType;
48604897
let Content = [{

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,4 +511,7 @@ def warn_drv_libstdcxx_not_found : Warning<
511511
def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with '%0'">;
512512

513513
def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not recognized and is not a valid setting.">;
514+
515+
def err_drv_invalid_sve_vector_bits : Error<
516+
"'-msve-vector-bits' is not supported without SVE enabled">;
514517
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,6 +2810,13 @@ def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">;
28102810
def err_attribute_invalid_matrix_type : Error<"invalid matrix element type %0">;
28112811
def err_attribute_bad_neon_vector_size : Error<
28122812
"Neon vector size must be 64 or 128 bits">;
2813+
def err_attribute_invalid_sve_type : Error<
2814+
"%0 attribute applied to non-SVE type %1">;
2815+
def err_attribute_bad_sve_vector_size : Error<
2816+
"invalid SVE vector size '%0', must match value set by "
2817+
"'-msve-vector-bits' ('%1')">;
2818+
def err_attribute_arm_feature_sve_bits_unsupported : Error<
2819+
"%0 is not supported when '-msve-vector-bits=<bits>' is not specified">;
28132820
def err_attribute_requires_positive_integer : Error<
28142821
"%0 attribute requires a %select{positive|non-negative}1 "
28152822
"integral compile time constant expression">;

clang/include/clang/Basic/LangOptions.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,8 @@ LANGOPT(SpeculativeLoadHardening, 1, 0, "Speculative load hardening enabled")
382382
LANGOPT(RelativeCXXABIVTables, 1, 0,
383383
"Use an ABI-incompatible v-table layout that uses relative references")
384384

385+
LANGOPT(ArmSveVectorBits, 32, 0, "SVE vector size in bits")
386+
385387
#undef LANGOPT
386388
#undef COMPATIBLE_LANGOPT
387389
#undef BENIGN_LANGOPT

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,11 @@ foreach i = {8-15,18} in
23432343
def fcall_saved_x#i : Flag<["-"], "fcall-saved-x"#i>, Group<m_aarch64_Features_Group>,
23442344
HelpText<"Make the x"#i#" register call-saved (AArch64 only)">;
23452345

2346+
def msve_vector_bits_EQ : Joined<["-"], "msve-vector-bits=">,
2347+
Group<m_aarch64_Features_Group>, Flags<[DriverOption,CC1Option]>,
2348+
HelpText<"Set the size of fixed-length SVE vectors in bits.">,
2349+
Values<"128,256,512,1024,2048">;
2350+
23462351
def msign_return_address_EQ : Joined<["-"], "msign-return-address=">,
23472352
Flags<[CC1Option]>, Group<m_Group>, Values<"none,all,non-leaf">,
23482353
HelpText<"Select return address signing scope">;

clang/lib/AST/Type.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,30 @@ bool Type::isSizelessBuiltinType() const {
22942294

22952295
bool Type::isSizelessType() const { return isSizelessBuiltinType(); }
22962296

2297+
bool Type::isVLSTBuiltinType() const {
2298+
if (const BuiltinType *BT = getAs<BuiltinType>()) {
2299+
switch (BT->getKind()) {
2300+
case BuiltinType::SveInt8:
2301+
case BuiltinType::SveInt16:
2302+
case BuiltinType::SveInt32:
2303+
case BuiltinType::SveInt64:
2304+
case BuiltinType::SveUint8:
2305+
case BuiltinType::SveUint16:
2306+
case BuiltinType::SveUint32:
2307+
case BuiltinType::SveUint64:
2308+
case BuiltinType::SveFloat16:
2309+
case BuiltinType::SveFloat32:
2310+
case BuiltinType::SveFloat64:
2311+
case BuiltinType::SveBFloat16:
2312+
case BuiltinType::SveBool:
2313+
return true;
2314+
default:
2315+
return false;
2316+
}
2317+
}
2318+
return false;
2319+
}
2320+
22972321
bool QualType::isPODType(const ASTContext &Context) const {
22982322
// C++11 has a more relaxed definition of POD.
22992323
if (Context.getLangOpts().CPlusPlus11)

clang/lib/AST/TypePrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,9 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
16321632
case attr::ArmMveStrictPolymorphism:
16331633
OS << "__clang_arm_mve_strict_polymorphism";
16341634
break;
1635+
case attr::ArmSveVectorBits:
1636+
OS << "arm_sve_vector_bits";
1637+
break;
16351638
}
16361639
OS << "))";
16371640
}

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
376376
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
377377
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
378378
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
379+
380+
if (Opts.ArmSveVectorBits)
381+
Builder.defineMacro("__ARM_FEATURE_SVE_BITS_EXPERIMENTAL",
382+
Twine(Opts.ArmSveVectorBits));
379383
}
380384

381385
ArrayRef<Builtin::Info> AArch64TargetInfo::getTargetBuiltins() const {

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,12 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
369369
if (V8_6Pos != std::end(Features))
370370
V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
371371

372+
bool HasSve = llvm::is_contained(Features, "+sve");
373+
// -msve_vector_bits=<bits> flag is valid only if SVE is enabled.
374+
if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ))
375+
if (!HasSve)
376+
D.Diag(diag::err_drv_invalid_sve_vector_bits);
377+
372378
if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
373379
options::OPT_munaligned_access))
374380
if (A->getOption().matches(options::OPT_mno_unaligned_access))

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,21 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
17151715
if (IndirectBranches)
17161716
CmdArgs.push_back("-mbranch-target-enforce");
17171717
}
1718+
1719+
// Handle -msve_vector_bits=<bits>
1720+
if (Arg *A = Args.getLastArg(options::OPT_msve_vector_bits_EQ)) {
1721+
StringRef Val = A->getValue();
1722+
const Driver &D = getToolChain().getDriver();
1723+
if (!Val.equals("128") && !Val.equals("256") && !Val.equals("512") &&
1724+
!Val.equals("1024") && !Val.equals("2048")) {
1725+
// Handle the unsupported values passed to msve-vector-bits.
1726+
D.Diag(diag::err_drv_unsupported_option_argument)
1727+
<< A->getOption().getName() << Val;
1728+
} else if (A->getOption().matches(options::OPT_msve_vector_bits_EQ)) {
1729+
CmdArgs.push_back(
1730+
Args.MakeArgString(llvm::Twine("-msve-vector-bits=") + Val));
1731+
}
1732+
}
17181733
}
17191734

17201735
void Clang::AddMIPSTargetArgs(const ArgList &Args,

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2997,6 +2997,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
29972997
Opts.GNUAsm = !Args.hasArg(OPT_fno_gnu_inline_asm);
29982998
Opts.Cmse = Args.hasArg(OPT_mcmse); // Armv8-M Security Extensions
29992999

3000+
Opts.ArmSveVectorBits =
3001+
getLastArgIntValue(Args, options::OPT_msve_vector_bits_EQ, 0, Diags);
3002+
30003003
// __declspec is enabled by default for the PS4 by the driver, and also
30013004
// enabled for Microsoft Extensions or Borland Extensions, here.
30023005
//

clang/lib/Sema/SemaType.cpp

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7686,6 +7686,19 @@ static bool isPermittedNeonBaseType(QualType &Ty,
76867686
BTy->getKind() == BuiltinType::BFloat16;
76877687
}
76887688

7689+
bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
7690+
llvm::APSInt &Result) {
7691+
const auto *AttrExpr = Attr.getArgAsExpr(0);
7692+
if (AttrExpr->isTypeDependent() || AttrExpr->isValueDependent() ||
7693+
!AttrExpr->isIntegerConstantExpr(Result, S.Context)) {
7694+
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
7695+
<< Attr << AANT_ArgumentIntegerConstant << AttrExpr->getSourceRange();
7696+
Attr.setInvalid();
7697+
return false;
7698+
}
7699+
return true;
7700+
}
7701+
76897702
/// HandleNeonVectorTypeAttr - The "neon_vector_type" and
76907703
/// "neon_polyvector_type" attributes are used to create vector types that
76917704
/// are mangled according to ARM's ABI. Otherwise, these types are identical
@@ -7711,16 +7724,10 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
77117724
return;
77127725
}
77137726
// The number of elements must be an ICE.
7714-
Expr *numEltsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
77157727
llvm::APSInt numEltsInt(32);
7716-
if (numEltsExpr->isTypeDependent() || numEltsExpr->isValueDependent() ||
7717-
!numEltsExpr->isIntegerConstantExpr(numEltsInt, S.Context)) {
7718-
S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
7719-
<< Attr << AANT_ArgumentIntegerConstant
7720-
<< numEltsExpr->getSourceRange();
7721-
Attr.setInvalid();
7728+
if (!verifyValidIntegerConstantExpr(S, Attr, numEltsInt))
77227729
return;
7723-
}
7730+
77247731
// Only certain element types are supported for Neon vectors.
77257732
if (!isPermittedNeonBaseType(CurType, VecKind, S)) {
77267733
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_vector_type) << CurType;
@@ -7741,6 +7748,58 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
77417748
CurType = S.Context.getVectorType(CurType, numElts, VecKind);
77427749
}
77437750

7751+
/// HandleArmSveVectorBitsTypeAttr - The "arm_sve_vector_bits" attribute is
7752+
/// used to create fixed-length versions of sizeless SVE types defined by
7753+
/// the ACLE, such as svint32_t and svbool_t.
7754+
static void HandleArmSveVectorBitsTypeAttr(QualType &CurType,
7755+
const ParsedAttr &Attr, Sema &S) {
7756+
// Target must have SVE.
7757+
if (!S.Context.getTargetInfo().hasFeature("sve")) {
7758+
S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
7759+
Attr.setInvalid();
7760+
return;
7761+
}
7762+
7763+
// Attribute is unsupported if '-msve-vector-bits=<bits>' isn't specified.
7764+
if (!S.getLangOpts().ArmSveVectorBits) {
7765+
S.Diag(Attr.getLoc(), diag::err_attribute_arm_feature_sve_bits_unsupported)
7766+
<< Attr;
7767+
Attr.setInvalid();
7768+
return;
7769+
}
7770+
7771+
// Check the attribute arguments.
7772+
if (Attr.getNumArgs() != 1) {
7773+
S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
7774+
<< Attr << 1;
7775+
Attr.setInvalid();
7776+
return;
7777+
}
7778+
7779+
// The vector size must be an integer constant expression.
7780+
llvm::APSInt SveVectorSizeInBits(32);
7781+
if (!verifyValidIntegerConstantExpr(S, Attr, SveVectorSizeInBits))
7782+
return;
7783+
7784+
unsigned VecSize = static_cast<unsigned>(SveVectorSizeInBits.getZExtValue());
7785+
7786+
// The attribute vector size must match -msve-vector-bits.
7787+
if (VecSize != S.getLangOpts().ArmSveVectorBits) {
7788+
S.Diag(Attr.getLoc(), diag::err_attribute_bad_sve_vector_size)
7789+
<< VecSize << S.getLangOpts().ArmSveVectorBits;
7790+
Attr.setInvalid();
7791+
return;
7792+
}
7793+
7794+
// Attribute can only be attached to a single SVE vector or predicate type.
7795+
if (!CurType->isVLSTBuiltinType()) {
7796+
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_sve_type)
7797+
<< Attr << CurType;
7798+
Attr.setInvalid();
7799+
return;
7800+
}
7801+
}
7802+
77447803
static void HandleArmMveStrictPolymorphismAttr(TypeProcessingState &State,
77457804
QualType &CurType,
77467805
ParsedAttr &Attr) {
@@ -8004,6 +8063,10 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
80048063
VectorType::NeonPolyVector);
80058064
attr.setUsedAsTypeAttr();
80068065
break;
8066+
case ParsedAttr::AT_ArmSveVectorBits:
8067+
HandleArmSveVectorBitsTypeAttr(type, attr, state.getSema());
8068+
attr.setUsedAsTypeAttr();
8069+
break;
80078070
case ParsedAttr::AT_ArmMveStrictPolymorphism: {
80088071
HandleArmMveStrictPolymorphismAttr(state, type, attr);
80098072
attr.setUsedAsTypeAttr();
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// -----------------------------------------------------------------------------
2+
// Tests for the -msve-vector-bits flag
3+
// -----------------------------------------------------------------------------
4+
5+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
6+
// RUN: -msve-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-128 %s
7+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
8+
// RUN: -msve-vector-bits=256 2>&1 | FileCheck --check-prefix=CHECK-256 %s
9+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
10+
// RUN: -msve-vector-bits=512 2>&1 | FileCheck --check-prefix=CHECK-512 %s
11+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
12+
// RUN: -msve-vector-bits=1024 2>&1 | FileCheck --check-prefix=CHECK-1024 %s
13+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
14+
// RUN: -msve-vector-bits=2048 2>&1 | FileCheck --check-prefix=CHECK-2048 %s
15+
16+
// CHECK-128: "-msve-vector-bits=128"
17+
// CHECK-256: "-msve-vector-bits=256"
18+
// CHECK-512: "-msve-vector-bits=512"
19+
// CHECK-1024: "-msve-vector-bits=1024"
20+
// CHECK-2048: "-msve-vector-bits=2048"
21+
22+
// Bail out if -msve-vector-bits is specified without SVE enabled
23+
// -----------------------------------------------------------------------------
24+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=128 \
25+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
26+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=256 \
27+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
28+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=512 \
29+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
30+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=1024 \
31+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
32+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -msve-vector-bits=2048 \
33+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-SVE-ERROR %s
34+
35+
// CHECK-NO-SVE-ERROR: error: '-msve-vector-bits' is not supported without SVE enabled
36+
37+
// Error out if an unsupported value is passed to -msve-vector-bits.
38+
// -----------------------------------------------------------------------------
39+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
40+
// RUN: -msve-vector-bits=64 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
41+
// RUN: %clang -c %s -### -target aarch64-none-linux-gnu -march=armv8-a+sve \
42+
// RUN: -msve-vector-bits=A 2>&1 | FileCheck --check-prefix=CHECK-BAD-VALUE-ERROR %s
43+
44+
// CHECK-BAD-VALUE-ERROR: error: unsupported argument '{{.*}}' to option 'msve-vector-bits='
45+
46+
// Error if using attribute without -msve-vector-bits
47+
// -----------------------------------------------------------------------------
48+
// RUN: not %clang -c %s -target aarch64-none-linux-gnu -march=armv8-a+sve \
49+
// RUN: 2>&1 | FileCheck --check-prefix=CHECK-NO-FLAG-ERROR %s
50+
51+
typedef __SVInt32_t svint32_t;
52+
typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));
53+
54+
// CHECK-NO-FLAG-ERROR: error: 'arm_sve_vector_bits' is not supported when '-msve-vector-bits=<bits>' is not specified
55+
56+
// Error if attribute vector size != -msve-vector-bits
57+
// -----------------------------------------------------------------------------
58+
// RUN: not %clang -c %s -target aarch64-none-linux-gnu -march=armv8-a+sve \
59+
// RUN: -msve-vector-bits=128 2>&1 | FileCheck --check-prefix=CHECK-BAD-VECTOR-SIZE-ERROR %s
60+
61+
typedef svint32_t bad_vector_size __attribute__((arm_sve_vector_bits(256)));
62+
63+
// CHECK-BAD-VECTOR-SIZE-ERROR: error: invalid SVE vector size '256', must match value set by '-msve-vector-bits' ('128')

0 commit comments

Comments
 (0)