[clang] [llvm] [AArch64] Add ability to list extensions enabled for a target (PR #95805)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 17 08:45:48 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 964c92d04f039a205327cb47c75919096f9fca94 2e10a741ac8ddfccc661966df096de9c7ff505f1 -- clang/test/Driver/aarch64-v8a.c clang/test/Driver/aarch64-v9a.c clang/include/clang/Frontend/FrontendOptions.h clang/lib/Basic/Targets/AArch64.cpp clang/lib/CodeGen/Targets/AArch64.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChain.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/aarch64-v81a.c clang/test/Driver/aarch64-v82a.c clang/test/Driver/aarch64-v83a.c clang/test/Driver/aarch64-v84a.c clang/test/Driver/aarch64-v85a.c clang/test/Driver/aarch64-v86a.c clang/test/Driver/aarch64-v87a.c clang/test/Driver/aarch64-v88a.c clang/test/Driver/aarch64-v89a.c clang/test/Driver/aarch64-v91a.c clang/test/Driver/aarch64-v92a.c clang/test/Driver/aarch64-v93a.c clang/test/Driver/aarch64-v94a.c clang/test/Driver/aarch64-v95a.c clang/test/Driver/print-supported-extensions.c clang/tools/driver/cc1_main.cpp llvm/include/llvm/MC/MCSubtargetInfo.h llvm/include/llvm/TargetParser/AArch64TargetParser.h llvm/lib/MC/MCSubtargetInfo.cpp llvm/lib/TargetParser/AArch64TargetParser.cpp llvm/unittests/TargetParser/TargetParserTest.cpp llvm/utils/TableGen/ARMTargetDefEmitter.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index db7327e25f..07561a2c36 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -370,7 +370,8 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
// -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
} else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
(PhaseArg = DAL.getLastArg(options::OPT_print_supported_cpus)) ||
- (PhaseArg = DAL.getLastArg(options::OPT_print_enabled_extensions)) ||
+ (PhaseArg =
+ DAL.getLastArg(options::OPT_print_enabled_extensions)) ||
(PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) ||
(PhaseArg = DAL.getLastArg(options::OPT_verify_pch)) ||
(PhaseArg = DAL.getLastArg(options::OPT_rewrite_objc)) ||
diff --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index 6c0f488844..029a0a26ea 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -162,7 +162,7 @@ static int PrintSupportedExtensions(std::string TargetStr) {
return 0;
}
-static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
+static int PrintEnabledExtensions(const TargetOptions &TargetOpts) {
std::string Error;
const llvm::Target *TheTarget =
llvm::TargetRegistry::lookupTarget(TargetOpts.Triple, Error);
@@ -174,11 +174,13 @@ static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
llvm::TargetOptions BackendOptions;
std::string FeaturesStr = llvm::join(TargetOpts.FeaturesAsWritten, ",");
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
- TheTarget->createTargetMachine(TargetOpts.Triple, TargetOpts.CPU, FeaturesStr, BackendOptions, std::nullopt));
+ TheTarget->createTargetMachine(TargetOpts.Triple, TargetOpts.CPU,
+ FeaturesStr, BackendOptions,
+ std::nullopt));
const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple();
const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();
const std::vector<llvm::SubtargetFeatureKV> Features =
- MCInfo->getEnabledProcessorFeatures();
+ MCInfo->getEnabledProcessorFeatures();
std::vector<llvm::StringRef> EnabledFeatureNames;
for (const llvm::SubtargetFeatureKV &feature : Features)
diff --git a/llvm/include/llvm/TargetParser/AArch64TargetParser.h b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
index d3a93da304..6979b5a34f 100644
--- a/llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ b/llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -114,14 +114,16 @@ using ExtensionBitset = Bitset<AEK_NUM_EXTENSIONS>;
// SubtargetFeature which may represent either an actual extension or some
// internal LLVM property.
struct ExtensionInfo {
- StringRef UserVisibleName; // Human readable name used in -march/-cpu, e.g. "profile"
+ StringRef UserVisibleName; // Human readable name used in -march/-cpu, e.g.
+ // "profile"
std::optional<StringRef> Alias; // An alias for this extension, if one exists.
ArchExtKind ID; // Corresponding to the ArchExtKind, this
// extensions representation in the bitfield.
- 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"
- StringRef NegTargetFeature; // -target-feature/-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"
+ StringRef
+ NegTargetFeature; // -target-feature/-mattr disable string, e.g. "-spe"
CPUFeatures CPUFeature; // Function Multi Versioning (FMV) bitfield value
// set in __aarch64_cpu_features
StringRef DependentFeatures; // FMV enabled features string,
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index e2b98917df..175e2b3410 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -139,8 +139,7 @@ std::optional<AArch64::CpuInfo> AArch64::parseCpu(StringRef Name) {
void AArch64::PrintSupportedExtensions() {
outs() << "All available -march extensions for AArch64\n\n"
<< " " << left_justify("Name", 20)
- << left_justify("Architecture Feature(s)", 55)
- << "Description\n";
+ << left_justify("Architecture Feature(s)", 55) << "Description\n";
for (const auto &Ext : Extensions) {
// Extensions without a feature cannot be used with -march.
if (!Ext.UserVisibleName.empty() && !Ext.TargetFeature.empty()) {
@@ -153,21 +152,21 @@ void AArch64::PrintSupportedExtensions() {
}
}
-void
-AArch64::printEnabledExtensions(std::vector<StringRef> EnabledFeatureNames) {
+void AArch64::printEnabledExtensions(
+ std::vector<StringRef> EnabledFeatureNames) {
outs() << "Extensions enabled for the given AArch64 target\n\n"
<< " " << left_justify("Architecture Feature(s)", 55)
<< "Description\n";
auto IsEnabled = [&](const ExtensionInfo &Ext) {
- StringRef FeatureName = Ext.TargetFeature.drop_front(); // drop '+' before comparing
+ StringRef FeatureName =
+ Ext.TargetFeature.drop_front(); // drop '+' before comparing
return std::find(EnabledFeatureNames.begin(), EnabledFeatureNames.end(),
FeatureName) != EnabledFeatureNames.end();
};
for (const auto &Ext : Extensions) {
if (IsEnabled(Ext)) {
outs() << " "
- << format("%-55s%s\n",
- Ext.ArchFeatureName.str().c_str(),
+ << format("%-55s%s\n", Ext.ArchFeatureName.str().c_str(),
Ext.Description.str().c_str());
}
}
diff --git a/llvm/unittests/TargetParser/TargetParserTest.cpp b/llvm/unittests/TargetParser/TargetParserTest.cpp
index d3ed905b96..f4b79d91ec 100644
--- a/llvm/unittests/TargetParser/TargetParserTest.cpp
+++ b/llvm/unittests/TargetParser/TargetParserTest.cpp
@@ -2314,9 +2314,9 @@ TEST(TargetParserTest, AArch64ArchExtFeature) {
}
TEST(TargetParserTest, AArch64PrintSupportedExtensions) {
- std::string expected =
- "All available -march extensions for AArch64\n\n"
- " Name Architecture Feature(s) Description\n";
+ std::string expected = "All available -march extensions for AArch64\n\n"
+ " Name Architecture Feature(s) "
+ " Description\n";
outs().flush();
testing::internal::CaptureStdout();
``````````
</details>
https://github.com/llvm/llvm-project/pull/95805
More information about the llvm-commits
mailing list