Go to the documentation of this file.
15 #ifndef LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
16 #define LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
121 : ResourceUnitMask(UnitMask), NextInSequenceMask(UnitMask),
122 RemovedFromNextInSequence(0) {}
137 const unsigned ProcResourceDescIndex;
193 const int BufferSize;
196 unsigned AvailableSlots;
209 bool isSubResourceReady(
uint64_t SubResMask)
const {
210 return ReadyMask & SubResMask;
233 bool isReady(
unsigned NumUnits = 1)
const;
273 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
274 return AvailableSlots;
284 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
339 std::vector<std::unique_ptr<ResourceState>> Resources;
340 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
343 std::vector<uint64_t> Resource2Groups;
378 unsigned getNumUnits(
uint64_t ResourceID)
const;
382 void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy>
S,
392 unsigned ResourceID) {
393 assert(ResourceID < ProcResID2Mask.size() &&
394 "Invalid resource index in input!");
395 return setCustomStrategyImpl(
std::move(
S), ProcResID2Mask[ResourceID]);
439 for (
const std::unique_ptr<ResourceState> &Resource : Resources)
447 #endif // LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
void releaseBuffer()
Releases a slot in the buffer.
This is an optimization pass for GlobalISel generic memory operations.
void reserveBuffers(uint64_t ConsumedBuffers)
A resource manager for processor resource units and groups.
unsigned resolveResourceMask(uint64_t Mask) const
virtual ~ResourceStrategy()
ResourceStateEvent canBeDispatched(uint64_t ConsumedBuffers) const
unsigned getNumUnits() const
Default resource allocation strategy used by processor resource groups and processor resources with m...
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
void setCustomStrategy(std::unique_ptr< ResourceStrategy > S, unsigned ResourceID)
virtual ~DefaultResourceStrategy()=default
uint64_t getReadyMask() const
bool isReady(unsigned NumUnits=1) const
Returs true if this resource is not reserved, and if there are at least NumUnits available units.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned getProcResourceID() const
bool containsResource(uint64_t ID) const
uint64_t checkAvailability(const InstrDesc &Desc) const
ResourceManager(const MCSchedModel &SM)
uint64_t select(uint64_t ReadyMask) override
Selects a processor resource unit from a ReadyMask.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
bool isADispatchHazard() const
Returns true if this is an in-order dispatch/issue resource.
Resource allocation strategy used by hardware scheduler resources.
void releaseSubResource(uint64_t ID)
uint64_t getResourceMask() const
unsigned countPopulation(T Value)
Count the number of set bits in a value.
Define a kind of processor resource that will be modeled by the scheduler.
std::pair< unsigned, unsigned > BufferUsageEntry
An instruction descriptor.
A processor resource descriptor.
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
uint64_t getProcResUnitMask() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void markSubResourceAsUsed(uint64_t ID)
int getBufferSize() const
@ Unavailable
We know the block is not fully available. This is a fixpoint.
void releaseBuffers(uint64_t ConsumedBuffers)
ResourceState(const MCProcResourceDesc &Desc, unsigned Index, uint64_t Mask)
virtual ~ResourceManager()=default
virtual uint64_t select(uint64_t ReadyMask)=0
Selects a processor resource unit from a ReadyMask.
uint64_t getAvailableProcResUnits() const
void used(uint64_t Mask) override
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
ResourceStrategy()=default
bool reserveBuffer()
Reserve a buffer slot.
void reserveResource(uint64_t ResourceID)
void cycleEvent(SmallVectorImpl< ResourceRef > &ResourcesFreed)
Machine model for scheduling, bundling, and heuristics.
virtual void used(uint64_t ResourceMask)
Called by the ResourceManager when a processor resource group, or a processor resource with multiple ...
DefaultResourceStrategy(uint64_t UnitMask)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void issueInstruction(const InstrDesc &Desc, SmallVectorImpl< std::pair< ResourceRef, ResourceCycles >> &Pipes)
bool isAResourceGroup() const
ResourceStateEvent isBufferAvailable() const
Checks if there is an available slot in the resource buffer.
ResourceStateEvent
Used to notify the internal state of a processor resource.
void releaseResource(uint64_t ResourceID)