Skip to content

[FMV][AArch64] Allow user to override version priority (option2). #147073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -4911,7 +4911,8 @@ class Sema final : public SemaBase {
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);

/// Check Target Version attrs
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str,
SmallString<64> &);
bool checkTargetClonesAttrString(
SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
Expand Down
5 changes: 4 additions & 1 deletion clang/lib/CodeGen/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,10 +1336,13 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef AttrStr,
});

llvm::SmallDenseSet<StringRef, 8> UniqueFeats;
for (auto &Feat : Features)
for (auto &Feat : Features) {
if (!getTarget().doesFeatureAffectCodeGen(Feat))
continue;
if (auto Ext = llvm::AArch64::parseFMVExtension(Feat))
if (UniqueFeats.insert(Ext->Name).second)
Out << 'M' << Ext->Name;
}
}

std::unique_ptr<TargetCodeGenInfo>
Expand Down
34 changes: 30 additions & 4 deletions clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3279,7 +3279,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) {
}

bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
StringRef AttrStr) {
StringRef AttrStr, SmallString<64> &NewStr) {
enum FirstParam { Unsupported };
enum SecondParam { None };
enum ThirdParam { Target, TargetClones, TargetVersion };
Expand Down Expand Up @@ -3330,11 +3330,19 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,
return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Unsupported << None << AttrStr << TargetVersion;

NewStr = AttrStr;
return false;
}
AttrStr.split(Features, "+");

auto [LHS, RHS] = AttrStr.split(';');
LHS.split(Features, '+');
if (!RHS.empty())
RHS.split(Features, '+');
for (auto &CurFeature : Features) {
CurFeature = CurFeature.trim();
if (!NewStr.empty())
NewStr.append("+");
NewStr.append(CurFeature);
if (CurFeature == "default")
continue;
if (!Context.getTargetInfo().validateCpuSupports(CurFeature))
Expand All @@ -3346,12 +3354,13 @@ bool Sema::checkTargetVersionAttr(SourceLocation LiteralLoc, Decl *D,

static void handleTargetVersionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
StringRef Str;
SmallString<64> NewStr;
SourceLocation LiteralLoc;
if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) ||
S.checkTargetVersionAttr(LiteralLoc, D, Str))
S.checkTargetVersionAttr(LiteralLoc, D, Str, NewStr))
return;
TargetVersionAttr *NewAttr =
::new (S.Context) TargetVersionAttr(S.Context, AL, Str);
::new (S.Context) TargetVersionAttr(S.Context, AL, NewStr);
D->addAttr(NewAttr);
}

Expand Down Expand Up @@ -3404,6 +3413,19 @@ bool Sema::checkTargetClonesAttrString(
else
StringsBuffer.push_back(Cur);
} else {
auto [LHS, RHS] = Cur.split(';');
StringRef Priority;
if (LHS.starts_with("priority")) {
Priority = LHS;
Cur = !RHS.empty() ? RHS : LHS;
} else if (RHS.starts_with("priority")) {
Priority = RHS;
Cur = LHS;
}
if (!Priority.empty() && !TInfo.validateCpuSupports(Priority))
Diag(CurLoc, diag::warn_unsupported_target_attribute)
<< Unsupported << None << Priority << TargetClones;

std::pair<StringRef, StringRef> CurParts = {{}, Cur};
llvm::SmallVector<StringRef, 8> CurFeatures;
while (!CurParts.second.empty()) {
Expand All @@ -3426,6 +3448,10 @@ bool Sema::checkTargetClonesAttrString(
Res.append("+");
Res.append(CurFeat);
}
if (!Res.empty() && !Priority.empty()) {
Res.append("+");
Res.append(Priority);
}
if (llvm::is_contained(StringsBuffer, Res) || DefaultIsDupe)
Diag(CurLoc, diag::warn_target_clone_duplicate_options);
else if (!HasCodeGenImpact)
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/attr-target-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
int __attribute__((target_version("sve2-bitperm + sha2"))) foov(void) { return 1; }
int __attribute__((target_clones(" lse + fp + sha3 ", "default"))) fooc(void) { return 2; }
// CHECK: TargetVersionAttr
// CHECK: sve2-bitperm + sha2
// CHECK: sve2-bitperm+sha2
// CHECK: TargetClonesAttr
// CHECK: fp+lse+sha3 default
16 changes: 16 additions & 0 deletions clang/test/CodeGen/AArch64/fmv-duplicate-mangled-name.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s -DCHECK_IMPLICIT_DEFAULT
// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s -DCHECK_EXPLICIT_DEFAULT
// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s -DCHECK_EXPLICIT_VERSION_PRIORITY
// RUN: %clang_cc1 -triple aarch64-linux-gnu -verify -emit-llvm-only %s -DCHECK_EXPLICIT_CLONES_PRIORITY

#if defined(CHECK_IMPLICIT_DEFAULT)

Expand All @@ -21,4 +23,18 @@ __attribute__((target_version("default"))) int explicit_default_bad(void) { retu
// expected-note@-2 {{previous definition is here}}
__attribute__((target_clones("aes", "lse", "default"))) int explicit_default_bad(void) { return 1; }

#elif defined(CHECK_EXPLICIT_VERSION_PRIORITY)

__attribute__((target_version("aes"))) int explicit_version_priority(void) { return 0; }
// expected-error@+2 {{definition with same mangled name 'explicit_version_priority._Maes' as another definition}}
// expected-note@-2 {{previous definition is here}}
__attribute__((target_version("priority1;aes"))) int explicit_version_priority(void) { return 1; }

#elif defined(CHECK_EXPLICIT_CLONES_PRIORITY)

__attribute__((target_version("aes;priority2"))) int explicit_clones_priority(void) { return 0; }
// expected-error@+2 {{definition with same mangled name 'explicit_clones_priority._Maes' as another definition}}
// expected-note@-2 {{previous definition is here}}
__attribute__((target_clones("priority1;aes", "lse"))) int explicit_clones_priority(void) { return 1; }

#endif
193 changes: 193 additions & 0 deletions clang/test/CodeGen/AArch64/fmv-explicit-priority.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals --include-generated-funcs
// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -O3 -fno-inline -emit-llvm -o - %s | FileCheck %s

__attribute__((target_version("priority1;lse"))) int foo(void) { return 1; }
__attribute__((target_version("priority2;sve2"))) int foo(void) { return 2; }
__attribute__((target_version("priority3;sve"))) int foo(void) { return 3; }
__attribute__((target_version( "default"))) int foo(void) { return 0; }

__attribute__((target_clones("priority1;lse+sve2", "priority2;lse", "priority3;sve", "default")))
int fmv_caller(void) { return foo(); }


__attribute__((target_version("aes"))) int bar(void) { return 1; }
__attribute__((target_version("priority1;sm4"))) int bar(void) { return 2; }
__attribute__((target_version("default"))) int bar(void) { return 0; }

__attribute__((target("aes"))) int regular_caller_aes() { return bar(); }
__attribute__((target("sm4"))) int regular_caller_sm4() { return bar(); }
//.
// CHECK: @__aarch64_cpu_features = external dso_local local_unnamed_addr global { i64 }
// CHECK: @foo = weak_odr ifunc i32 (), ptr @foo.resolver
// CHECK: @fmv_caller = weak_odr ifunc i32 (), ptr @fmv_caller.resolver
// CHECK: @bar = weak_odr ifunc i32 (), ptr @bar.resolver
//.
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@foo._Mlse
// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@foo._Msve2
// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 2
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@foo._Msve
// CHECK-SAME: () #[[ATTR2:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 3
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@foo.default
// CHECK-SAME: () #[[ATTR3:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 0
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@fmv_caller._MlseMsve2
// CHECK-SAME: () #[[ATTR4:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @foo._Mlse()
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@fmv_caller._Mlse
// CHECK-SAME: () #[[ATTR5:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @foo._Mlse()
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK: Function Attrs: noinline nounwind vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@fmv_caller._Msve
// CHECK-SAME: () #[[ATTR6:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @foo() #[[ATTR12:[0-9]+]]
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16)
// CHECK-LABEL: define {{[^@]+}}@fmv_caller.default
// CHECK-SAME: () #[[ATTR7:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @foo.default()
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@bar._Maes
// CHECK-SAME: () #[[ATTR8:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 1
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@bar._Msm4
// CHECK-SAME: () #[[ATTR9:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 2
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@bar.default
// CHECK-SAME: () #[[ATTR3]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: ret i32 0
//
//
// CHECK: Function Attrs: noinline nounwind
// CHECK-LABEL: define {{[^@]+}}@regular_caller_aes
// CHECK-SAME: () local_unnamed_addr #[[ATTR10:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @bar() #[[ATTR12]]
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK: Function Attrs: mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none)
// CHECK-LABEL: define {{[^@]+}}@regular_caller_sm4
// CHECK-SAME: () local_unnamed_addr #[[ATTR11:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[CALL:%.*]] = tail call i32 @bar._Msm4()
// CHECK-NEXT: ret i32 [[CALL]]
//
//
// CHECK-LABEL: define {{[^@]+}}@foo.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: tail call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 128
// CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i64 [[TMP1]], 0
// CHECK-NEXT: br i1 [[DOTNOT]], label [[RESOLVER_ELSE:%.*]], label [[COMMON_RET:%.*]]
// CHECK: common.ret:
// CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ @foo._Mlse, [[RESOLVER_ENTRY:%.*]] ], [ @foo._Msve2, [[RESOLVER_ELSE]] ], [ [[FOO__MSVE_FOO_DEFAULT:%.*]], [[RESOLVER_ELSE2:%.*]] ]
// CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
// CHECK: resolver_else:
// CHECK-NEXT: [[TMP2:%.*]] = and i64 [[TMP0]], 69793284352
// CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[TMP2]], 69793284352
// CHECK-NEXT: br i1 [[TMP3]], label [[COMMON_RET]], label [[RESOLVER_ELSE2]]
// CHECK: resolver_else2:
// CHECK-NEXT: [[TMP4:%.*]] = and i64 [[TMP0]], 1073807616
// CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[TMP4]], 1073807616
// CHECK-NEXT: [[FOO__MSVE_FOO_DEFAULT]] = select i1 [[TMP5]], ptr @foo._Msve, ptr @foo.default
// CHECK-NEXT: br label [[COMMON_RET]]
//
//
// CHECK-LABEL: define {{[^@]+}}@fmv_caller.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: tail call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 69793284480
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 69793284480
// CHECK-NEXT: br i1 [[TMP2]], label [[COMMON_RET:%.*]], label [[RESOLVER_ELSE:%.*]]
// CHECK: common.ret:
// CHECK-NEXT: [[COMMON_RET_OP:%.*]] = phi ptr [ @fmv_caller._MlseMsve2, [[RESOLVER_ENTRY:%.*]] ], [ @fmv_caller._Mlse, [[RESOLVER_ELSE]] ], [ [[FMV_CALLER__MSVE_FMV_CALLER_DEFAULT:%.*]], [[RESOLVER_ELSE2:%.*]] ]
// CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
// CHECK: resolver_else:
// CHECK-NEXT: [[TMP3:%.*]] = and i64 [[TMP0]], 128
// CHECK-NEXT: [[DOTNOT:%.*]] = icmp eq i64 [[TMP3]], 0
// CHECK-NEXT: br i1 [[DOTNOT]], label [[RESOLVER_ELSE2]], label [[COMMON_RET]]
// CHECK: resolver_else2:
// CHECK-NEXT: [[TMP4:%.*]] = and i64 [[TMP0]], 1073807616
// CHECK-NEXT: [[TMP5:%.*]] = icmp eq i64 [[TMP4]], 1073807616
// CHECK-NEXT: [[FMV_CALLER__MSVE_FMV_CALLER_DEFAULT]] = select i1 [[TMP5]], ptr @fmv_caller._Msve, ptr @fmv_caller.default
// CHECK-NEXT: br label [[COMMON_RET]]
//
//
// CHECK-LABEL: define {{[^@]+}}@bar.resolver() comdat {
// CHECK-NEXT: resolver_entry:
// CHECK-NEXT: tail call void @__init_cpu_features_resolver()
// CHECK-NEXT: [[TMP0:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
// CHECK-NEXT: [[TMP1:%.*]] = and i64 [[TMP0]], 800
// CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 800
// CHECK-NEXT: [[TMP3:%.*]] = and i64 [[TMP0]], 33536
// CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[TMP3]], 33536
// CHECK-NEXT: [[BAR__MAES_BAR_DEFAULT:%.*]] = select i1 [[TMP4]], ptr @bar._Maes, ptr @bar.default
// CHECK-NEXT: [[COMMON_RET_OP:%.*]] = select i1 [[TMP2]], ptr @bar._Msm4, ptr [[BAR__MAES_BAR_DEFAULT]]
// CHECK-NEXT: ret ptr [[COMMON_RET_OP]]
//
//.
// CHECK: attributes #[[ATTR0]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "fmv-features"="lse,priority1" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" }
// CHECK: attributes #[[ATTR1]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16) "fmv-features"="priority2,sve2" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+sve,+sve2" }
// CHECK: attributes #[[ATTR2]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16) "fmv-features"="priority3,sve" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+sve" }
// CHECK: attributes #[[ATTR3]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "fmv-features" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
// CHECK: attributes #[[ATTR4]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16) "fmv-features"="lse,priority1,sve2" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+lse,+sve,+sve2" }
// CHECK: attributes #[[ATTR5]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16) "fmv-features"="lse,priority2" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse" }
// CHECK: attributes #[[ATTR6]] = { noinline nounwind vscale_range(1,16) "fmv-features"="priority3,sve" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+sve" }
// CHECK: attributes #[[ATTR7]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) vscale_range(1,16) "fmv-features" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
// CHECK: attributes #[[ATTR8]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "fmv-features"="aes" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+aes,+fp-armv8,+neon" }
// CHECK: attributes #[[ATTR9]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "fmv-features"="priority1,sm4" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+sm4" }
// CHECK: attributes #[[ATTR10]] = { noinline nounwind "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+aes,+fp-armv8,+neon" }
// CHECK: attributes #[[ATTR11]] = { mustprogress nofree noinline norecurse nosync nounwind willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+sm4" }
// CHECK: attributes #[[ATTR12]] = { nounwind }
//.
// CHECK: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
// CHECK: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
//.
6 changes: 5 additions & 1 deletion llvm/include/llvm/Analysis/TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1916,9 +1916,13 @@ class TargetTransformInfo {
LLVM_ABI bool hasArmWideBranch(bool Thumb) const;

/// Returns a bitmask constructed from the target-features or fmv-features
/// metadata of a function.
/// metadata of a function corresponding to its Arch Extensions.
LLVM_ABI uint64_t getFeatureMask(const Function &F) const;

/// Returns a bitmask constructed from the target-features or fmv-features
/// metadata of a function corresponding to its FMV priority.
LLVM_ABI uint64_t getPriorityMask(const Function &F) const;

/// Returns true if this is an instance of a function with multiple versions.
LLVM_ABI bool isMultiversionedFunction(const Function &F) const;

Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,7 @@ class TargetTransformInfoImplBase {
virtual bool hasArmWideBranch(bool) const { return false; }

virtual uint64_t getFeatureMask(const Function &F) const { return 0; }
virtual uint64_t getPriorityMask(const Function &F) const { return 0; }

virtual bool isMultiversionedFunction(const Function &F) const {
return false;
Expand Down
7 changes: 6 additions & 1 deletion llvm/include/llvm/TargetParser/AArch64FeatPriorities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ enum FeatPriorities {
PRIOR_SME_I64,
PRIOR_SME2,
PRIOR_MOPS,
PRIOR_CSSC
PRIOR_CSSC,
PRIOR_5,
PRIOR_4,
PRIOR_3,
PRIOR_2,
PRIOR_1
};

#endif
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,10 @@ uint64_t TargetTransformInfo::getFeatureMask(const Function &F) const {
return TTIImpl->getFeatureMask(F);
}

uint64_t TargetTransformInfo::getPriorityMask(const Function &F) const {
return TTIImpl->getPriorityMask(F);
}

bool TargetTransformInfo::isMultiversionedFunction(const Function &F) const {
return TTIImpl->isMultiversionedFunction(F);
}
Expand Down
5 changes: 5 additions & 0 deletions llvm/lib/Target/AArch64/AArch64FMV.td
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,8 @@ def : FMVExtension<"sve2-sha3", "SVE_SHA3">;
def : FMVExtension<"sve2-sm4", "SVE_SM4">;
def : FMVExtension<"wfxt", "WFXT">;
def : FMVExtension<"cssc", "CSSC">;
let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority1", "1">;
let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority2", "2">;
let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority3", "3">;
let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority4", "4">;
let FeatureBit = "FEAT_MAX" in def : FMVExtension<"priority5", "5">;
Loading
Loading