summaryrefslogtreecommitdiff
path: root/llvm/lib/TargetParser
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/TargetParser')
-rw-r--r--llvm/lib/TargetParser/AArch64TargetParser.cpp86
-rw-r--r--llvm/lib/TargetParser/Host.cpp2
-rw-r--r--llvm/lib/TargetParser/RISCVISAInfo.cpp16
-rw-r--r--llvm/lib/TargetParser/X86TargetParser.cpp5
4 files changed, 75 insertions, 34 deletions
diff --git a/llvm/lib/TargetParser/AArch64TargetParser.cpp b/llvm/lib/TargetParser/AArch64TargetParser.cpp
index ca356ec82bf1..7986f07538df 100644
--- a/llvm/lib/TargetParser/AArch64TargetParser.cpp
+++ b/llvm/lib/TargetParser/AArch64TargetParser.cpp
@@ -23,6 +23,9 @@
using namespace llvm;
+#define EMIT_FMV_INFO
+#include "llvm/TargetParser/AArch64TargetParserDef.inc"
+
static unsigned checkArchVersion(llvm::StringRef Arch) {
if (Arch.size() >= 2 && Arch[0] == 'v' && std::isdigit(Arch[1]))
return (Arch[1] - 48);
@@ -30,9 +33,6 @@ static unsigned checkArchVersion(llvm::StringRef Arch) {
}
const AArch64::ArchInfo *AArch64::getArchForCpu(StringRef CPU) {
- if (CPU == "generic")
- return &ARMV8A;
-
// Note: this now takes cpu aliases into account
std::optional<CpuInfo> Cpu = parseCpu(CPU);
if (!Cpu)
@@ -50,8 +50,8 @@ std::optional<AArch64::ArchInfo> AArch64::ArchInfo::findBySubArch(StringRef SubA
uint64_t AArch64::getCpuSupportsMask(ArrayRef<StringRef> FeatureStrs) {
uint64_t FeaturesMask = 0;
for (const StringRef &FeatureStr : FeatureStrs) {
- if (auto Ext = parseArchExtension(FeatureStr))
- FeaturesMask |= (1ULL << Ext->CPUFeature);
+ if (auto Ext = parseFMVExtension(FeatureStr))
+ FeaturesMask |= (1ULL << Ext->Bit);
}
return FeaturesMask;
}
@@ -79,7 +79,7 @@ StringRef AArch64::getArchExtFeature(StringRef ArchExt) {
StringRef ArchExtBase = IsNegated ? ArchExt.drop_front(2) : ArchExt;
if (auto AE = parseArchExtension(ArchExtBase)) {
- // Note: the returned string can be empty.
+ assert(!(AE.has_value() && AE->NegFeature.empty()));
return IsNegated ? AE->NegFeature : AE->Feature;
}
@@ -122,6 +122,26 @@ AArch64::parseArchExtension(StringRef ArchExt) {
return {};
}
+std::optional<AArch64::FMVInfo> AArch64::parseFMVExtension(StringRef FMVExt) {
+ // FIXME introduce general alias functionality, or remove this exception.
+ if (FMVExt == "rdma")
+ FMVExt = "rdm";
+
+ for (const auto &I : getFMVInfo()) {
+ if (FMVExt == I.Name)
+ return I;
+ }
+ return {};
+}
+
+std::optional<AArch64::ExtensionInfo>
+AArch64::targetFeatureToExtension(StringRef TargetFeature) {
+ for (const auto &E : Extensions)
+ if (TargetFeature == E.Feature)
+ return E;
+ return {};
+}
+
std::optional<AArch64::CpuInfo> AArch64::parseCpu(StringRef Name) {
// Resolve aliases first.
Name = resolveCPUAlias(Name);
@@ -213,21 +233,6 @@ void AArch64::ExtensionSet::disable(ArchExtKind E) {
disable(Dep.Later);
}
-void AArch64::ExtensionSet::toLLVMFeatureList(
- std::vector<StringRef> &Features) const {
- if (BaseArch && !BaseArch->ArchFeature.empty())
- Features.push_back(BaseArch->ArchFeature);
-
- for (const auto &E : Extensions) {
- if (E.Feature.empty() || !Touched.test(E.ID))
- continue;
- if (Enabled.test(E.ID))
- Features.push_back(E.Feature);
- else
- Features.push_back(E.NegFeature);
- }
-}
-
void AArch64::ExtensionSet::addCPUDefaults(const CpuInfo &CPU) {
LLVM_DEBUG(llvm::dbgs() << "addCPUDefaults(" << CPU.Name << ")\n");
BaseArch = &CPU.Arch;
@@ -247,11 +252,18 @@ void AArch64::ExtensionSet::addArchDefaults(const ArchInfo &Arch) {
enable(E.ID);
}
-bool AArch64::ExtensionSet::parseModifier(StringRef Modifier) {
+bool AArch64::ExtensionSet::parseModifier(StringRef Modifier,
+ const bool AllowNoDashForm) {
LLVM_DEBUG(llvm::dbgs() << "parseModifier(" << Modifier << ")\n");
- bool IsNegated = Modifier.starts_with("no");
- StringRef ArchExt = IsNegated ? Modifier.drop_front(2) : Modifier;
+ size_t NChars = 0;
+ // The "no-feat" form is allowed in the target attribute but nowhere else.
+ if (AllowNoDashForm && Modifier.starts_with("no-"))
+ NChars = 3;
+ else if (Modifier.starts_with("no"))
+ NChars = 2;
+ bool IsNegated = NChars != 0;
+ StringRef ArchExt = Modifier.drop_front(NChars);
if (auto AE = parseArchExtension(ArchExt)) {
if (AE->Feature.empty() || AE->NegFeature.empty())
@@ -265,6 +277,32 @@ bool AArch64::ExtensionSet::parseModifier(StringRef Modifier) {
return false;
}
+void AArch64::ExtensionSet::reconstructFromParsedFeatures(
+ const std::vector<std::string> &Features,
+ std::vector<std::string> &NonExtensions) {
+ assert(Touched.none() && "Bitset already initialized");
+ for (auto &F : Features) {
+ bool IsNegated = F[0] == '-';
+ if (auto AE = targetFeatureToExtension(F)) {
+ Touched.set(AE->ID);
+ if (IsNegated)
+ Enabled.reset(AE->ID);
+ else
+ Enabled.set(AE->ID);
+ continue;
+ }
+ NonExtensions.push_back(F);
+ }
+}
+
+void AArch64::ExtensionSet::dump() const {
+ std::vector<StringRef> Features;
+ toLLVMFeatureList(Features);
+ for (StringRef F : Features)
+ llvm::outs() << F << " ";
+ llvm::outs() << "\n";
+}
+
const AArch64::ExtensionInfo &
AArch64::getExtensionByID(AArch64::ArchExtKind ExtID) {
return lookupExtensionByID(ExtID);
diff --git a/llvm/lib/TargetParser/Host.cpp b/llvm/lib/TargetParser/Host.cpp
index 369287e2d203..2ea56746aff2 100644
--- a/llvm/lib/TargetParser/Host.cpp
+++ b/llvm/lib/TargetParser/Host.cpp
@@ -239,11 +239,13 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
.Case("0xd4d", "cortex-a715")
.Case("0xd81", "cortex-a720")
.Case("0xd89", "cortex-a720ae")
+ .Case("0xd87", "cortex-a725")
.Case("0xd44", "cortex-x1")
.Case("0xd4c", "cortex-x1c")
.Case("0xd48", "cortex-x2")
.Case("0xd4e", "cortex-x3")
.Case("0xd82", "cortex-x4")
+ .Case("0xd85", "cortex-x925")
.Case("0xd4a", "neoverse-e1")
.Case("0xd0c", "neoverse-n1")
.Case("0xd49", "neoverse-n2")
diff --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 4e0d07d39f9b..739a36477c28 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -177,21 +177,21 @@ bool RISCVISAInfo::addExtension(StringRef ExtName,
}
static StringRef getExtensionTypeDesc(StringRef Ext) {
- if (Ext.starts_with("s"))
+ if (Ext.starts_with('s'))
return "standard supervisor-level extension";
- if (Ext.starts_with("x"))
+ if (Ext.starts_with('x'))
return "non-standard user-level extension";
- if (Ext.starts_with("z"))
+ if (Ext.starts_with('z'))
return "standard user-level extension";
return StringRef();
}
static StringRef getExtensionType(StringRef Ext) {
- if (Ext.starts_with("s"))
+ if (Ext.starts_with('s'))
return "s";
- if (Ext.starts_with("x"))
+ if (Ext.starts_with('x'))
return "x";
- if (Ext.starts_with("z"))
+ if (Ext.starts_with('z'))
return "z";
return StringRef();
}
@@ -287,7 +287,7 @@ std::vector<std::string> RISCVISAInfo::toFeatures(bool AddAllExtensions,
return Features;
}
-static Error getStringErrorForInvalidExt(std::string_view ExtName) {
+static Error getStringErrorForInvalidExt(StringRef ExtName) {
if (ExtName.size() == 1) {
return createStringError(errc::invalid_argument,
"unsupported standard user-level extension '" +
@@ -757,7 +757,7 @@ RISCVISAInfo::parseArchString(StringRef Arch, bool EnableExperimentalExtension,
Ext, SeenExtMap, IgnoreUnknown, EnableExperimentalExtension,
ExperimentalExtensionVersionCheck))
return std::move(E);
- // Multi-letter extension must be seperate following extension with
+ // Multi-letter extension must be separate following extension with
// underscore
break;
} else {
diff --git a/llvm/lib/TargetParser/X86TargetParser.cpp b/llvm/lib/TargetParser/X86TargetParser.cpp
index e3802380d2be..141ecb936b70 100644
--- a/llvm/lib/TargetParser/X86TargetParser.cpp
+++ b/llvm/lib/TargetParser/X86TargetParser.cpp
@@ -631,6 +631,7 @@ constexpr FeatureBitset ImpliedFeaturesNDD = {};
constexpr FeatureBitset ImpliedFeaturesCCMP = {};
constexpr FeatureBitset ImpliedFeaturesNF = {};
constexpr FeatureBitset ImpliedFeaturesCF = {};
+constexpr FeatureBitset ImpliedFeaturesZU = {};
constexpr FeatureInfo FeatureInfos[X86::CPU_FEATURE_MAX] = {
#define X86_FEATURE(ENUM, STR) {{"+" STR}, ImpliedFeatures##ENUM},
@@ -748,13 +749,13 @@ unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) {
#ifndef NDEBUG
// Check that priorities are set properly in the .def file. We expect that
// "compat" features are assigned non-duplicate consecutive priorities
- // starting from one (1, ..., 35) and multiple zeros.
+ // starting from one (1, ..., 37) and multiple zeros.
#define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) PRIORITY,
unsigned Priorities[] = {
#include "llvm/TargetParser/X86TargetParser.def"
};
std::array<unsigned, std::size(Priorities)> HelperList;
- const size_t MaxPriority = 35;
+ const size_t MaxPriority = 37;
std::iota(HelperList.begin(), HelperList.begin() + MaxPriority + 1, 0);
for (size_t i = MaxPriority + 1; i != std::size(Priorities); ++i)
HelperList[i] = 0;