15#ifndef LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
16#define LLVM_MCA_HARDWAREUNITS_RESOURCEMANAGER_H
122 : ResourceUnitMask(UnitMask), NextInSequenceMask(UnitMask),
123 RemovedFromNextInSequence(0) {}
138 const unsigned ProcResourceDescIndex;
194 const int BufferSize;
197 unsigned AvailableSlots;
210 bool isSubResourceReady(
uint64_t SubResMask)
const {
211 return ReadyMask & SubResMask;
277 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
278 return AvailableSlots;
288 assert(AvailableSlots <=
static_cast<unsigned>(BufferSize));
343 std::vector<std::unique_ptr<ResourceState>> Resources;
344 std::vector<std::unique_ptr<ResourceStrategy>> Strategies;
347 std::vector<uint64_t> Resource2Groups;
382 unsigned getNumUnits(
uint64_t ResourceID)
const;
386 LLVM_ABI void setCustomStrategyImpl(std::unique_ptr<ResourceStrategy> S,
396 unsigned ResourceID) {
398 "Invalid resource index in input!");
399 return setCustomStrategyImpl(std::move(S), ProcResID2Mask[ResourceID]);
439 if (
Desc.HasPartiallyOverlappingGroups)
468 for (
const std::unique_ptr<ResourceState> &Resource : Resources)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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 class consists of common code factored out of the SmallVector class to reduce code duplication b...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Default resource allocation strategy used by processor resource groups and processor resources with m...
DefaultResourceStrategy(uint64_t UnitMask)
virtual ~DefaultResourceStrategy()=default
A resource manager for processor resource units and groups.
LLVM_ABI void reserveBuffers(uint64_t ConsumedBuffers)
void issueInstruction(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
LLVM_ABI void releaseBuffers(uint64_t ConsumedBuffers)
LLVM_ABI void fastIssueInstruction(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
std::pair< ResourceRef, ReleaseAtCycles > ResourceWithCycles
LLVM_ABI void releaseResource(uint64_t ResourceID)
virtual ~ResourceManager()=default
LLVM_ABI void reserveResource(uint64_t ResourceID)
LLVM_ABI void issueInstructionImpl(const InstrDesc &Desc, SmallVectorImpl< ResourceWithCycles > &Pipes)
LLVM_ABI unsigned resolveResourceMask(uint64_t Mask) const
LLVM_ABI void cycleEvent(SmallVectorImpl< ResourceRef > &ResourcesFreed)
uint64_t getProcResUnitMask() const
void setCustomStrategy(std::unique_ptr< ResourceStrategy > S, unsigned ResourceID)
LLVM_ABI ResourceStateEvent canBeDispatched(uint64_t ConsumedBuffers) const
LLVM_ABI uint64_t checkAvailability(const InstrDesc &Desc) const
uint64_t getAvailableProcResUnits() const
A processor resource descriptor.
LLVM_ABI ResourceStateEvent isBufferAvailable() const
Checks if there is an available slot in the resource buffer.
uint64_t getReadyMask() const
void markSubResourceAsUsed(uint64_t ID)
void releaseBuffer()
Releases a slot in the buffer.
unsigned getProcResourceID() const
void releaseSubResource(uint64_t ID)
int getBufferSize() const
bool isADispatchHazard() const
Returns true if this is an in-order dispatch/issue resource.
LLVM_ABI bool isReady(unsigned NumUnits=1) const
Returs true if this resource is not reserved, and if there are at least NumUnits available units.
bool containsResource(uint64_t ID) const
uint64_t getNumReadyUnits() const
unsigned getNumUnits() const
bool reserveBuffer()
Reserve a buffer slot.
uint64_t getResourceMask() const
bool isAResourceGroup() const
Resource allocation strategy used by hardware scheduler resources.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ResourceStateEvent
Used to notify the internal state of a processor resource.
std::pair< uint64_t, uint64_t > ResourceRef
A resource unit identifier.
std::pair< unsigned, unsigned > BufferUsageEntry
This is an optimization pass for GlobalISel generic memory operations.
int popcount(T Value) noexcept
Count the number of set bits in a value.
Description of the encoding of one expression Op.
Define a kind of processor resource that will be modeled by the scheduler.
Machine model for scheduling, bundling, and heuristics.
An instruction descriptor.