Skip to content

Commit cd0a990

Browse files
committed
[FMV] Add alias for FEAT_RDM and change priorities according to ACLE.
This patch follows the latest ACLE spec (see PR #279). It adds a name alias for FEAT_RDM and adjusts priorities for FEAT_DOTPROD, FEAT_SM4, FEAT_FP16FML, FEAT_RDM.
1 parent ca8605a commit cd0a990

File tree

5 files changed

+45
-13
lines changed

5 files changed

+45
-13
lines changed

clang/test/CodeGen/attr-target-version.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) fmv_inline(void
3636
inline int __attribute__((target_version("sve2+sve2-pmull128+sve2-bitperm"))) fmv_inline(void) { return 9; }
3737
inline int __attribute__((target_version("sve2-sm4+memtag2"))) fmv_inline(void) { return 10; }
3838
inline int __attribute__((target_version("memtag3+rcpc3+mops"))) fmv_inline(void) { return 11; }
39+
inline int __attribute__((target_version("rdma+sm4"))) fmv_inline(void) { return 12; }
3940
inline int __attribute__((target_version("default"))) fmv_inline(void) { return 3; }
4041

4142
__attribute__((target_version("ls64"))) int fmv_e(void);
@@ -359,6 +360,14 @@ int hoo(void) {
359360
// CHECK: resolver_return21:
360361
// CHECK-NEXT: ret ptr @fmv_inline._Mdpb2Mjscvt
361362
// CHECK: resolver_else22:
363+
// CHECK-NEXT: [[TMP48:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
364+
// CHECK-NEXT: [[TMP49:%.*]] = and i64 [[TMP48]], 96
365+
// CHECK-NEXT: [[TMP50:%.*]] = icmp eq i64 [[TMP49]], 96
366+
// CHECK-NEXT: [[TMP51:%.*]] = and i1 true, [[TMP50]]
367+
// CHECK-NEXT: br i1 [[TMP51]], label [[RESOLVER_RETURN23:%.*]], label [[RESOLVER_ELSE24:%.*]]
368+
// CHECK: resolver_return23:
369+
// CHECK-NEXT: ret ptr @fmv_inline._Msm4Mrdma
370+
// CHECK: resolver_else24:
362371
// CHECK-NEXT: ret ptr @fmv_inline.default
363372
//
364373
//
@@ -616,6 +625,13 @@ int hoo(void) {
616625
//
617626
//
618627
// CHECK: Function Attrs: noinline nounwind optnone
628+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._Msm4Mrdma
629+
// CHECK-SAME: () #[[ATTR24:[0-9]+]] {
630+
// CHECK-NEXT: entry:
631+
// CHECK-NEXT: ret i32 12
632+
//
633+
//
634+
// CHECK: Function Attrs: noinline nounwind optnone
619635
// CHECK-LABEL: define {{[^@]+}}@fmv_inline.default
620636
// CHECK-SAME: () #[[ATTR2]] {
621637
// CHECK-NEXT: entry:
@@ -624,7 +640,7 @@ int hoo(void) {
624640
//
625641
// CHECK: Function Attrs: noinline nounwind optnone
626642
// CHECK-LABEL: define {{[^@]+}}@fmv_d._Msb
627-
// CHECK-SAME: () #[[ATTR24:[0-9]+]] {
643+
// CHECK-SAME: () #[[ATTR25:[0-9]+]] {
628644
// CHECK-NEXT: entry:
629645
// CHECK-NEXT: ret i32 0
630646
//
@@ -769,7 +785,8 @@ int hoo(void) {
769785
// CHECK: attributes #[[ATTR21]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+neon,+sve,+sve2,+sve2-aes,+sve2-bitperm" }
770786
// CHECK: attributes #[[ATTR22]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+mte,+neon,+sve,+sve2,+sve2-sm4" }
771787
// CHECK: attributes #[[ATTR23]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+mops,+mte,+rcpc,+rcpc3" }
772-
// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+sb" }
788+
// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+neon,+rdm,+sm4" }
789+
// CHECK: attributes #[[ATTR25]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+sb" }
773790
//.
774791
// CHECK-NOFMV: attributes #[[ATTR0]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-fmv" }
775792
// CHECK-NOFMV: attributes #[[ATTR1:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-fmv" }

clang/test/Sema/attr-target-clones-aarch64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify %s
22

3-
void __attribute__((target_clones("fp16+sve2-aes", "sb+sve2-sha3+rcpc3+mops"))) no_def(void);
3+
void __attribute__((target_clones("fp16+sve2-aes", "sb+sve2-sha3+rcpc3+mops", "rdma"))) no_def(void);
44

55
// expected-warning@+1 {{unsupported 'default' in the 'target_clones' attribute string; 'target_clones' attribute ignored}}
66
void __attribute__((target_clones("default+sha3"))) warn1(void);

clang/test/SemaCXX/attr-target-version.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ void __attribute__((target_version("dotprod"))) no_def(void);
77
void __attribute__((target_version("rdm+fp"))) no_def(void);
88
void __attribute__((target_version("rcpc3"))) no_def(void);
99
void __attribute__((target_version("mops"))) no_def(void);
10+
void __attribute__((target_version("rdma"))) no_def(void);
1011

1112
// expected-error@+1 {{no matching function for call to 'no_def'}}
1213
void foo(void) { no_def(); }

llvm/include/llvm/TargetParser/AArch64TargetParser.h

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ inline constexpr ExtensionInfo Extensions[] = {
222222
{"d128", AArch64::AEK_D128, "+d128", "-d128", FEAT_INIT, "", 0},
223223
{"dgh", AArch64::AEK_NONE, {}, {}, FEAT_DGH, "", 260},
224224
{"dit", AArch64::AEK_NONE, {}, {}, FEAT_DIT, "+dit", 180},
225-
{"dotprod", AArch64::AEK_DOTPROD, "+dotprod", "-dotprod", FEAT_DOTPROD, "+dotprod,+fp-armv8,+neon", 50},
225+
{"dotprod", AArch64::AEK_DOTPROD, "+dotprod", "-dotprod", FEAT_DOTPROD, "+dotprod,+fp-armv8,+neon", 104},
226226
{"dpb", AArch64::AEK_NONE, {}, {}, FEAT_DPB, "+ccpp", 190},
227227
{"dpb2", AArch64::AEK_NONE, {}, {}, FEAT_DPB2, "+ccpp,+ccdp", 200},
228228
{"ebf16", AArch64::AEK_NONE, {}, {}, FEAT_EBF16, "+bf16", 290},
@@ -233,7 +233,7 @@ inline constexpr ExtensionInfo Extensions[] = {
233233
{"flagm2", AArch64::AEK_NONE, {}, {}, FEAT_FLAGM2, "+flagm,+altnzcv", 30},
234234
{"fp", AArch64::AEK_FP, "+fp-armv8", "-fp-armv8", FEAT_FP, "+fp-armv8,+neon", 90},
235235
{"fp16", AArch64::AEK_FP16, "+fullfp16", "-fullfp16", FEAT_FP16, "+fullfp16,+fp-armv8,+neon", 170},
236-
{"fp16fml", AArch64::AEK_FP16FML, "+fp16fml", "-fp16fml", FEAT_FP16FML, "+fp16fml,+fullfp16,+fp-armv8,+neon", 40},
236+
{"fp16fml", AArch64::AEK_FP16FML, "+fp16fml", "-fp16fml", FEAT_FP16FML, "+fp16fml,+fullfp16,+fp-armv8,+neon", 175},
237237
{"frintts", AArch64::AEK_NONE, {}, {}, FEAT_FRINTTS, "+fptoint", 250},
238238
{"hbc", AArch64::AEK_HBC, "+hbc", "-hbc", FEAT_INIT, "", 0},
239239
{"i8mm", AArch64::AEK_I8MM, "+i8mm", "-i8mm", FEAT_I8MM, "+i8mm", 270},
@@ -259,15 +259,15 @@ inline constexpr ExtensionInfo Extensions[] = {
259259
{"rcpc", AArch64::AEK_RCPC, "+rcpc", "-rcpc", FEAT_RCPC, "+rcpc", 230},
260260
{"rcpc2", AArch64::AEK_NONE, {}, {}, FEAT_RCPC2, "+rcpc", 240},
261261
{"rcpc3", AArch64::AEK_RCPC3, "+rcpc3", "-rcpc3", FEAT_RCPC3, "+rcpc,+rcpc3", 241},
262-
{"rdm", AArch64::AEK_RDM, "+rdm", "-rdm", FEAT_RDM, "+rdm,+fp-armv8,+neon", 70},
262+
{"rdm", AArch64::AEK_RDM, "+rdm", "-rdm", FEAT_RDM, "+rdm,+fp-armv8,+neon", 108},
263263
{"rng", AArch64::AEK_RAND, "+rand", "-rand", FEAT_RNG, "+rand", 10},
264264
{"rpres", AArch64::AEK_NONE, {}, {}, FEAT_RPRES, "", 300},
265265
{"sb", AArch64::AEK_SB, "+sb", "-sb", FEAT_SB, "+sb", 470},
266266
{"sha1", AArch64::AEK_NONE, {}, {}, FEAT_SHA1, "+fp-armv8,+neon", 120},
267267
{"sha2", AArch64::AEK_SHA2, "+sha2", "-sha2", FEAT_SHA2, "+sha2,+fp-armv8,+neon", 130},
268268
{"sha3", AArch64::AEK_SHA3, "+sha3", "-sha3", FEAT_SHA3, "+sha3,+sha2,+fp-armv8,+neon", 140},
269269
{"simd", AArch64::AEK_SIMD, "+neon", "-neon", FEAT_SIMD, "+fp-armv8,+neon", 100},
270-
{"sm4", AArch64::AEK_SM4, "+sm4", "-sm4", FEAT_SM4, "+sm4,+fp-armv8,+neon", 60},
270+
{"sm4", AArch64::AEK_SM4, "+sm4", "-sm4", FEAT_SM4, "+sm4,+fp-armv8,+neon", 106},
271271
{"sme-f16f16", AArch64::AEK_SMEF16F16, "+sme-f16f16", "-sme-f16f16", FEAT_INIT, "", 0},
272272
{"sme-f64f64", AArch64::AEK_SMEF64F64, "+sme-f64f64", "-sme-f64f64", FEAT_SME_F64, "+sme,+sme-f64f64,+bf16", 560},
273273
{"sme-i16i64", AArch64::AEK_SMEI16I64, "+sme-i16i64", "-sme-i16i64", FEAT_SME_I64, "+sme,+sme-i16i64,+bf16", 570},
@@ -807,20 +807,23 @@ inline constexpr CpuInfo CpuInfos[] = {
807807
AArch64::AEK_MTE, AArch64::AEK_SB, AArch64::AEK_SSBS}))},
808808
};
809809

810-
// An alias for a CPU.
811-
struct CpuAlias {
812-
StringRef Alias;
810+
// Name alias
811+
struct Alias {
812+
StringRef AltName;
813813
StringRef Name;
814814
};
815815

816-
inline constexpr CpuAlias CpuAliases[] = {{"grace", "neoverse-v2"}};
816+
inline constexpr Alias CpuAliases[] = {{"grace", "neoverse-v2"}};
817+
818+
inline constexpr Alias ExtAliases[] = {{"rdma", "rdm"}};
817819

818820
bool getExtensionFeatures(
819821
const AArch64::ExtensionBitset &Extensions,
820822
std::vector<StringRef> &Features);
821823

822824
StringRef getArchExtFeature(StringRef ArchExt);
823825
StringRef resolveCPUAlias(StringRef CPU);
826+
StringRef resolveExtAlias(StringRef ArchExt);
824827

825828
// Information by Name
826829
const ArchInfo *getArchForCpu(StringRef CPU);

llvm/lib/TargetParser/AArch64TargetParser.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ bool AArch64::getExtensionFeatures(
6969

7070
StringRef AArch64::resolveCPUAlias(StringRef Name) {
7171
for (const auto &A : CpuAliases)
72-
if (A.Alias == Name)
72+
if (A.AltName == Name)
73+
return A.Name;
74+
return Name;
75+
}
76+
77+
StringRef AArch64::resolveExtAlias(StringRef Name) {
78+
for (const auto &A : ExtAliases)
79+
if (A.AltName == Name)
7380
return A.Name;
7481
return Name;
7582
}
@@ -91,7 +98,7 @@ void AArch64::fillValidCPUArchList(SmallVectorImpl<StringRef> &Values) {
9198
Values.push_back(C.Name);
9299

93100
for (const auto &Alias : CpuAliases)
94-
Values.push_back(Alias.Alias);
101+
Values.push_back(Alias.AltName);
95102
}
96103

97104
bool AArch64::isX18ReservedByDefault(const Triple &TT) {
@@ -114,6 +121,10 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) {
114121
}
115122

116123
std::optional<AArch64::ExtensionInfo> AArch64::parseArchExtension(StringRef ArchExt) {
124+
// Resolve aliases first.
125+
ArchExt = resolveExtAlias(ArchExt);
126+
127+
// Then find the Extension name.
117128
for (const auto &A : Extensions) {
118129
if (ArchExt == A.Name)
119130
return A;

0 commit comments

Comments
 (0)