[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -11,7 +11,7 @@ int __attribute__((target_version("fp+aes"))) fmv(void) { return 6; } int __attribute__((target_version("crc+ls64_v"))) fmv(void) { return 7; } int __attribute__((target_version("bti"))) fmv(void) { return 8; } int __attribute__((target_version("sme2"))) fmv(void) { return 9; } -int __attribute__((target_version("default"))) fmv(void); +int __attribute__((target_version("default"))) fmv(void) { return 0; } tmatheson-arm wrote: I think `fmv_one` and `fmv_too` should be defined too, to keep the original behaviour of this test unchanged, and then add a new, separate test for checking the various behaviours of `default` https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -59,15 +59,22 @@ int bar() { return m.goo(1) + foo(1) + foo(); } +// Example to demonstrate that at the point of use we haven't yet seen the default. +// At that point a declaration for the unmangled symbol is emitted, which is later +// replaced by the ifunc symbol (once we have seen the default definition). +__attribute__((target_version("aes"))) void fmv(void) {} +void caller(void) { fmv(); } +__attribute__((target_version("default"))) void fmv(void) {} tmatheson-arm wrote: I think we want to test the observable behaviour, not whatever is happening internally. The test doesn't actually check the internals anyway, besides that it doesn't crash. i.e. I would expect the comment to be something like: > Test that an ifunc is generated and used when `default` is defined after the > first use of the function If we want to check the other case you mentioned, and `update_cc_test_checks.py` can't generate a test for it automatically, it should still be tested but it will have to be manually written. https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -4224,10 +4204,8 @@ void CodeGenModule::emitMultiVersionFunctions() { llvm::Function *Func = createFunction(CurFD); Options.emplace_back(Func, TA->getArchitecture(), Feats); } else if (const auto *TVA = CurFD->getAttr()) { -bool HasDefaultDef = TVA->isDefaultVersion() && - CurFD->doesThisDeclarationHaveABody(); -HasDefaultDecl |= TVA->isDefaultVersion(); -ShouldEmitResolver |= (CurFD->isUsed() || HasDefaultDef); +ShouldEmitResolver |= (TVA->isDefaultVersion() && + CurFD->doesThisDeclarationHaveABody()); tmatheson-arm wrote: ```suggestion if (TVA->isDefaultVersion() && CurFD->doesThisDeclarationHaveABody()) ShouldEmitResolver = true; ``` https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -59,15 +59,22 @@ int bar() { return m.goo(1) + foo(1) + foo(); } +// Example to demonstrate that at the point of use we haven't yet seen the default. +// At that point a declaration for the unmangled symbol is emitted, which is later +// replaced by the ifunc symbol (once we have seen the default definition). +__attribute__((target_version("aes"))) void fmv(void) {} +void caller(void) { fmv(); } +__attribute__((target_version("default"))) void fmv(void) {} tmatheson-arm wrote: How does it demonstrate this? The unmangled symbol doesn't appear in the output, as far as I can see. https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -4210,9 +4192,7 @@ void CodeGenModule::emitMultiVersionFunctions() { return cast(Func); }; -bool HasDefaultDecl = !FD->isTargetVersionMultiVersion(); -bool ShouldEmitResolver = -!getContext().getTargetInfo().getTriple().isAArch64(); +bool ShouldEmitResolver = !getTarget().getTriple().isAArch64(); tmatheson-arm wrote: ```suggestion // For AArch64, a resolver is only emitted if a function marked target(default)) // is present and defined in this TU. For other architectures it is always emitted. bool ShouldEmitResolver = !getTarget().getTriple().isAArch64(); ``` https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
https://github.com/tmatheson-arm commented: It's really hard to tell what is changing here because the existing tests are so non-specific. https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [FMV][AArch64] Do not emit ifunc resolver on use. (PR #97761)
@@ -261,9 +261,9 @@ __attribute__((target_version("jscvt"))) int default_def_with_version_decls(void // CHECK: attributes #[[ATTR3]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" } // CHECK: attributes #[[ATTR4]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+neon,+rdm,-v9.5a" } // CHECK: attributes #[[ATTR5:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+dotprod,+fp-armv8,+neon,-v9.5a" } -// CHECK: attributes #[[ATTR6:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" } -// CHECK: attributes #[[ATTR7:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-v9.5a" } -// CHECK: attributes #[[ATTR8:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" } +// CHECK: attributes #[[ATTR6:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-v9.5a" } +// CHECK: attributes #[[ATTR7:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+lse,-v9.5a" } +// CHECK: attributes #[[ATTR8:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+jsconv,+neon,-v9.5a" } tmatheson-arm wrote: These attributes are not actually matched against anything, is there any point testing them? https://github.com/llvm/llvm-project/pull/97761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][RISCV] Improve the tests for --print-enabled-extensions and --print-supported-extensions (PR #97829)
@@ -0,0 +1,24 @@ +// REQUIRES: aarch64-registered-target tmatheson-arm wrote: I've kept them as-is so that they still correspond to the [generating script](https://gist.github.com/tmatheson-arm/333dd14cc1c95ab4ac563ed615add95d). https://github.com/llvm/llvm-project/pull/97829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][RISCV] Improve the tests for --print-enabled-extensions and --print-supported-extensions (PR #97829)
https://github.com/tmatheson-arm closed https://github.com/llvm/llvm-project/pull/97829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][RISCV] Improve the tests for --print-enabled-extensions and --print-supported-extensions (PR #97829)
tmatheson-arm wrote: > Mind sticking it in a gist at least so folks can use it for downstream > subtargets? [Here you go](https://gist.github.com/tmatheson-arm/333dd14cc1c95ab4ac563ed615add95d) https://github.com/llvm/llvm-project/pull/97829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [PAC][ELF][AArch64] Encode signed GOT flag in PAuth core info (PR #96159)
https://github.com/tmatheson-arm approved this pull request. LGTM, just based on what I can see from implementation of the existing bits in the version field. https://github.com/llvm/llvm-project/pull/96159 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][RISCV] Improve the tests for --print-enabled-extensions and --print-supported-extensions (PR #97829)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97829 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -22,13 +22,13 @@ using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - if (std::optional> features = + if (const std::optional> features = sys::getHostCPUFeatures(features)) { -if ((*features)["sse"]) +if (features->contains("sse")) tmatheson-arm wrote: `contains` will only check if the key exists in the map, but you want to actually get the `bool` if it exists and default to `false` if it doesn't. I think `lookup` fits better. https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
@@ -15,22 +15,23 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" +#include + using namespace llvm; int main(int argc, char **argv) { #if defined(__i386__) || defined(_M_IX86) || \ defined(__x86_64__) || defined(_M_X64) - StringMap features; - - if (!sys::getHostCPUFeatures(features)) + if (std::optional> features = + sys::getHostCPUFeatures(features)) { +if ((*features)["sse"]) tmatheson-arm wrote: Maybe ```suggestion if (features->lookup("sse")) ``` which does the same, but doesn't insert the default entry into the map. https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [lldb] [llvm] [llvm][TargetParser] Return optional from getHostCPUFeatures (PR #97824)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97824 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/97749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)
@@ -445,4 +445,21 @@ void aarch64::getAArch64TargetFeatures(const Driver , if (Args.getLastArg(options::OPT_mno_bti_at_return_twice)) Features.push_back("+no-bti-at-return-twice"); + + // Parse AArch64 CPU Features + const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ); + StringRef CPUName; + + if (CPUArg) { +CPUName = CPUArg->getValue(); +if (CPUName == "native") { + llvm::StringMap HostFeatures; + if (llvm::sys::getHostCPUFeatures(HostFeatures)) { +for (auto : HostFeatures) { + Features.push_back( +Args.MakeArgString((F.second ? "+" : "-") + F.first())); +} tmatheson-arm wrote: ```suggestion for (auto &[Name, Enabled] : HostFeatures) { Features.push_back( Args.MakeArgString((Enabled ? "+" : "-") + Name)); } ``` https://github.com/llvm/llvm-project/pull/97749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][AArch64] Add getHostCPUFeatures to query for enabled features in cpu info (PR #97749)
@@ -445,4 +445,21 @@ void aarch64::getAArch64TargetFeatures(const Driver , if (Args.getLastArg(options::OPT_mno_bti_at_return_twice)) Features.push_back("+no-bti-at-return-twice"); + + // Parse AArch64 CPU Features + const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ); tmatheson-arm wrote: Feels like this should be done in `getAArch64ArchFeaturesFromMcpu`/`DecodeAArch64Mcpu` https://github.com/llvm/llvm-project/pull/97749 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Bring initFeatureMap back to AArch64TargetInfo. (PR #96832)
tmatheson-arm wrote: Thank you for the example, I understand what is happening how. - Before #94279, we used to add CPU features in `AArch64::initFeatureMap`. - In #94279, we decided that actually you should do that in the Driver, which should put all `-target-features` it wants on the -cc1 command line. The Driver is responsible for expanding the CPU (and architecture) feature dependencies and their interaction with any modifiers on the command line. - This means that when `initFeatureMap` runs in `clang`, `FeaturesAsWritten` is populated with the CPU features and is used to initialise the `FeatureMap`. - In contrast, you are not using the `Driver`, and do not populate `FeaturesAsWritten` with the CPU features. - Instead, you expect `initFeatureMap` to add CPU features. This is not unreasonable, given that the CPU is passed the function and several other backends add CPU features at this stage. [This bit of code](https://github.com/llvm/llvm-project/pull/94279/files#diff-2ccae12096c75c4b8422ea0d2fdf6b195896d2554d62cce604e8fcb56a78ef62L1057-L1067) used to crudely add the CPU features to the end of the feature list. However there are some problems with that approach, which we attempted to rectify in #94279: - CPU features that were explicitly disabled on the command line could actually end up enabled in the backend - The architecture features (i.e. implied by `-march`) were not treated the same way as the CPU features (`-mcpu`) For example, if you wrote: `clang -mcpu=cortex-a75+norcpc -###`, you would see all the Cortex-A75 features expanded on the `-cc1` command line, but with RCPC disabled: `-target-feature -rcpc`. But in this case, `AArch64::initFeatureMap` would have re-added `+rcpc`, overriding the command line. (This is technically not the case after [this line](https://github.com/llvm/llvm-project/pull/94279/files#diff-2ccae12096c75c4b8422ea0d2fdf6b195896d2554d62cce604e8fcb56a78ef62L1092) was added, but the general point is that `initFeatureMap` broke feature dependency resolution in ways that are difficult to reason about). There doesn't seem to be a way to specify an architecture in `TargetOptions`, which looks odd to me. That means there is no way to select e.g. `armv9.4-a` in your example, except by manually adding the features in `TargetOptions::Features` or `TargetOptions::FeaturesAsWritten`. So the way that we set up the AArch64 backend in #94279 is to require you to calculate your feature set up front, which are then trivially passed through by the default `TargetInfo::initFeatureMap`. I'm not sure there is a clear answer on this one. I can't see a way to easily let `AArch64:: initFeatureMap` add CPU features again without breaking the dependency resolution. I am open to suggestions though. If you wanted to go the route of building the feature list before calling `initFeatureMap`, the functions `tools::getTargetFeatures` and `aarch64::getAArch64TargetFeatures` can do that for you. Currently they require a `const Driver `, but fundamentally I think they just need a `DiagnosticsEngine&` so that could be changed. I'm open to other suggestions too. https://github.com/llvm/llvm-project/pull/96832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -102,8 +102,9 @@ int __attribute__((target_version("sha2"))) combine(void) { return 1; } // expected-error@+1 {{multiversioned function declaration has a different calling convention}} int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; } -int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; } +int unspec_args(); // expected-error@-1 {{multiversioned function must have a prototype}} -// expected-error@+1 {{multiversioned function must have a prototype}} +// expected-note@+1 {{function multiversioning caused by this declaration}} +int __attribute__((target_version("fp"))) unspec_args() { return -1; } int __attribute__((target_version("default"))) unspec_args() { return 0; } tmatheson-arm wrote: Either way lets keep the original test, if only to document what that case does now. https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -102,8 +102,9 @@ int __attribute__((target_version("sha2"))) combine(void) { return 1; } // expected-error@+1 {{multiversioned function declaration has a different calling convention}} int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; } -int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; } +int unspec_args(); // expected-error@-1 {{multiversioned function must have a prototype}} -// expected-error@+1 {{multiversioned function must have a prototype}} +// expected-note@+1 {{function multiversioning caused by this declaration}} +int __attribute__((target_version("fp"))) unspec_args() { return -1; } int __attribute__((target_version("default"))) unspec_args() { return 0; } tmatheson-arm wrote: Can we keep the test to check that we _don't_ emit a diagnostic then? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
https://github.com/tmatheson-arm deleted https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11465,6 +11465,10 @@ static bool CheckMultiVersionFirstFunction(Sema , FunctionDecl *FD) { // otherwise it is treated as a normal function. if (TA && !TA->isDefaultVersion()) return false; + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. + if (TVA && TVA->isDefaultVersion()) +return false; tmatheson-arm wrote: ```suggestion if (!TVA || TVA->isDefaultVersion()) return false; ``` https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11947,24 +11939,8 @@ static bool CheckMultiVersionFunction(Sema , FunctionDecl *NewFD, FunctionDecl *OldFD = OldDecl->getAsFunction(); - if (!OldFD->isMultiVersion() && MVKind == MultiVersionKind::None) { -if (NewTVA || !OldFD->getAttr()) - return false; -if (!NewFD->getType()->getAs()) { - // Multiversion declaration doesn't have prototype. - S.Diag(NewFD->getLocation(), diag::err_multiversion_noproto); - NewFD->setInvalidDecl(); -} else { - // No "target_version" attribute is equivalent to "default" attribute. - NewFD->addAttr(TargetVersionAttr::CreateImplicit( - S.Context, "default", NewFD->getSourceRange())); - NewFD->setIsMultiVersion(); - OldFD->setIsMultiVersion(); - OldDecl = OldFD; - Redeclaration = true; -} -return true; - } + if (!OldFD->isMultiVersion() && MVKind == MultiVersionKind::None) tmatheson-arm wrote: `!OldFD->isMultiVersion()` is asserted at the top of the function, so this looks unnecessary. However OldFD is redefined here. This is confusing. Does the original assert still hold with the new assignment? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11523,10 +11525,17 @@ static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, const auto *OldTVA = OldFD->getAttr(); // If the old decl is NOT MultiVersioned yet, and we don't cause that // to change, this is a simple redeclaration. - if ((NewTA && !NewTA->isDefaultVersion() && - (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) || - (NewTVA && !NewTVA->isDefaultVersion() && - (!OldTVA || OldTVA->getName() == NewTVA->getName( + if (NewTA && !NewTA->isDefaultVersion() && + (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) +return false; + + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. Moreover, the old declaration + // must be the default version (either explicitly via the attribute, + // or implicitly without it). + if (NewTVA && NewTVA->isDefaultVersion()) +return false; + if (NewTVA && OldTVA && !OldTVA->isDefaultVersion()) return false; tmatheson-arm wrote: ```suggestion ``` We already know that `!isMultiVersioned()` at this point, because of the call site (and assert at the top of the function). Presumably these checks for the old version have already been done? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11523,10 +11525,17 @@ static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, const auto *OldTVA = OldFD->getAttr(); // If the old decl is NOT MultiVersioned yet, and we don't cause that // to change, this is a simple redeclaration. - if ((NewTA && !NewTA->isDefaultVersion() && - (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) || - (NewTVA && !NewTVA->isDefaultVersion() && - (!OldTVA || OldTVA->getName() == NewTVA->getName( + if (NewTA && !NewTA->isDefaultVersion() && + (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) +return false; + + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. Moreover, the old declaration + // must be the default version (either explicitly via the attribute, + // or implicitly without it). + if (NewTVA && NewTVA->isDefaultVersion()) +return false; tmatheson-arm wrote: ```suggestion // If this is target_version("default") (implicit or explicit) it doesn't trigger MV if (!NewTVA || NewTVA->isDefaultVersion()) return false; ``` This is my understanding of what we want to do here. https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11576,22 +11584,6 @@ static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, } } - if (NewTVA) { tmatheson-arm wrote: If you are reasoning based on that, it might be good to add an assert checking it: ``` assert(!OldTVA || OldTVA->isDefaultVersion()); ``` https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11465,6 +11465,10 @@ static bool CheckMultiVersionFirstFunction(Sema , FunctionDecl *FD) { // otherwise it is treated as a normal function. if (TA && !TA->isDefaultVersion()) return false; + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. + if (TVA && TVA->isDefaultVersion()) +return false; tmatheson-arm wrote: Is it allowed to have both `target` and `target_version` on the same function? If so, can these early returns interfere with each other? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64][TableGen] Create a ProcessorAlias record (PR #96249)
@@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: generic, cortex-a35, cortex-a34, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-a725, cortex-r82, cortex-r82ae, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, cortex-x925, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx, thunderxt88, thunderxt81, thunderxt83, thunderx2t99, thunderx3t110, tsv110, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-s4, apple-s5, apple-a13, apple-a14, apple-m1, apple-a15, apple-m2, apple-a16, apple-m3, apple-a17, apple-m4, a64fx, carmel, ampere1, ampere1a, ampere1b, oryon-1, cobalt-100, grace{{$}} +// AARCH64-NEXT: note: valid target CPU values are: a64fx, ampere1, ampere1a, ampere1b, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-a7, apple-a8, apple-a9, apple-m1, apple-m2, apple-m3, apple-m4, apple-s4, apple-s5, carmel, cobalt-100, cortex-a34, cortex-a35, cortex-a510, cortex-a520, cortex-a520ae, cortex-a53, cortex-a55, cortex-a57, cortex-a65, cortex-a65ae, cortex-a710, cortex-a715, cortex-a72, cortex-a720, cortex-a720ae, cortex-a725, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-r82, cortex-r82ae, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, cortex-x925, cyclone, exynos-m3, exynos-m4, exynos-m5, falkor, generic, grace, kryo, neoverse-512tvb, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, oryon-1, saphira, thunderx, thunderx2t99, thunderx3t110, thunderxt81, thunderxt83, thunderxt88, tsv110{{$}} tmatheson-arm wrote: I meant `AARCH64-SAME`, but you are right, that will potentially miss things. I'd be happy with changing the actual output format, but it doesn't have to be done in this PR. https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64][TableGen] Create a ProcessorAlias record (PR #96249)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Bring initFeatureMap back to AArch64TargetInfo. (PR #96832)
tmatheson-arm wrote: I think a test demonstrating the problem would be the fastest way forward. https://github.com/llvm/llvm-project/pull/96832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Bring initFeatureMap back to AArch64TargetInfo. (PR #96832)
tmatheson-arm wrote: The only thing `AArch64TargetInfo::initFeatureMap` adds is features from the selected CPU. IMHO this was not an appropriate place to be doing that. Since #94279 the CPU features are added either by `AArch64TargetInfo::parseTargetAttr` when dealing with `__attribute(target(...))`, and by `getAArch64ArchFeaturesFromMcpu` if you are in the clang driver dealing with `-mcpu`. Basically anywhere you see `AArch64::ExtensionSet::addCPUDefaults` used. This approach properly handles feature dependencies, which the old `AArch64TargetInfo::initFeatureMap` approach did not. What inputs are you giving when you create the `TargetInfo`? What features do you expect to see that are missing? A concrete example would help to understand. https://github.com/llvm/llvm-project/pull/96832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -102,8 +102,9 @@ int __attribute__((target_version("sha2"))) combine(void) { return 1; } // expected-error@+1 {{multiversioned function declaration has a different calling convention}} int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; } -int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; } +int unspec_args(); // expected-error@-1 {{multiversioned function must have a prototype}} tmatheson-arm wrote: This is not the most helpful message. It doesn't have a prototype because `void` is missing from the argument list? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11498,11 +11502,9 @@ static void patchDefaultTargetVersion(FunctionDecl *From, FunctionDecl *To) { if (MVKindTo == MultiVersionKind::None && (MVKindFrom == MultiVersionKind::TargetVersion || - MVKindFrom == MultiVersionKind::TargetClones)) { -To->setIsMultiVersion(); + MVKindFrom == MultiVersionKind::TargetClones)) To->addAttr(TargetVersionAttr::CreateImplicit( To->getASTContext(), "default", To->getSourceRange())); - } } static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, tmatheson-arm wrote: ```suggestion static bool CheckAttributeCausesMultiVersioning(Sema , FunctionDecl *OldFD, ``` https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11523,10 +11525,16 @@ static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, const auto *OldTVA = OldFD->getAttr(); // If the old decl is NOT MultiVersioned yet, and we don't cause that // to change, this is a simple redeclaration. - if ((NewTA && !NewTA->isDefaultVersion() && - (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) || - (NewTVA && !NewTVA->isDefaultVersion() && - (!OldTVA || OldTVA->getName() == NewTVA->getName( + if (NewTA && !NewTA->isDefaultVersion() && + (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) +return false; + + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. Moreover, the old declaration + // must be the default version (either explicitly via the attribute, + // or implicitly without it). + if (NewTVA && + (NewTVA->isDefaultVersion() || (OldTVA && !OldTVA->isDefaultVersion( return false; // Otherwise, this decl causes MultiVersioning. tmatheson-arm wrote: This comment is out of date, since there are more conditions below it. https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -102,8 +102,9 @@ int __attribute__((target_version("sha2"))) combine(void) { return 1; } // expected-error@+1 {{multiversioned function declaration has a different calling convention}} int __attribute__((aarch64_vector_pcs, target_version("sha3"))) combine(void) { return 2; } -int __attribute__((target_version("fp+aes+pmull+rcpc"))) unspec_args() { return -1; } +int unspec_args(); // expected-error@-1 {{multiversioned function must have a prototype}} -// expected-error@+1 {{multiversioned function must have a prototype}} +// expected-note@+1 {{function multiversioning caused by this declaration}} +int __attribute__((target_version("fp"))) unspec_args() { return -1; } int __attribute__((target_version("default"))) unspec_args() { return 0; } tmatheson-arm wrote: Is there a reason not to keep the original test too? https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang][FMV] Do not omit explicit default target_version attribute. (PR #96628)
@@ -11523,10 +11525,16 @@ static bool CheckTargetCausesMultiVersioning(Sema , FunctionDecl *OldFD, const auto *OldTVA = OldFD->getAttr(); // If the old decl is NOT MultiVersioned yet, and we don't cause that // to change, this is a simple redeclaration. - if ((NewTA && !NewTA->isDefaultVersion() && - (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) || - (NewTVA && !NewTVA->isDefaultVersion() && - (!OldTVA || OldTVA->getName() == NewTVA->getName( + if (NewTA && !NewTA->isDefaultVersion() && + (!OldTA || OldTA->getFeaturesStr() == NewTA->getFeaturesStr())) +return false; + + // The target_version attribute only causes Multiversioning if this + // declaration is NOT the default version. Moreover, the old declaration + // must be the default version (either explicitly via the attribute, + // or implicitly without it). + if (NewTVA && + (NewTVA->isDefaultVersion() || (OldTVA && !OldTVA->isDefaultVersion( return false; tmatheson-arm wrote: ```suggestion if (NewTVA && NewTVA->isDefaultVersion()) return false; if (NewTVA && OldTVA && !OldTVA->isDefaultVersion()) return false; ``` https://github.com/llvm/llvm-project/pull/96628 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
@@ -304,8 +304,21 @@ struct Alias { StringRef Name; }; -inline constexpr Alias CpuAliases[] = {{"cobalt-100", "neoverse-n2"}, - {"grace", "neoverse-v2"}}; +inline constexpr Alias CpuAliases[] = { tmatheson-arm wrote: We should tablegen this too. https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
@@ -88,10 +88,14 @@ StringRef AArch64::getArchExtFeature(StringRef ArchExt) { void AArch64::fillValidCPUArchList(SmallVectorImpl ) { for (const auto : CpuInfos) - Values.push_back(C.Name); +Values.push_back(C.Name); for (const auto : CpuAliases) -Values.push_back(Alias.AltName); +// The apple-latest alias is backend only, do not expose it to clang's -mcpu. +if (Alias.AltName != "apple-latest") tmatheson-arm wrote: I don't love this special case. But, not sure what to do about it. https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
@@ -304,8 +304,21 @@ struct Alias { StringRef Name; }; -inline constexpr Alias CpuAliases[] = {{"cobalt-100", "neoverse-n2"}, - {"grace", "neoverse-v2"}}; +inline constexpr Alias CpuAliases[] = { +{"cobalt-100", "neoverse-n2"}, +{"grace", "neoverse-v2"}, +// Support cyclone as an alias for apple-a7 so we can still LTO old bitcode. tmatheson-arm wrote: If you really want this to work only for bitcode (and not appear on `-mcpu`), could it be handled in the bitcode importer? Same for "apple-latest"? https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
@@ -5,11 +5,11 @@ // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64 // AARCH64: error: unknown target CPU 'not-a-cpu' -// AARCH64-NEXT: note: valid target CPU values are: generic, cortex-a35, cortex-a34, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-a725, cortex-r82, cortex-r82ae, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, cortex-x925, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx, thunderxt88, thunderxt81, thunderxt83, thunderx2t99, thunderx3t110, tsv110, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-s4, apple-s5, apple-a13, apple-a14, apple-m1, apple-a15, apple-m2, apple-a16, apple-m3, apple-a17, apple-m4, a64fx, carmel, ampere1, ampere1a, ampere1b, oryon-1, cobalt-100, grace{{$}} +// AARCH64-NEXT: note: valid target CPU values are: a64fx, ampere1, ampere1a, ampere1b, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-a7, apple-a8, apple-a9, apple-m1, apple-m2, apple-m3, apple-m4, apple-s4, apple-s5, carmel, cobalt-100, cortex-a34, cortex-a35, cortex-a510, cortex-a520, cortex-a520ae, cortex-a53, cortex-a55, cortex-a57, cortex-a65, cortex-a65ae, cortex-a710, cortex-a715, cortex-a72, cortex-a720, cortex-a720ae, cortex-a725, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-r82, cortex-r82ae, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, cortex-x925, cyclone, exynos-m3, exynos-m4, exynos-m5, falkor, generic, grace, kryo, neoverse-512tvb, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, oryon-1, saphira, thunderx, thunderx2t99, thunderx3t110, thunderxt81, thunderxt83, thunderxt88, tsv110{{$}} tmatheson-arm wrote: Split into multiple lines? https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Move Apple aliases into the CpuAlias map (PR #96249)
https://github.com/tmatheson-arm approved this pull request. LGTM, I've added some thoughts but it's fine as it is. https://github.com/llvm/llvm-project/pull/96249 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Clang] Bring initFeatureMap back to AArch64TargetInfo. (PR #96832)
tmatheson-arm wrote: And please add a test to cover whatever broke. https://github.com/llvm/llvm-project/pull/96832 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm approved this pull request. LGTM. Shame the order of the `-target-features` has to change again, but I can see why (there are non-user-visible extensions in the ExtensionInfo table now, which also need sorted). https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -1130,7 +1130,8 @@ INSTANTIATE_TEST_SUITE_P( AArch64::AEK_MTE, AArch64::AEK_SSBS, AArch64::AEK_FP16,AArch64::AEK_FP16FML, AArch64::AEK_SB, AArch64::AEK_JSCVT, - AArch64::AEK_FCMA,AArch64::AEK_PERFMON}), + AArch64::AEK_FCMA,AArch64::AEK_PERFMON, + AArch64::AEK_ETE, AArch64::AEK_AM}), tmatheson-arm wrote: I notice there are no tests for `--print-enabled-extensions` for individual CPUs. Can we now remove these from `TargetParserTest`, which is quite annoying to keep updated, and instead add lit tests for these CPUs which can be autogenerated? Maybe in a follow up PR. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -154,17 +156,39 @@ std::optional AArch64::parseCpu(StringRef Name) { return {}; } -void AArch64::PrintSupportedExtensions(StringMap DescMap) { +void AArch64::PrintSupportedExtensions() { outs() << "All available -march extensions for AArch64\n\n" << "" << left_justify("Name", 20) - << (DescMap.empty() ? "\n" : "Description\n"); + << left_justify("Architecture Feature(s)", 55) + << "Description\n"; for (const auto : Extensions) { // Extensions without a feature cannot be used with -march. -if (!Ext.Feature.empty()) { - std::string Description = DescMap[Ext.Name].str(); +if (!Ext.UserVisibleName.empty() && !Ext.PosTargetFeature.empty()) { + outs() << "" + << format(Ext.Description.empty() ? "%-20s%s\n" : "%-20s%-55s%s\n", + Ext.UserVisibleName.str().c_str(), + Ext.ArchFeatureName.str().c_str(), + Ext.Description.str().c_str()); +} + } +} + +void +AArch64::printEnabledExtensions(std::vector EnabledFeatureNames) { + outs() << "Extensions enabled for the given AArch64 target\n\n" + << "" << left_justify("Architecture Feature(s)", 55) + << "Description\n"; + auto IsEnabled = [&](const ExtensionInfo ) { +StringRef FeatureName = Ext.PosTargetFeature.drop_front(); // drop '+' before comparing tmatheson-arm wrote: Can you ever have a negative feature here? https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -19,3 +19,17 @@ // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon" + +// = Architecture extensions = + +// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 2>&1 | sort | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s tmatheson-arm wrote: I don't think any of the `2>&1` are necessary, because you print to `outs()` (which is good). https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -19,3 +19,17 @@ // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon" + +// = Architecture extensions = + +// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 2>&1 | sort | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s tmatheson-arm wrote: Why not sort the extensions in the actual output, rather than just in the test? Currently they are not in any particular order, which will make reading the output difficult when there are a lot. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -14,23 +14,36 @@ class Extension< tmatheson-arm wrote: The comment needs updating, something like: > A SubtargetFeature that represents one or more Architecture Extensions, as > defined in the Arm ARM and typically named `FEAT_*`. Each has an `AEK_*` > entry in the ArmExtKind enum. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) { return 0; } +static int PrintEnabledExtensions(const TargetOptions& TargetOpts) { + std::string Error; + const llvm::Target *TheTarget = + llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error); + if (!TheTarget) { +llvm::errs() << Error; +return 1; + } + + llvm::TargetOptions BackendOptions; tmatheson-arm wrote: What is the difference between this and `TargetOpts`? This section maybe needs a comment explaining what is going on. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -116,12 +116,18 @@ using ExtensionBitset = Bitset; // SubtargetFeature which may represent either an actual extension or some // internal LLVM property. struct ExtensionInfo { - StringRef Name; // Human readable name, e.g. "profile". + StringRef UserVisibleName; // Human readable name used in -march, -cpu tmatheson-arm wrote: Please could you make the names here consistent with tablegen, i.e. either pick `UserVisibleName` or `MArchName`. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -154,17 +156,39 @@ std::optional AArch64::parseCpu(StringRef Name) { return {}; } -void AArch64::PrintSupportedExtensions(StringMap DescMap) { +void AArch64::PrintSupportedExtensions() { outs() << "All available -march extensions for AArch64\n\n" << "" << left_justify("Name", 20) - << (DescMap.empty() ? "\n" : "Description\n"); + << left_justify("Architecture Feature(s)", 55) + << "Description\n"; for (const auto : Extensions) { // Extensions without a feature cannot be used with -march. -if (!Ext.Feature.empty()) { - std::string Description = DescMap[Ext.Name].str(); +if (!Ext.UserVisibleName.empty() && !Ext.PosTargetFeature.empty()) { + outs() << "" + << format(Ext.Description.empty() ? "%-20s%s\n" : "%-20s%-55s%s\n", + Ext.UserVisibleName.str().c_str(), + Ext.ArchFeatureName.str().c_str(), + Ext.Description.str().c_str()); +} + } +} + +void +AArch64::printEnabledExtensions(std::vector EnabledFeatureNames) { + outs() << "Extensions enabled for the given AArch64 target\n\n" + << "" << left_justify("Architecture Feature(s)", 55) + << "Description\n"; + auto IsEnabled = [&](const ExtensionInfo ) { +StringRef FeatureName = Ext.PosTargetFeature.drop_front(); // drop '+' before comparing +return std::find(EnabledFeatureNames.begin(), EnabledFeatureNames.end(), + FeatureName) != EnabledFeatureNames.end(); tmatheson-arm wrote: Can you use `targetFeatureToExtension` here, to avoid the double loop? https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -1841,7 +1868,8 @@ INSTANTIATE_TEST_SUITE_P( AArch64::AEK_PROFILE, AArch64::AEK_RAND, AArch64::AEK_FP16FML, AArch64::AEK_I8MM, AArch64::AEK_JSCVT, AArch64::AEK_FCMA, - AArch64::AEK_PAUTH, AArch64::AEK_PERFMON}), + AArch64::AEK_PAUTH, AArch64::AEK_PERFMON, + AArch64::AEK_CCDP}), tmatheson-arm wrote: We should think about whether we want each AEK to correspond to a `-march` modifier (status quo) or whether we want it to correspond to an `Extension` like here. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm commented: LGTM, just some minor suggestions/clarifications. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -14,23 +14,36 @@ class Extension< string TargetFeatureName,// String used for -target-feature and -march, unless overridden. string Spelling, // The XYZ in HasXYZ and AEK_XYZ. + string ArchitectureFeatureName, // The extension's "FEAT_*"" name(s) defined by the architecture string Desc, // Description. list Implies = [] // List of dependent features. > : SubtargetFeature Implies> { string ArchExtKindSpelling = "AEK_" # Spelling; // ArchExtKind enum name. -// In general, the name written on the command line should match the name -// used for -target-feature. However, there are exceptions. Therefore we -// add a separate field for this, to allow overriding it. Strongly prefer -// not doing so. -string MArchName = TargetFeatureName; +string ArchFeatureName = ArchitectureFeatureName; + +// By default, extensions are available as -march/-cpu command line options. +string MArchName = ""; // An alias that can be used on the command line, if the extension has one. // Used for correcting historical names while remaining backwards compatible. string MArchAlias = ""; } +class ExtensionWithMArch< tmatheson-arm wrote: ```suggestion // An Extension that can be enabled via a `-march` modifier or target attribute, e.g. `+sm4` class ExtensionWithMArch< ``` https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -161,6 +162,39 @@ static int PrintSupportedExtensions(std::string TargetStr) { return 0; } +static int PrintEnabledExtensions(const TargetOptions& TargetOpts) { + std::string Error; + const llvm::Target *TheTarget = + llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error); + if (!TheTarget) { +llvm::errs() << Error; +return 1; + } + + llvm::TargetOptions BackendOptions; + std::string FeaturesStr = llvm::join(TargetOpts.FeaturesAsWritten, ","); + std::unique_ptr TheTargetMachine( + TheTarget->createTargetMachine(TargetOpts.Triple, TargetOpts.CPU, FeaturesStr, BackendOptions, std::nullopt)); + const llvm::Triple = TheTargetMachine->getTargetTriple(); + const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo(); + const std::vector Features = +MCInfo->getEnabledProcessorFeatures(); + + std::vector EnabledFeatureNames; + for (const llvm::SubtargetFeatureKV : Features) +EnabledFeatureNames.push_back(feature.Key); tmatheson-arm wrote: Maybe we shouldn't throw away the type information in `llvm::SubtargetFeatureKV` before `printEnabledExtensions`. It is not clear what `EnabledFeatureNames` contains, since it is just a vector of strings. i.e. are they internal names, extension names, subtarget feature names, etc. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] SVE2 is an optional feature in ARMv9.0a (PR #96007)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/96007 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm closed https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [Clang][ARM][AArch64] Alway emit protection attributes for functions. (PR #82819)
https://github.com/tmatheson-arm approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/82819 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
tmatheson-arm wrote: > Looking good Tomas and thanks for your effort to tidy things up. I know this > is NFC, but can we rectify the implied features for rcpc2 and rcpc3 by adding > rcpc-immo as shown here > https://github.com/llvm/llvm-project/pull/92319/files#diff-0df0a19b911b768165642047ad84892b945f9e2e652f91e8d9ed911b21915ec4R488 > ? That would be better as a separate PR. https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH 1/4] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH 1/4] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH 1/3] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH 1/2] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] [AArch64][TargetParser] Split FMV and extensions (PR #92882)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Split fmv and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH 1/2] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] Split fmv and extensions (PR #92882)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Split fmv and extensions (PR #92882)
https://github.com/tmatheson-arm ready_for_review https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Split fmv and extensions (PR #92882)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92882 >From b3e9e2f313d3c3a51b7b6690a5cca67a3ec87dd6 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Tue, 18 Jun 2024 22:23:11 +0100 Subject: [PATCH] [AArch64][TargetParser] Split FMV and extensions --- clang/include/clang/Basic/TargetInfo.h| 5 - clang/lib/AST/ASTContext.cpp | 4 +- clang/lib/Basic/Targets/AArch64.cpp | 20 +- clang/lib/Basic/Targets/AArch64.h | 1 - clang/lib/CodeGen/CGBuiltin.cpp | 2 +- clang/lib/CodeGen/Targets/AArch64.cpp | 2 +- clang/test/CodeGen/aarch64-fmv-dependencies.c | 92 .../llvm/TargetParser/AArch64TargetParser.h | 32 ++- llvm/lib/Target/AArch64/AArch64.td| 1 + llvm/lib/Target/AArch64/AArch64FMV.td | 99 + llvm/lib/Target/AArch64/AArch64Features.td| 206 -- llvm/lib/TargetParser/AArch64TargetParser.cpp | 30 ++- llvm/utils/TableGen/ARMTargetDefEmitter.cpp | 36 ++- 13 files changed, 281 insertions(+), 249 deletions(-) create mode 100644 llvm/lib/Target/AArch64/AArch64FMV.td diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 8a6511b9ced83..9b0ae2102e098 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1400,11 +1400,6 @@ class TargetInfo : public TransferrableTargetInfo, return true; } - /// For given feature return dependent ones. - virtual StringRef getFeatureDependencies(StringRef Feature) const { -return StringRef(); - } - struct BranchProtectionInfo { LangOptions::SignReturnAddressScopeKind SignReturnAddr; LangOptions::SignReturnAddressKeyKind SignKey; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index aa22825602a40..5329fb6bf22f5 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -13683,9 +13683,9 @@ static std::vector getFMVBackendFeaturesFor( const llvm::SmallVectorImpl ) { std::vector BackendFeats; for (StringRef F : FMVFeatStrings) { -if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) { +if (auto FMVExt = llvm::AArch64::parseFMVExtension(F)) { SmallVector Feats; - FMVExt->DependentFeatures.split(Feats, ',', -1, false); + FMVExt->Features.split(Feats, ',', -1, false); for (StringRef F : Feats) BackendFeats.push_back(F.str()); } diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index fba2ad00df96d..31d8121b91d10 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -673,34 +673,30 @@ AArch64TargetInfo::getVScaleRange(const LangOptions ) const { unsigned AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const { if (Name == "default") return 0; - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->FmvPriority; + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return Ext->Priority; return 0; } unsigned AArch64TargetInfo::multiVersionFeatureCost() const { // Take the maximum priority as per feature cost, so more features win. - return llvm::AArch64::ExtensionInfo::MaxFMVPriority; + constexpr unsigned MaxFMVPriority = 1000; + return MaxFMVPriority; } bool AArch64TargetInfo::doesFeatureAffectCodeGen(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return !Ext->DependentFeatures.empty(); + // FMV extensions which imply no backend features do not affect codegen. + if (auto Ext = llvm::AArch64::parseFMVExtension(Name)) +return !Ext->Features.empty(); return false; } -StringRef AArch64TargetInfo::getFeatureDependencies(StringRef Name) const { - if (auto Ext = llvm::AArch64::parseArchExtension(Name)) -return Ext->DependentFeatures; - return StringRef(); -} - bool AArch64TargetInfo::validateCpuSupports(StringRef FeatureStr) const { // CPU features might be separated by '+', extract them and check llvm::SmallVector Features; FeatureStr.split(Features, "+"); for (auto : Features) -if (!llvm::AArch64::parseArchExtension(Feature.trim()).has_value()) +if (!llvm::AArch64::parseFMVExtension(Feature.trim()).has_value()) return false; return true; } diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index c0a6bd2de6b04..71510fe289510 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -151,7 +151,6 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public TargetInfo { std::optional> getVScaleRange(const LangOptions ) const override; bool doesFeatureAffectCodeGen(StringRef Name) const override; - StringRef getFeatureDependencies(StringRef Name) const override; bool validateCpuSupports(StringRef FeatureStr) const override; bool hasFeature(StringRef Feature) const override;
[clang] [llvm] Split fmv and extensions (PR #92882)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/92882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95519)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/95519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64][TargetParser] move CPUInfo into tablegen [NFC] (PR #92145)
https://github.com/tmatheson-arm closed https://github.com/llvm/llvm-project/pull/92145 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95519)
https://github.com/tmatheson-arm approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/95519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
https://github.com/tmatheson-arm deleted https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -19,3 +19,19 @@ // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon" + +// = Architecture extensions = + +// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s +// ARCH-EXTENSION: FEAT_ETE +// ARCH-EXTENSION: FEAT_LOR +// ARCH-EXTENSION: FEAT_TRBE +// ARCH-EXTENSION: FEAT_VHE +// ARCH-EXTENSION: FEAT_PAN +// ARCH-EXTENSION: FEAT_CRC32 +// FIXME: FEAT_FP is optional from v8.0a +// ARCH-EXTENSION: FEAT_FP +// ARCH-EXTENSION: FEAT_LSE +// ARCH-EXTENSION: FEAT_RDM +// FIXME: FEAT_AdvSIMD is optional from v8.0a +// ARCH-EXTENSION: FEAT_AdvSIMD tmatheson-arm wrote: These should go in a separate file so that the tests can be autogenerated (or autogenerate this file, if possible). https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -19,3 +19,19 @@ // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // RUN: %clang --target=arm64 -mlittle-endian -march=armv8.1-a -### -c %s 2>&1 | FileCheck -check-prefix=ARM64-GENERICV81A %s // ARM64-GENERICV81A: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "generic"{{.*}} "-target-feature" "+v8.1a"{{.*}} "-target-feature" "+neon" + +// = Architecture extensions = + +// RUN: %clang -target aarch64 -march=armv8.1-a --print-enabled-extensions 2>&1 | FileCheck -check-prefix=ARCH-EXTENSION --implicit-check-not FEAT_ %s +// ARCH-EXTENSION: FEAT_ETE +// ARCH-EXTENSION: FEAT_LOR +// ARCH-EXTENSION: FEAT_TRBE +// ARCH-EXTENSION: FEAT_VHE +// ARCH-EXTENSION: FEAT_PAN +// ARCH-EXTENSION: FEAT_CRC32 +// FIXME: FEAT_FP is optional from v8.0a +// ARCH-EXTENSION: FEAT_FP +// ARCH-EXTENSION: FEAT_LSE +// ARCH-EXTENSION: FEAT_RDM +// FIXME: FEAT_AdvSIMD is optional from v8.0a +// ARCH-EXTENSION: FEAT_AdvSIMD tmatheson-arm wrote: Use ARCH-NEXT to guarantee we don't miss any changes. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -116,7 +116,9 @@ const AArch64::ArchInfo *AArch64::parseArch(StringRef Arch) { std::optional AArch64::parseArchExtension(StringRef ArchExt) { for (const auto : Extensions) { -if (ArchExt == A.Name || ArchExt == A.Alias) +if (A.UserVisibleName.empty() && !A.Alias) + continue; tmatheson-arm wrote: This seems redundant when looking at the following `if` condition, maybe we actually want to check if `ArchExt.empty()` instead? https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -23,6 +23,7 @@ class Extension< string TargetFeatureName,// String used for -target-feature and -march, unless overridden. string Spelling, // The XYZ in HasXYZ and AEK_XYZ. + string ArchitectureFeatureName, // The extension's "FEAT_*"" name(s) defined by the architecture tmatheson-arm wrote: Keep the name in sync with the name in the struct if you can https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -114,12 +114,14 @@ using ExtensionBitset = Bitset; // SubtargetFeature which may represent either an actual extension or some // internal LLVM property. struct ExtensionInfo { - StringRef Name; // Human readable name, e.g. "profile". + StringRef UserVisibleName; // Human readable name used in -march/-cpu, e.g. "profile" std::optional Alias; // An alias for this extension, if one exists. ArchExtKind ID; // Corresponding to the ArchExtKind, this // extensions representation in the bitfield. - StringRef Feature; // -mattr enable string, e.g. "+spe" - StringRef NegFeature; // -mattr disable string, e.g. "-spe" + StringRef ArchFeatureName; // The feature name defined by the Architecture + StringRef Description; // The textual description of the extension + StringRef TargetFeature;// -target-feature/-mattr enable string, e.g. "+spe" tmatheson-arm wrote: ```suggestion StringRef PosTargetFeature;// -target-feature/-mattr enable string, e.g. "+spe" ``` Keeps it consistent with `NegTargetFeature`, and makes it clear it includes the `+` https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -114,12 +114,14 @@ using ExtensionBitset = Bitset; // SubtargetFeature which may represent either an actual extension or some // internal LLVM property. struct ExtensionInfo { - StringRef Name; // Human readable name, e.g. "profile". + StringRef UserVisibleName; // Human readable name used in -march/-cpu, e.g. "profile" tmatheson-arm wrote: This is also what is used in the `target` attribute. https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
@@ -114,12 +114,14 @@ using ExtensionBitset = Bitset; // SubtargetFeature which may represent either an actual extension or some // internal LLVM property. struct ExtensionInfo { - StringRef Name; // Human readable name, e.g. "profile". + StringRef UserVisibleName; // Human readable name used in -march/-cpu, e.g. "profile" std::optional Alias; // An alias for this extension, if one exists. ArchExtKind ID; // Corresponding to the ArchExtKind, this // extensions representation in the bitfield. - StringRef Feature; // -mattr enable string, e.g. "+spe" - StringRef NegFeature; // -mattr disable string, e.g. "-spe" + StringRef ArchFeatureName; // The feature name defined by the Architecture tmatheson-arm wrote: ```suggestion StringRef ArchFeatureName; // The feature name defined by the Architecture e.g. FEAT_AdvSIMD ``` https://github.com/llvm/llvm-project/pull/95805 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Parse target attribute (PR #95519)
https://github.com/tmatheson-arm requested changes to this pull request. https://github.com/llvm/llvm-project/pull/95519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Parse target attribute (PR #95519)
@@ -13725,12 +13725,10 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap , // Make a copy of the features as passed on the command line into the // beginning of the additional features from the function to override. -// AArch64 handles command line option features in parseTargetAttr(). -if (!Target->getTriple().isAArch64()) tmatheson-arm wrote: Removing this will break the dependency expansion done in `parseTargetAttr()` https://github.com/llvm/llvm-project/pull/95519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Parse target attribute (PR #95519)
https://github.com/tmatheson-arm edited https://github.com/llvm/llvm-project/pull/95519 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [llvm][AArch64] Support -mcpu=apple-m4 (PR #95478)
@@ -521,7 +521,14 @@ inline constexpr CpuInfo CpuInfos[] = { AArch64::ExtensionBitset({AArch64::AEK_AES, AArch64::AEK_SHA2, AArch64::AEK_SHA3, AArch64::AEK_FP16, AArch64::AEK_FP16FML})}, - +// Technically apple-m4 is ARMv9.2a, but a quirk of LLVM defines v9.0 as +// requiring SVE, which is optional according to the Arm ARM and not +// supported by the core. ARMv8.7a is the next closest choice. tmatheson-arm wrote: >From the Arm ARM: > FEAT_SVE2 is OPTIONAL from Armv9.0. In LLVM, SVE2 is an `Implied` (read: mandatory) feature of 9.0-a (wrong), and SVE and SVE2 are both on by default for the architecture: ``` def HasV9_0aOps : Architecture64<9, 0, "a", "v9a", [HasV8_5aOps, FeatureMEC, FeatureSVE2], !listconcat(HasV8_5aOps.DefaultExts, [FeatureFullFP16, FeatureSVE, FeatureSVE2])>; ``` It should be possible to remove SVE2 from the `Implied` list while keeping it in the list of default extensions, which would avoid any user-facing changes. I'm not sure why FEAT_MEC is enabled there either. > FEAT_MEC is OPTIONAL from Armv9.2. https://github.com/llvm/llvm-project/pull/95478 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Add support for Cortex-A725 and Cortex-X925 (PR #95214)
https://github.com/tmatheson-arm approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/95214 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95231)
https://github.com/tmatheson-arm approved this pull request. https://github.com/llvm/llvm-project/pull/95231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] set AppleA14 architecture version to v8.4-a (PR #92600)
https://github.com/tmatheson-arm closed https://github.com/llvm/llvm-project/pull/92600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 1b13bc0 - [AArch64] fix Windows buildbot failure
Author: Tomas Matheson Date: 2024-06-10T14:47:23+01:00 New Revision: 1b13bc05fe4a3b7b4916387543f0a64d41909e83 URL: https://github.com/llvm/llvm-project/commit/1b13bc05fe4a3b7b4916387543f0a64d41909e83 DIFF: https://github.com/llvm/llvm-project/commit/1b13bc05fe4a3b7b4916387543f0a64d41909e83.diff LOG: [AArch64] fix Windows buildbot failure Introduced by 2cf14398c9341feddb419e7ff9c8c5623a3da3db (#94279). See also 6c369cf937b7d9acb98a1fc46b1340cef7703e12. The build system cannot track transitive dependencies on generated headers for some reason. Added: Modified: clang/lib/AST/CMakeLists.txt Removed: diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index a5d3dacfc1a84..0328666d59b1f 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/lib/AST/CMakeLists.txt @@ -139,4 +139,6 @@ add_clang_library(clangAST omp_gen ClangDriverOptions intrinsics_gen + # These generated headers are included transitively. + AArch64TargetParserTableGen ) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] set AppleA14 architecture version to v8.4-a (PR #92600)
https://github.com/tmatheson-arm updated https://github.com/llvm/llvm-project/pull/92600 >From 518b83ab69c4852f7e7ea71c17df3f58e8ff50ef Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Fri, 17 May 2024 21:39:17 +0100 Subject: [PATCH 1/5] [AArch64] set AppleA14 architecture version to 8.5 --- llvm/lib/Target/AArch64/AArch64Processors.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/AArch64/AArch64Processors.td b/llvm/lib/Target/AArch64/AArch64Processors.td index f2286ae17dba5..96422758bc618 100644 --- a/llvm/lib/Target/AArch64/AArch64Processors.td +++ b/llvm/lib/Target/AArch64/AArch64Processors.td @@ -718,7 +718,7 @@ def ProcessorFeatures { list AppleA13 = [HasV8_4aOps, FeatureCrypto, FeatureFPARMv8, FeatureNEON, FeaturePerfMon, FeatureFullFP16, FeatureFP16FML, FeatureSHA3]; - list AppleA14 = [HasV8_4aOps, FeatureCrypto, FeatureFPARMv8, + list AppleA14 = [HasV8_5aOps, FeatureCrypto, FeatureFPARMv8, FeatureNEON, FeaturePerfMon, FeatureFRInt3264, FeatureSpecRestrict, FeatureSSBS, FeatureSB, FeaturePredRes, FeatureCacheDeepPersist, >From 74f6d426fa67b1f794a8ba2ac7c864830ee9c2b2 Mon Sep 17 00:00:00 2001 From: Tomas Matheson Date: Mon, 20 May 2024 12:38:52 +0100 Subject: [PATCH 2/5] make m1+a14 v8.4 instead --- clang/lib/Basic/Targets/AArch64.cpp| 4 +++- clang/test/Driver/aarch64-mac-cpus.c | 2 +- clang/test/Preprocessor/aarch64-target-features.c | 8 +++- .../llvm/TargetParser/AArch64TargetParser.h| 4 ++-- llvm/lib/Target/AArch64/AArch64Processors.td | 14 +- llvm/test/DebugInfo/debug_frame_symbol.ll | 2 +- .../AddressSanitizer/calls-only-smallfn.ll | 2 +- .../Instrumentation/AddressSanitizer/calls-only.ll | 2 +- llvm/unittests/TargetParser/TargetParserTest.cpp | 8 9 files changed, 29 insertions(+), 17 deletions(-) diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp index 5db1ce78c657f..692ec58235efe 100644 --- a/clang/lib/Basic/Targets/AArch64.cpp +++ b/clang/lib/Basic/Targets/AArch64.cpp @@ -286,7 +286,6 @@ void AArch64TargetInfo::getTargetDefinesARMV84A(const LangOptions , void AArch64TargetInfo::getTargetDefinesARMV85A(const LangOptions , MacroBuilder ) const { Builder.defineMacro("__ARM_FEATURE_FRINT", "1"); - Builder.defineMacro("__ARM_FEATURE_BTI", "1"); // Also include the Armv8.4 defines getTargetDefinesARMV84A(Opts, Builder); } @@ -499,6 +498,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions , if (HasPAuthLR) Builder.defineMacro("__ARM_FEATURE_PAUTH_LR", "1"); + if (HasBTI) +Builder.defineMacro("__ARM_FEATURE_BTI", "1"); + if (HasUnalignedAccess) Builder.defineMacro("__ARM_FEATURE_UNALIGNED", "1"); diff --git a/clang/test/Driver/aarch64-mac-cpus.c b/clang/test/Driver/aarch64-mac-cpus.c index 5179731268950..488298cfd2d24 100644 --- a/clang/test/Driver/aarch64-mac-cpus.c +++ b/clang/test/Driver/aarch64-mac-cpus.c @@ -16,7 +16,7 @@ // RUN: %clang --target=arm64-apple-macos -mcpu=apple-m1 -### -c %s 2>&1 | FileCheck --check-prefix=EXPLICIT-M1 %s // CHECK: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-m1" -// CHECK-SAME: "-target-feature" "+v8.5a" +// CHECK-SAME: "-target-feature" "+v8.4a" // EXPLICIT-A11: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a11" // EXPLICIT-A7: "-cc1"{{.*}} "-triple" "arm64{{.*}}" "-target-cpu" "apple-a7" diff --git a/clang/test/Preprocessor/aarch64-target-features.c b/clang/test/Preprocessor/aarch64-target-features.c index 82304a15a04a3..3f2c2929c7129 100644 --- a/clang/test/Preprocessor/aarch64-target-features.c +++ b/clang/test/Preprocessor/aarch64-target-features.c @@ -335,7 +335,7 @@ // CHECK-MCPU-CARMEL: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" "+v8.2a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" "+lse" "-target-feature" "+ras" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature" "+neon" // RUN: %clang -target x86_64-apple-macosx -arch arm64 -### -c %s 2>&1 | FileCheck --check-prefix=CHECK-ARCH-ARM64 %s -// CHECK-ARCH-ARM64: "-target-cpu" "apple-m1" "-target-feature" "+zcm" "-target-feature" "+zcz" "-target-feature" "+v8.5a" "-target-feature" "+aes" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" "+complxnum" "-target-feature" "+fp-armv8" "-target-feature" "+fullfp16" "-target-feature" "+fp16fml" "-target-feature" "+jsconv" "-target-feature" "+lse" "-target-feature" "+pauth" "-target-feature" "+ras" "-target-feature" "+rcpc" "-target-feature" "+rdm" "-target-feature" "+sha2" "-target-feature"
[clang] [llvm] [AArch64] Decouple feature dependency expansion. (PR #94279)
@@ -48,5 +48,5 @@ int test_versions() { return code(); } // CHECK: attributes #0 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" } -// CHECK: attributes #1 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+neon" } -// CHECK: attributes #2 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+neon,+sve" } tmatheson-arm wrote: I think this is ok. `-march=armv8-a+nosimd+sve` gives `-target-feature -neon`, i.e. `+sve` does not imply `+simd`. The reason we don't see `+neon` here is because the test uses a `-cc1` command line and does not specify `-target-feature +neon`, as the driver would for the same triple. So the test is maybe not actually representative of what would be done if going through the driver, but the changes here look correct given that nothing asks for `+neon`. `+simd` now implies `+fp-armv8` because `def FeatureNEON` says it does. https://github.com/llvm/llvm-project/pull/94279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [AArch64] Decouple feature dependency expansion. (PR #94279)
@@ -13665,9 +13665,9 @@ QualType ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const { } // Given a list of FMV features, add each of their backend features to the list. tmatheson-arm wrote: ```suggestion // Given a list of FMV features, return a concatenated list of the corresponding // backend features (which might contain duplicates). ``` https://github.com/llvm/llvm-project/pull/94279 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits