24#define DEBUG_TYPE "target-parser"
29#include "llvm/TargetParser/AArch64TargetParserDef.inc"
32 if (Arch.
size() >= 2 && Arch[0] ==
'v' && std::isdigit(Arch[1]))
33 return (Arch[1] - 48);
39 std::optional<CpuInfo> Cpu =
parseCpu(CPU);
42 return &ArchInfos[Cpu->ArchIdx];
46 for (
const auto &
A : AArch64::ArchInfos)
47 if (
A.getSubArch() == SubArch)
52std::optional<AArch64::FMVInfo>
lookupFMVByID(AArch64::ArchExtKind ExtID) {
62 if (std::optional<AArch64::ExtensionInfo> Ext =
72 for (
const StringRef Feature : Features) {
76 FeatureBits.
enable(*FMV->ID);
78 PriorityMask.
setBit(FMV->PriorityBit);
85 PriorityMask.
setBit(Info.PriorityBit);
96 FeatureBits.
enable(*FMV->ID);
102 FeaturesMask.
setBit(*Info.FeatureBit);
109 std::vector<StringRef> &Features) {
112 if (InputExts.
test(E.ID))
113 Features.push_back(StrTab[E.PosTargetFeature]);
119 for (
const auto &
A : CpuAliases)
120 if (StrTab[
A.AltName] == Name)
121 return StrTab[
A.Name];
130 return StrTab[IsNegated ? AE->NegTargetFeature : AE->PosTargetFeature];
135 for (
const auto &
C : CpuInfos)
136 Values.push_back(StrTab[
C.Name]);
138 for (
const auto &
Alias : CpuAliases)
147 return TT.isAndroid() || TT.isOSDarwin() || TT.isOSFuchsia() ||
148 TT.isOSWindows() || TT.isOHOSFamily();
158 for (
const auto &
A : ArchInfos) {
159 if (StrTab[
A.Name].ends_with(Syn))
165std::optional<AArch64::ExtensionInfo>
172 for (
StringRef Name : {StrTab[
A.UserVisibleName], StrTab[
A.Alias]})
173 Map.try_emplace(Name, &
A);
183 if (FMVExt ==
"rdma")
187 if (FMVExt ==
I.Name)
193std::optional<AArch64::ExtensionInfo>
199 {StrTab[E.PosTargetFeature], StrTab[E.NegTargetFeature]})
200 Map.try_emplace(Feature, &E);
213 for (
const auto &
C : CpuInfos)
214 if (Name == StrTab[
C.Name])
221 outs() <<
"All available -march extensions for AArch64\n\n"
227 if (Ext.UserVisibleName.value() && Ext.PosTargetFeature.value()) {
231 <<
format(!Ext.Description.value() ?
"%-20s%s\n"
233 StrTab[Ext.UserVisibleName].data(),
234 StrTab[Ext.ArchFeatureName].data(),
235 StrTab[Ext.Description].data());
242 outs() <<
"Extensions enabled for the given AArch64 target\n\n"
245 std::vector<ExtensionInfo> EnabledExtensionsInfo;
246 for (
const auto &FeatureName : EnabledFeatureNames) {
247 std::string PosFeatureName =
'+' + FeatureName.str();
249 EnabledExtensionsInfo.push_back(*ExtInfo);
252 std::sort(EnabledExtensionsInfo.begin(), EnabledExtensionsInfo.end(),
254 return StrTab[Lhs.ArchFeatureName] < StrTab[Rhs.ArchFeatureName];
257 for (
const auto &Ext : EnabledExtensionsInfo) {
261 <<
format(
"%-55s%s\n", StrTab[Ext.ArchFeatureName].data(),
262 StrTab[Ext.Description].data());
268 for (
const auto &
E : llvm::AArch64::Extensions)
274void AArch64::ExtensionSet::enable(ArchExtKind E) {
288 for (
auto Dep : ExtensionDependencies)
296 if (E == AEK_FP16 &&
BaseArch->is_superset(ARMV8_4A) &&
301 if (E == AEK_CRYPTO &&
BaseArch->is_superset(ARMV8_4A)) {
308void AArch64::ExtensionSet::disable(ArchExtKind E) {
311 if (E == AEK_CRYPTO) {
322 if (E == AEK_SVE2AES)
329 if (E == AEK_SVE2SM4)
336 if (E == AEK_SVE2SHA3)
339 if (E == AEK_SVE2BITPERM){
355 for (
auto Dep : ExtensionDependencies)
356 if (E == Dep.Earlier)
360void AArch64::ExtensionSet::addCPUDefaults(
const CpuInfo &CPU) {
365 if (CPU.DefaultExtensions.test(E.ID))
374 if (
BaseArch->DefaultExts.test(E.ID))
378void AArch64::ExtensionSet::addArchDefaults(
const ArchInfo &Arch) {
387bool AArch64::ExtensionSet::parseModifier(
StringRef Modifier,
388 const bool AllowNoDashForm) {
393 if (AllowNoDashForm && Modifier.starts_with(
"no-"))
395 else if (Modifier.starts_with(
"no"))
397 bool IsNegated = NChars != 0;
398 StringRef ArchExt = Modifier.drop_front(NChars);
410void AArch64::ExtensionSet::reconstructFromParsedFeatures(
411 const std::vector<std::string> &Features,
412 std::vector<std::string> &NonExtensions) {
414 for (
auto &
F : Features) {
415 bool IsNegated =
F[0] ==
'-';
424 NonExtensions.push_back(
F);
428void AArch64::ExtensionSet::dump()
const {
429 std::vector<StringRef> Features;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
std::optional< AArch64::FMVInfo > getFMVInfoFrom(StringRef Feature)
static unsigned checkArchVersion(llvm::StringRef Arch)
const llvm::AArch64::ExtensionInfo & lookupExtensionByID(llvm::AArch64::ArchExtKind ExtID)
std::optional< AArch64::FMVInfo > lookupFMVByID(AArch64::ArchExtKind ExtID)
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
static cl::opt< ExtensionSet, false, SPIRVExtensionsParser > Extensions("spirv-ext", cl::desc("Specify list of enabled SPIR-V extensions"))
Class for arbitrary precision integers.
void setBit(unsigned BitPosition)
Set the given bit to 1 whose position is given as "bitPosition".
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
constexpr bool test(unsigned I) const
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
constexpr size_t size() const
Get the string size.
Triple - Helper class for working with autoconf configuration names.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI bool isX18ReservedByDefault(const Triple &TT)
LLVM_ABI StringRef getArchExtFeature(StringRef ArchExt)
LLVM_ABI std::optional< ExtensionInfo > parseArchExtension(StringRef Extension)
LLVM_ABI std::optional< CpuInfo > parseCpu(StringRef Name)
LLVM_ABI const std::vector< FMVInfo > & getFMVInfo()
LLVM_ABI const ArchInfo * parseArch(StringRef Arch)
LLVM_ABI const ArchInfo * getArchForCpu(StringRef CPU)
LLVM_ABI const ExtensionInfo & getExtensionByID(ArchExtKind(ExtID))
LLVM_ABI void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
LLVM_ABI APInt getCpuSupportsMask(ArrayRef< StringRef > Features)
LLVM_ABI void printEnabledExtensions(const std::set< StringRef > &EnabledFeatureNames)
LLVM_ABI std::optional< FMVInfo > parseFMVExtension(StringRef Extension)
Bitset< AEK_NUM_EXTENSIONS > ExtensionBitset
LLVM_ABI APInt getFMVPriority(ArrayRef< StringRef > Features)
LLVM_ABI void PrintSupportedExtensions()
LLVM_ABI std::optional< ExtensionInfo > targetFeatureToExtension(StringRef TargetFeature)
LLVM_ABI StringRef resolveCPUAlias(StringRef CPU)
LLVM_ABI bool getExtensionFeatures(const AArch64::ExtensionBitset &Extensions, std::vector< StringRef > &Features)
LLVM_ABI StringRef getCanonicalArchName(StringRef Arch)
MArch is expected to be of the form (arm|thumb)?(eb)?(v.
LLVM_ABI StringRef getArchSynonym(StringRef Arch)
Converts e.g. "armv8" -> "armv8-a".
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr Values
LLVM_ABI raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
StringTable::Offset AltName
AArch64::ExtensionBitset DefaultExts
static LLVM_ABI std::optional< ArchInfo > findBySubArch(StringRef SubArch)
LLVM_ABI void enable(ArchExtKind E)
LLVM_ABI void disable(ArchExtKind E)
void toLLVMFeatureList(std::vector< T > &Features) const
const ArchInfo * BaseArch