15#ifndef LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
16#define LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
49 ResourceStrategy(
const ResourceStrategy &) =
delete;
50 ResourceStrategy &operator=(
const ResourceStrategy &) =
delete;
122 : ResourceUnitMask(UnitMask), NextInSequenceMask(UnitMask),
123 RemovedFromNextInSequence(0) {}
138 const unsigned ProcResourceDescIndex;
200 const int BufferSize;
203 unsigned AvailableSlots;
214 bool isSubResourceReady(
uint64_t SubResMask)
const {
215 return ReadyMask & SubResMask;
221 float ReservationStationScaleFactor);
223 unsigned getProcResourceID()
const {
return ProcResourceDescIndex; }
224 uint64_t getResourceMask()
const {
return ResourceMask; }
225 uint64_t getReadyMask()
const {
return ReadyMask; }
226 int getBufferSize()
const {
return BufferSize; }
228 bool isBuffered()
const {
return BufferSize > 0; }
229 bool isInOrder()
const {
return BufferSize == 1; }
232 bool isADispatchHazard()
const {
return BufferSize == 0; }
240 LLVM_ABI bool isReady(
unsigned NumUnits = 1)
const;
244 bool isAResourceGroup()
const {
return IsAGroup; }
246 bool containsResource(
uint64_t ID)
const {
return ResourceMask &
ID; }
258 unsigned getNumUnits()
const {
259 return isAResourceGroup() ? 1U :
llvm::popcount(ResourceSizeMask);
277 bool reserveBuffer() {
282 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
283 return AvailableSlots;
287 void releaseBuffer() {
293 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
310typedef std::pair<unsigned, unsigned> BufferUsageEntry;
348 std::vector<std::unique_ptr<ResourceState>>
Resources;
349 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
352 std::vector<uint64_t> Resource2Groups;
387 unsigned getNumUnits(
uint64_t ResourceID)
const;
391 LLVM_ABI void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy> S,
396 float ReservationStationScaleFactor);
401 void setCustomStrategy(std::unique_ptr<ResourceStrategy> S,
402 unsigned ResourceID) {
404 "Invalid resource index in input!");
405 return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
410 LLVM_ABI ResourceStateEvent canBeDispatched(
uint64_t ConsumedBuffers)
const;
438 uint64_t getProcResUnitMask()
const {
return ProcResUnitMask; }
439 uint64_t getAvailableProcResUnits()
const {
return AvailableProcResUnits; }
441 using ResourceWithCycles = std::pair<ResourceRef, ReleaseAtCycles>;
443 void issueInstruction(
const InstrDesc &Desc,
444 SmallVectorImpl<ResourceWithCycles> &Pipes) {
445 if (
Desc.HasPartiallyOverlappingGroups)
446 return issueInstructionImpl(Desc, Pipes);
448 return fastIssueInstruction(Desc, Pipes);
458 fastIssueInstruction(
const InstrDesc &Desc,
459 SmallVectorImpl<ResourceWithCycles> &Pipes);
467 issueInstructionImpl(
const InstrDesc &Desc,
468 SmallVectorImpl<ResourceWithCycles> &Pipes);
470 LLVM_ABI void cycleEvent(SmallVectorImpl<ResourceRef> &ResourcesFreed);
474 for (
const std::unique_ptr<ResourceState> &Resource :
Resources)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
DXIL Remove Unused Resources
This file defines the DenseMap class.
@ Unavailable
We know the block is not fully available. This is a fixpoint.
Move duplicate certain instructions close to their use
This file defines abstractions used by the Pipeline to model register reads, register writes and inst...
This file defines the SmallVector class.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
DefaultResourceStrategy(uint64_t UnitMask)
void used(uint64_t Mask) override
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
~DefaultResourceStrategy() override=default
uint64_t select(uint64_t ReadyMask) override
Selects a processor resource unit from a ReadyMask.
A processor resource descriptor.
virtual uint64_t select(uint64_t ReadyMask)=0
Selects a processor resource unit from a ReadyMask.
virtual ~ResourceStrategy()
virtual void used(uint64_t ResourceMask)
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
ResourceStrategy()=default
Helper functions used by various pipeline components.
char InstructionError< T >::ID
ResourceStateEvent
Used to notify the internal state of a processor resource.
std::pair< uint64_t, uint64_t > ResourceRef
This is an optimization pass for GlobalISel generic memory operations.
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
constexpr int popcount(T Value) noexcept
Count the number of set bits in a value.
Define a kind of processor resource that will be modeled by the scheduler.
Machine model for scheduling, bundling, and heuristics.