23#define DEBUG_TYPE "target-parser"
28#include "llvm/TargetParser/AArch64TargetParserDef.inc"
31 if (Arch.
size() >= 2 && Arch[0] ==
'v' && std::isdigit(Arch[1]))
32 return (Arch[1] - 48);
38 std::optional<CpuInfo> Cpu =
parseCpu(CPU);
45 for (
const auto *
A : AArch64::ArchInfos)
46 if (
A->getSubArch() == SubArch)
52 constexpr unsigned MaxFMVPriority = 1000;
53 unsigned Priority = 0;
54 unsigned NumFeatures = 0;
57 Priority = std::max(Priority, Ext->Priority);
61 return Priority + MaxFMVPriority * NumFeatures;
76 FeaturesMask |= (1ULL <<
Info.Bit);
83 std::vector<StringRef> &Features) {
86 if (InputExts.
test(E.ID) && !E.PosTargetFeature.empty())
87 Features.push_back(E.PosTargetFeature);
93 for (
const auto &
A : CpuAliases)
94 if (
A.AltName ==
Name)
104 assert(!(AE.has_value() && AE->NegTargetFeature.empty()));
105 return IsNegated ? AE->NegTargetFeature : AE->PosTargetFeature;
112 for (
const auto &
C : CpuInfos)
115 for (
const auto &
Alias : CpuAliases)
124 return TT.isAndroid() || TT.isOSDarwin() || TT.isOSFuchsia() ||
125 TT.isOSWindows() || TT.isOHOSFamily();
135 for (
const auto *
A : ArchInfos) {
136 if (
A->Name.ends_with(Syn))
142std::optional<AArch64::ExtensionInfo>
147 if (ArchExt ==
A.UserVisibleName || ArchExt ==
A.Alias)
155 if (FMVExt ==
"rdma")
159 if (FMVExt ==
I.Name)
165std::optional<AArch64::ExtensionInfo>
168 if (TargetFeature == E.PosTargetFeature)
178 for (
const auto &
C : CpuInfos)
186 outs() <<
"All available -march extensions for AArch64\n\n"
192 if (!Ext.UserVisibleName.empty() && !Ext.PosTargetFeature.empty()) {
194 <<
format(Ext.Description.empty() ?
"%-20s%s\n" :
"%-20s%-55s%s\n",
195 Ext.UserVisibleName.str().c_str(),
196 Ext.ArchFeatureName.str().c_str(),
197 Ext.Description.str().c_str());
204 outs() <<
"Extensions enabled for the given AArch64 target\n\n"
207 std::vector<ExtensionInfo> EnabledExtensionsInfo;
208 for (
const auto &FeatureName : EnabledFeatureNames) {
209 std::string PosFeatureName =
'+' + FeatureName.str();
211 EnabledExtensionsInfo.push_back(*ExtInfo);
214 std::sort(EnabledExtensionsInfo.begin(), EnabledExtensionsInfo.end(),
216 return Lhs.ArchFeatureName < Rhs.ArchFeatureName;
219 for (
const auto &Ext : EnabledExtensionsInfo) {
222 Ext.ArchFeatureName.str().c_str(),
223 Ext.Description.str().c_str());
229 for (
const auto &E : llvm::AArch64::Extensions)
247 for (
auto Dep : ExtensionDependencies)
255 if (E == AEK_FP16 && BaseArch->is_superset(ARMV8_4A) &&
256 !BaseArch->is_superset(ARMV9A))
260 if (E == AEK_CRYPTO && BaseArch->is_superset(ARMV8_4A)) {
270 if (E == AEK_CRYPTO) {
281 if (E == AEK_SVE2AES)
293 for (
auto Dep : ExtensionDependencies)
294 if (E == Dep.Earlier)
300 BaseArch = &CPU.
Arch;
304 if (CPUExtensions.
test(E.ID))
318 const bool AllowNoDashForm) {
323 if (AllowNoDashForm && Modifier.
starts_with(
"no-"))
327 bool IsNegated = NChars != 0;
331 if (AE->PosTargetFeature.empty() || AE->NegTargetFeature.empty())
343 const std::vector<std::string> &Features,
344 std::vector<std::string> &NonExtensions) {
345 assert(Touched.none() &&
"Bitset already initialized");
346 for (
auto &
F : Features) {
347 bool IsNegated =
F[0] ==
'-';
356 NonExtensions.push_back(
F);
361 std::vector<StringRef> Features;
362 toLLVMFeatureList(Features);
static unsigned checkArchVersion(llvm::StringRef Arch)
const llvm::AArch64::ExtensionInfo & lookupExtensionByID(llvm::AArch64::ArchExtKind ExtID)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
Analysis containing CSE Info
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static cl::opt< std::set< SPIRV::Extension::Extension >, false, SPIRVExtensionsParser > Extensions("spirv-ext", cl::desc("Specify list of enabled SPIR-V extensions"))
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
constexpr bool test(unsigned I) const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
StringRef - 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
empty - 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
size - 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.
bool isX18ReservedByDefault(const Triple &TT)
StringRef getArchExtFeature(StringRef ArchExt)
std::optional< ExtensionInfo > parseArchExtension(StringRef Extension)
std::optional< CpuInfo > parseCpu(StringRef Name)
const ArchInfo * parseArch(StringRef Arch)
const ArchInfo * getArchForCpu(StringRef CPU)
void fillValidCPUArchList(SmallVectorImpl< StringRef > &Values)
const ExtensionInfo & getExtensionByID(ArchExtKind(ExtID))
void printEnabledExtensions(const std::set< StringRef > &EnabledFeatureNames)
std::optional< FMVInfo > parseFMVExtension(StringRef Extension)
const std::vector< FMVInfo > & getFMVInfo()
void PrintSupportedExtensions()
std::optional< ExtensionInfo > targetFeatureToExtension(StringRef TargetFeature)
StringRef resolveCPUAlias(StringRef CPU)
bool getExtensionFeatures(const AArch64::ExtensionBitset &Extensions, std::vector< StringRef > &Features)
unsigned getFMVPriority(ArrayRef< StringRef > Features)
uint64_t getCpuSupportsMask(ArrayRef< StringRef > Features)
StringRef getCanonicalArchName(StringRef Arch)
MArch is expected to be of the form (arm|thumb)?(eb)?(v.
StringRef getArchSynonym(StringRef Arch)
Converts e.g. "armv8" -> "armv8-a".
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
raw_fd_ostream & outs()
This returns a reference to a raw_fd_ostream for standard output.
void sort(IteratorTy Start, IteratorTy End)
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.
AArch64::ExtensionBitset DefaultExts
static std::optional< ArchInfo > findBySubArch(StringRef SubArch)
AArch64::ExtensionBitset getImpliedExtensions() const
bool parseModifier(StringRef Modifier, const bool AllowNoDashForm=false)
void addCPUDefaults(const CpuInfo &CPU)
void enable(ArchExtKind E)
void disable(ArchExtKind E)
void addArchDefaults(const ArchInfo &Arch)
void reconstructFromParsedFeatures(const std::vector< std::string > &Features, std::vector< std::string > &NonExtensions)