Skip to content

Commit 50e4cbc

Browse files
committed
[aarch64][clang][llvm] Allow AArch64 TLB maintenance instructions to be enabled via -march
1 parent 816c975 commit 50e4cbc

File tree

4 files changed

+27
-5
lines changed

4 files changed

+27
-5
lines changed

clang/lib/Basic/Targets/AArch64.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,12 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts,
635635
if (HasGCS)
636636
Builder.defineMacro("__ARM_FEATURE_GCS", "1");
637637

638+
if (HasXS)
639+
Builder.defineMacro("__ARM_FEATURE_XS", "1");
640+
641+
if (HasTLBRmi)
642+
Builder.defineMacro("__ARM_FEATURE_TLB_RMI", "1");
643+
638644
if (*ArchInfo == llvm::AArch64::ARMV8_1A)
639645
getTargetDefinesARMV81A(Opts, Builder);
640646
else if (*ArchInfo == llvm::AArch64::ARMV8_2A)
@@ -790,6 +796,8 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) const {
790796
.Cases("ls64", "ls64_v", "ls64_accdata", HasLS64)
791797
.Case("wfxt", HasWFxT)
792798
.Case("rcpc3", HasRCPC3)
799+
.Case("xs", HasXS)
800+
.Case("tlb-rmi", HasTLBRmi)
793801
.Default(false);
794802
}
795803

@@ -1102,6 +1110,10 @@ bool AArch64TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
11021110
HasPAuthLR = true;
11031111
HasPAuth = true;
11041112
}
1113+
if (Feature == "+xs")
1114+
HasXS = true;
1115+
if (Feature == "+tlb-rmi")
1116+
HasTLBRmi = true;
11051117
}
11061118

11071119
// Check features that are manually disabled by command line options.

clang/lib/Basic/Targets/AArch64.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo {
118118
bool HasRCPC3 = false;
119119
bool HasSMEFA64 = false;
120120
bool HasPAuthLR = false;
121+
bool HasXS = false;
122+
bool HasTLBRmi = false;
121123

122124
const llvm::AArch64::ArchInfo *ArchInfo = &llvm::AArch64::ARMV8A;
123125

clang/test/Preprocessor/aarch64-target-features.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,3 +738,11 @@
738738
// CHECK-SMEB16B16: __ARM_FEATURE_SME2 1
739739
// CHECK-SMEB16B16: __ARM_FEATURE_SME_B16B16 1
740740
// CHECK-SMEB16B16: __ARM_FEATURE_SVE_B16B16 1
741+
742+
// ================== Check Armv8.7-A limited-TLB-maintenance instruction.
743+
// RUN: %clang -target aarch64 -march=armv8a+xs -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-XS %s
744+
// CHECK-XS: __ARM_FEATURE_XS 1
745+
746+
// ================== Check Armv8.4-A TLB Range and Maintenance instructions.
747+
// RUN: %clang -target aarch64 -march=armv8a+tlb-rmi -x c -E -dM %s -o - | FileCheck -check-prefix=CHECK-TLB-RMI %s
748+
// CHECK-TLB-RMI: __ARM_FEATURE_TLB_RMI 1

llvm/lib/Target/AArch64/AArch64Features.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def FeatureAM : Extension<"am", "AM", "FEAT_AMUv1",
227227
def FeatureSEL2 : Extension<"sel2", "SEL2", "FEAT_SEL2",
228228
"Enable Armv8.4-A Secure Exception Level 2 extension">;
229229

230-
def FeatureTLB_RMI : Extension<"tlb-rmi", "TLB_RMI",
230+
def FeatureTLB_RMI : ExtensionWithMArch<"tlb-rmi", "TLB_RMI",
231231
"FEAT_TLBIOS, FEAT_TLBIRANGE",
232232
"Enable Armv8.4-A TLB Range and Maintenance instructions">;
233233

@@ -296,7 +296,7 @@ def FeatureEnhancedCounterVirtualization :
296296
// Armv8.7 Architecture Extensions
297297
//===----------------------------------------------------------------------===//
298298

299-
def FeatureXS : Extension<"xs", "XS", "FEAT_XS",
299+
def FeatureXS : ExtensionWithMArch<"xs", "XS", "FEAT_XS",
300300
"Enable Armv8.7-A limited-TLB-maintenance instruction">;
301301

302302
def FeatureWFxT : ExtensionWithMArch<"wfxt", "WFxT", "FEAT_WFxT",
@@ -836,7 +836,7 @@ def HasV8_4aOps : Architecture64<8, 4, "a", "v8.4a",
836836
[HasV8_3aOps, FeatureDotProd, FeatureNV, FeatureMPAM, FeatureDIT,
837837
FeatureTRACEV8_4, FeatureAM, FeatureSEL2, FeatureTLB_RMI, FeatureFlagM,
838838
FeatureRCPC_IMMO, FeatureLSE2],
839-
!listconcat(HasV8_3aOps.DefaultExts, [FeatureDotProd, FeatureDIT, FeatureFlagM])>;
839+
!listconcat(HasV8_3aOps.DefaultExts, [FeatureDotProd, FeatureDIT, FeatureTLB_RMI, FeatureFlagM])>;
840840
def HasV8_5aOps : Architecture64<8, 5, "a", "v8.5a",
841841
[HasV8_4aOps, FeatureAltFPCmp, FeatureFRInt3264, FeatureSpecRestrict,
842842
FeatureSB, FeaturePredRes, FeatureCacheDeepPersist,
@@ -848,7 +848,7 @@ def HasV8_6aOps : Architecture64<8, 6, "a", "v8.6a",
848848
!listconcat(HasV8_5aOps.DefaultExts, [FeatureBF16, FeatureMatMulInt8])>;
849849
def HasV8_7aOps : Architecture64<8, 7, "a", "v8.7a",
850850
[HasV8_6aOps, FeatureXS, FeatureWFxT, FeatureHCX, FeatureSPE_EEF],
851-
!listconcat(HasV8_6aOps.DefaultExts, [FeatureWFxT])>;
851+
!listconcat(HasV8_6aOps.DefaultExts, [FeatureXS, FeatureWFxT])>;
852852
def HasV8_8aOps : Architecture64<8, 8, "a", "v8.8a",
853853
[HasV8_7aOps, FeatureHBC, FeatureMOPS, FeatureNMI],
854854
!listconcat(HasV8_7aOps.DefaultExts, [FeatureMOPS, FeatureHBC])>;
@@ -866,7 +866,7 @@ def HasV9_1aOps : Architecture64<9, 1, "a", "v9.1a",
866866
!listconcat(HasV9_0aOps.DefaultExts, [FeatureBF16, FeatureMatMulInt8, FeatureRME])>;
867867
def HasV9_2aOps : Architecture64<9, 2, "a", "v9.2a",
868868
[HasV8_7aOps, HasV9_1aOps],
869-
!listconcat(HasV9_1aOps.DefaultExts, [FeatureMEC, FeatureWFxT])>;
869+
!listconcat(HasV9_1aOps.DefaultExts, [FeatureMEC, FeatureXS, FeatureWFxT])>;
870870
def HasV9_3aOps : Architecture64<9, 3, "a", "v9.3a",
871871
[HasV8_8aOps, HasV9_2aOps],
872872
!listconcat(HasV9_2aOps.DefaultExts, [FeatureMOPS, FeatureHBC])>;

0 commit comments

Comments
 (0)