31 if (
F ==
A.end() ||
StringRef(
F->Key) != S)
return nullptr;
42 while (Implies.
any()) {
45 if (Implies.
test(FE.Value))
46 Implied |= FE.Implies.getAsBitset();
50 Implies = Implied & ~NewBits;
61 if (FE.Implies.getAsBitset().test(
Value)) {
71 "Feature flags should start with '+' or '-'");
80 Bits.set(FeatureEntry->
Value);
85 Bits.reset(FeatureEntry->
Value);
91 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target"
92 <<
" (ignoring feature)\n";
100 MaxLen = std::max(MaxLen, std::strlen(
I.Key));
107 MaxLen = std::max(MaxLen,
I.size());
116 static bool PrintOnce =
false;
126 errs() <<
"Available CPUs for this target:\n\n";
127 for (
auto &CPUName : CPUNames) {
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, Feature.Desc);
144 errs() <<
"Use +feature to enable a feature, or -feature to disable it.\n"
145 "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
154 static bool PrintOnce =
false;
160 errs() <<
"Available CPUs for this target:\n\n";
161 for (
auto &CPU : CPUNames) {
165 if (CPU ==
"apple-latest")
167 errs() <<
"\t" << CPU <<
"\n";
171 errs() <<
"Use -mcpu or -mtune to specify the target's processor.\n"
172 "For example, clang --target=aarch64-unknown-linux-gnu "
173 "-mcpu=cortex-a35\n";
195 Help(ProcNames, ProcFeatures);
198 else if (!CPU.empty()) {
206 errs() <<
"'" << CPU <<
"' is not a recognized processor for this target"
207 <<
" (ignoring processor)\n";
211 if (!TuneCPU.
empty()) {
218 }
else if (TuneCPU != CPU) {
219 errs() <<
"'" << TuneCPU <<
"' is not a recognized processor for this "
220 <<
"target (ignoring processor)\n";
225 for (
const std::string &Feature : Features.
getFeatures()) {
227 if (Feature ==
"+help")
228 Help(ProcNames, ProcFeatures);
229 else if (Feature ==
"+cpuhelp")
241 getFeatures(*
this, CPU, TuneCPU, FS, ProcNames, ProcDesc, ProcFeatures);
242 FeatureString = std::string(FS);
244 if (!TuneCPU.empty())
253 getFeatures(*
this, CPU, TuneCPU, FS, ProcNames, ProcDesc, ProcFeatures);
254 FeatureString = std::string(FS);
262 const InstrStage *IS,
const unsigned *OC,
const unsigned *
FP)
263 : TargetTriple(TT), CPU(
std::string(
C)), TuneCPU(
std::string(TC)),
264 ProcNames(PN), ProcFeatures(PF), ProcDesc(PD), WriteProcResTable(WPR),
265 WriteLatencyTable(WL), ReadAdvanceTable(
RA), Stages(IS),
266 OperandCycles(OC), ForwardingPaths(
FP) {
271 FeatureBits.
flip(FB);
288 for (
unsigned I = 0, E = FB.
size();
I < E;
I++) {
290 FeatureBits.reset(
I);
303 if (FeatureBits.test(FeatureEntry->
Value)) {
304 FeatureBits.reset(FeatureEntry->
Value);
308 FeatureBits.set(FeatureEntry->
Value);
315 errs() <<
"'" << Feature <<
"' is not a recognized feature for this target"
316 <<
" (ignoring feature)\n";
329 return all_of(
T.getFeatures(), [
this](
const std::string &
F) {
330 assert(SubtargetFeatures::hasFlag(F) &&
331 "Feature flags should start with '+' or '-'");
332 const SubtargetFeatureKV *FeatureEntry =
333 Find(SubtargetFeatures::StripFlag(F), ProcFeatures);
335 report_fatal_error(Twine(
"'") + F +
336 "' is not a recognized feature for this target");
338 return FeatureBits.test(FeatureEntry->Value) ==
339 SubtargetFeatures::isEnabled(F);
345 "Processor machine model table is not sorted");
353 <<
"' is not a recognized processor for this target"
354 <<
" (ignoring processor)\n";
372std::vector<SubtargetFeatureKV>
374 std::vector<SubtargetFeatureKV> EnabledFeatures;
376 return FeatureBits.test(FeatureKV.Value);
378 llvm::copy_if(ProcFeatures, std::back_inserter(EnabledFeatures), IsEnabled);
379 return EnabledFeatures;
386std::optional<unsigned>
391std::optional<unsigned>
409 unsigned NumStridedMemAccesses,
410 unsigned NumPrefetches,
411 bool HasCall)
const {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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 Help(ArrayRef< StringRef > CPUNames, ArrayRef< SubtargetFeatureKV > FeatTable)
Display help for feature and mcpu choices.
static void cpuHelp(ArrayRef< StringRef > CPUNames)
Display help for mcpu choices only.
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.
static FeatureBitset getFeatures(MCSubtargetInfo &STI, StringRef CPU, StringRef TuneCPU, StringRef FS, ArrayRef< StringRef > ProcNames, ArrayRef< SubtargetSubTypeKV > ProcDesc, ArrayRef< SubtargetFeatureKV > ProcFeatures)
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.
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.
std::vector< SubtargetFeatureKV > getEnabledProcessorFeatures() const
Return the list of processor features currently enabled.
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)
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.
constexpr bool empty() const
Check if the string is empty.
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.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
OutputIt copy_if(R &&Range, OutputIt Out, UnaryPredicate P)
Provide wrappers to std::copy_if which take ranges instead of having to pass begin/end explicitly.
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...
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.
const MCSchedModel * SchedModel
FeatureBitArray Implies
K-V bit mask.
FeatureBitArray TuneImplies
K-V bit mask.