Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8689f5e

Browse files
committedOct 27, 2021
[AArch64] Add support for the 'R' architecture profile.
This change introduces subtarget features to predicate certain instructions and system registers that are available only on 'A' profile targets. Those features are not present when targeting a generic CPU, which is the default processor. In other words the generic CPU now means the intersection of 'A' and 'R' profiles. To maintain backwards compatibility we enable the features that correspond to -march=armv8-a when the architecture is not explicitly specified on the command line. References: https://developer.arm.com/documentation/ddi0600/latest Differential Revision: https://reviews.llvm.org/D110065
1 parent cb4feae commit 8689f5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+914
-85
lines changed
 

‎clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ static StringRef getArchVersionString(llvm::AArch64::ArchKind Kind) {
5151
}
5252
}
5353

54+
StringRef AArch64TargetInfo::getArchProfile() const {
55+
switch (ArchKind) {
56+
case llvm::AArch64::ArchKind::ARMV8R:
57+
return "R";
58+
default:
59+
return "A";
60+
}
61+
}
62+
5463
AArch64TargetInfo::AArch64TargetInfo(const llvm::Triple &Triple,
5564
const TargetOptions &Opts)
5665
: TargetInfo(Triple), ABI("aapcs") {
@@ -257,7 +266,7 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
257266
// ACLE predefines. Many can only have one possible value on v8 AArch64.
258267
Builder.defineMacro("__ARM_ACLE", "200");
259268
Builder.defineMacro("__ARM_ARCH", getArchVersionString(ArchKind));
260-
Builder.defineMacro("__ARM_ARCH_PROFILE", "'A'");
269+
Builder.defineMacro("__ARM_ARCH_PROFILE", "'" + getArchProfile() + "'");
261270

262271
Builder.defineMacro("__ARM_64BIT_STATE", "1");
263272
Builder.defineMacro("__ARM_PCS_AAPCS64", "1");
@@ -511,7 +520,7 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
511520
HasMatmulFP32 = false;
512521
HasLSE = false;
513522

514-
ArchKind = llvm::AArch64::ArchKind::ARMV8A;
523+
ArchKind = llvm::AArch64::ArchKind::INVALID;
515524

516525
for (const auto &Feature : Features) {
517526
if (Feature == "+neon")
@@ -573,6 +582,8 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
573582
HasSM4 = true;
574583
if (Feature == "+strict-align")
575584
HasUnaligned = false;
585+
if (Feature == "+v8a")
586+
ArchKind = llvm::AArch64::ArchKind::ARMV8A;
576587
if (Feature == "+v8.1a")
577588
ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
578589
if (Feature == "+v8.2a")

‎clang/lib/Basic/Targets/AArch64.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
5959
static const Builtin::Info BuiltinInfo[];
6060

6161
std::string ABI;
62+
StringRef getArchProfile() const;
6263

6364
public:
6465
AArch64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts);

0 commit comments

Comments
 (0)