43 while (Implies.
any()) {
46 if (Implies.
test(FE.Value))
47 Implied |= FE.Implies.getAsBitset();
51 Implies = Implied & ~NewBits;
62 if (FE.Implies.getAsBitset().test(
Value)) {
72 "Feature flags should start with '+' or '-'");
81 Bits.set(FeatureEntry->
Value);
86 Bits.reset(FeatureEntry->
Value);
92 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target"
93 <<
" (ignoring feature)\n";
100 for (
auto &
I : Table)
101 MaxLen = std::max(MaxLen, std::strlen(
I.key()));
108 MaxLen = std::max(MaxLen,
I.size());
116 static bool PrintOnce =
false;
126 errs() <<
"Available CPUs for this target:\n\n";
131 if (CPUName ==
"apple-latest")
133 errs() <<
format(
" %-*s - Select the %s processor.\n", MaxCPULen,
134 CPUName.str().c_str(), CPUName.str().c_str());
139 errs() <<
"Available features for this target:\n\n";
140 for (
auto &Feature : FeatTable)
141 errs() <<
format(
" %-*s - %s.\n", MaxFeatLen, Feature.key(),
145 errs() <<
"Use +feature to enable a feature, or -feature to disable it.\n"
146 "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
155 static bool PrintOnce =
false;
161 errs() <<
"Available CPUs for this target:\n\n";
166 if (CPU ==
"apple-latest")
168 errs() <<
"\t" << CPU <<
"\n";
172 errs() <<
"Use -mcpu or -mtune to specify the target's processor.\n"
173 "For example, clang --target=aarch64-unknown-linux-gnu "
174 "-mcpu=cortex-a35\n";
196 Help(ProcNames, ProcFeatures);
199 else if (!CPU.empty()) {
207 errs() <<
"'" << CPU <<
"' is not a recognized processor for this target"
208 <<
" (ignoring processor)\n";
212 if (!TuneCPU.
empty()) {
219 }
else if (TuneCPU != CPU) {
220 errs() <<
"'" << TuneCPU <<
"' is not a recognized processor for this "
221 <<
"target (ignoring processor)\n";
226 for (
const std::string &Feature : Features.
getFeatures()) {
228 if (Feature ==
"+help")
229 Help(ProcNames, ProcFeatures);
230 else if (Feature ==
"+cpuhelp")
242 getFeatures(*
this, CPU, TuneCPU, FS, ProcNames, ProcDesc, ProcFeatures);
243 FeatureString = std::string(FS);
245 if (!TuneCPU.empty())
254 getFeatures(*
this, CPU, TuneCPU, FS, ProcNames, ProcDesc, ProcFeatures);
255 FeatureString = std::string(FS);
263 const InstrStage *IS,
const unsigned *OC,
const unsigned *
FP)
264 : TargetTriple(TT), CPU(
std::string(
C)), TuneCPU(
std::string(TC)),
265 ProcNames(PN), ProcFeatures(PF), ProcDesc(PD), ProcSchedModels(PSM),
266 WriteProcResTable(WPR), WriteLatencyTable(WL), ReadAdvanceTable(
RA),
267 Stages(IS), OperandCycles(OC), ForwardingPaths(
FP) {
272 FeatureBits.
flip(FB);
289 for (
unsigned I = 0, E = FB.
size();
I < E;
I++) {
291 FeatureBits.reset(
I);
304 if (FeatureBits.test(FeatureEntry->
Value)) {
305 FeatureBits.reset(FeatureEntry->
Value);
309 FeatureBits.set(FeatureEntry->
Value);
316 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target"
317 <<
" (ignoring feature)\n";
330 return all_of(
T.getFeatures(), [
this](
const std::string &
F) {
331 assert(SubtargetFeatures::hasFlag(F) &&
332 "Feature flags should start with '+' or '-'");
333 const SubtargetFeatureKV *FeatureEntry =
334 Find(SubtargetFeatures::StripFlag(F), ProcFeatures);
336 reportFatalInternalError(Twine(
"'") + F +
337 "' is not a recognized feature for this target");
340 return FeatureBits.test(FeatureEntry->Value) ==
347 bool ShouldBeEnabled =
true;
349 ShouldBeEnabled =
false;
354 "' is not a recognized feature for this target");
357 return FeatureBits.
test(FeatureEntry->
Value) == ShouldBeEnabled;
361class FeatureExpressionParser {
363 const FeatureBitset &FeatureBits;
368 FeatureExpressionParser(StringRef Expr,
const FeatureBitset &FeatureBits,
370 : Expr(Expr), FeatureBits(FeatureBits), ProcFeatures(ProcFeatures) {}
374 if (Pos != Expr.
size())
381 if (Pos == Expr.
size() || Expr[Pos] !=
C)
390 bool RHS = parseAnd();
397 bool Result = parsePrimary();
399 bool RHS = parsePrimary();
405 bool parsePrimary() {
427 if (FeatureExpr.
empty())
431 "spaces are not allowed in target feature expressions");
433 FeatureExpressionParser Parser(FeatureExpr, FeatureBits, ProcFeatures);
434 return Parser.parse();
439 "Processor machine model table is not sorted");
447 <<
"' is not a recognized processor for this target"
448 <<
" (ignoring processor)\n";
465std::vector<const SubtargetFeatureKV *>
467 std::vector<const SubtargetFeatureKV *> EnabledFeatures;
469 if (FeatureBits.test(FeatureKV.Value))
470 EnabledFeatures.push_back(&FeatureKV);
471 return EnabledFeatures;
478std::optional<unsigned>
483std::optional<unsigned>
501 unsigned NumStridedMemAccesses,
502 unsigned NumPrefetches,
503 bool HasCall)
const {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static llvm::Error parse(GsymDataExtractor &Data, uint64_t BaseAddr, LineEntryCallback const &Callback)
static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature, ArrayRef< SubtargetFeatureKV > FeatureTable)
static const T * Find(StringRef S, ArrayRef< T > A)
Find KV in array using binary search.
static void cpuHelp(StringTable CPUNames)
Display help for mcpu choices only.
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, StringTable ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static bool hasFeature(StringRef Feature, const FeatureBitset &FeatureBits, ArrayRef< SubtargetFeatureKV > ProcFeatures)
static void Help(StringTable CPUNames, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature and mcpu choices.
static size_t getLongestEntryLength(ArrayRef< SubtargetFeatureKV > Table)
Return the length of the longest entry in the table.
static void SetImpliedBits(FeatureBitset &Bits, FeatureBitset Implies, ArrayRef< SubtargetFeatureKV > FeatureTable)
For each feature that is (transitively) implied by this feature, set it.
static void ClearImpliedBits(FeatureBitset &Bits, unsigned Value, ArrayRef< SubtargetFeatureKV > FeatureTable)
For each feature that (transitively) implies this feature, clear it.
SI optimize exec mask operations pre RA
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
Check if the array is empty.
const FeatureBitset & getAsBitset() const
Container class for subtarget features.
constexpr bool test(unsigned I) const
constexpr FeatureBitset & flip(unsigned I)
constexpr size_t size() const
Itinerary data supplied by a subtarget to be used by a target.
Generic base class for all target subtargets.
virtual unsigned getCacheLineSize() const
Return the target cache line size in bytes.
bool checkFeatures(StringRef FS) const
Check whether the subtarget features are enabled/disabled as per the provided string,...
virtual std::optional< unsigned > getCacheSize(unsigned Level) const
Return the cache size in bytes for the given level of cache.
virtual bool shouldPrefetchAddressSpace(unsigned AS) const
const MCSchedModel & getSchedModelForCPU(StringRef CPU) const
Get the machine model of a CPU.
std::vector< const SubtargetFeatureKV * > getEnabledProcessorFeatures() const
Return the list of processor features currently enabled.
virtual unsigned getMinPrefetchStride(unsigned NumMemAccesses, unsigned NumStridedMemAccesses, unsigned NumPrefetches, bool HasCall) const
Return the minimum stride necessary to trigger software prefetching.
virtual bool enableWritePrefetching() const
virtual unsigned getMaxPrefetchIterationsAhead() const
Return the maximum prefetch distance in terms of loop iterations.
const FeatureBitset & ToggleFeature(uint64_t FB)
Toggle a feature and return the re-computed feature bits.
virtual unsigned getPrefetchDistance() const
Return the preferred prefetch distance in terms of instructions.
virtual std::optional< unsigned > getCacheAssociativity(unsigned Level) const
Return the cache associatvity for the given level of cache.
InstrItineraryData getInstrItineraryForCPU(StringRef CPU) const
Get scheduling itinerary of a CPU.
const FeatureBitset & ApplyFeatureFlag(StringRef FS)
Apply a feature flag and return the re-computed feature bits, including all feature bits implied by t...
void setDefaultFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Set the features to the default for the given CPU and TuneCPU, with ano appended feature string.
void InitMCProcessorInfo(StringRef CPU, StringRef TuneCPU, StringRef FS)
Initialize the scheduling model and feature bits.
const FeatureBitset & ClearFeatureBitsTransitively(const FeatureBitset &FB)
bool checkFeatureExpression(StringRef FeatureExpr) const
Check whether the current subtarget satisfies a target feature expression.
void initInstrItins(InstrItineraryData &InstrItins) const
Initialize an InstrItineraryData instance.
const MCSchedModel & getSchedModel() const
Get the machine model for this subtarget's CPU.
const FeatureBitset & SetFeatureBitsTransitively(const FeatureBitset &FB)
Set/clear additional feature bits, including all other bits they imply.
Represent a constant reference to a string, i.e.
static constexpr size_t npos
constexpr bool empty() const
Check if the string is empty.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
Get the string size.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
bool consume_front(char Prefix)
Returns true if this StringRef has the given prefix and removes that prefix.
A table of densely packed, null-terminated strings indexed by offset.
Manages the enabling and disabling of subtarget specific features.
const std::vector< std::string > & getFeatures() const
Returns the vector of individual subtarget features.
static bool hasFlag(StringRef Feature)
Determine if a feature has a flag; '+' or '-'.
static StringRef StripFlag(StringRef Feature)
Return string stripped of flag.
static bool isEnabled(StringRef Feature)
Return true if enable flag; '+'.
Triple - Helper class for working with autoconf configuration names.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI void reportFatalInternalError(Error Err)
Report a fatal error that indicates a bug in LLVM.
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
ArrayRef(const T &OneElt) -> ArrayRef< T >
Implement std::hash so that hash_code can be used in STL containers.
These values represent a non-pipelined step in the execution of an instruction.
Specify the number of cycles allowed after instruction issue before a particular use operand reads it...
Machine model for scheduling, bundling, and heuristics.
static LLVM_ABI const MCSchedModel Default
Returns the default initialized model.
Specify the latency in cpu cycles for a particular scheduling class and def index.
Identify one of the processor resource kinds consumed by a particular scheduling class for the specif...
Used to provide key value pairs for feature and CPU bit flags.
unsigned Value
K-V integer value.
FeatureBitArray Implies
K-V bit mask.
Used to provide key value pairs for feature and CPU bit flags.
FeatureBitArray Implies
K-V bit mask.
FeatureBitArray TuneImplies
K-V bit mask.