LLVM 24.0.0git
MLRegAllocEvictAdvisor.cpp File Reference

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.

Macros

#define DEBUG_TYPE   "ml-regalloc"
#define RA_EVICT_FEATURES_LIST(M)
#define DecisionName   "index_to_evict"
#define _FEATURE_IDX_SIMPLE(_, name, __, ___)
#define _FEATURE_IDX(A, B, C, D)
#define _RESET(TYPE, NAME, SHAPE, __)
#define _DECL_FEATURES(type, name, shape, _)
#define SET(ID, TYPE, VAL)

Enumerations

enum class  MLGORegAllocModelChoice { Default }

Functions

static std::unique_ptr< MLModelRunnercreateMLGORegAllocModelRunner (LLVMContext &, const std::vector< TensorSpec > &)
 INITIALIZE_PASS (RegAllocScoring, "regallocscoringpass", "Register Allocation Scoring Pass", false, false) namespace

Variables

constexpr bool HaveMLIRLoweringRegAlloc = false
static const MLGORegAllocModelChoice SelectedMLGORegAllocModel
static cl::opt< std::stringInteractiveChannelBaseName ("regalloc-evict-interactive-channel-base", cl::Hidden, cl::desc("Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out"))
static cl::opt< unsignedMaxEvictionCount ("mlregalloc-max-eviction-count", cl::Hidden, cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted"), cl::init(100))
cl::opt< unsignedllvm::EvictInterferenceCutoff

Macro Definition Documentation

◆ _DECL_FEATURES

#define _DECL_FEATURES ( type,
name,
shape,
_ )
Value:
static const char * name
static TensorSpec createSpec(const std::string &Name, const std::vector< int64_t > &Shape, int Port=0)
Definition TensorSpec.h:65

Referenced by INITIALIZE_PASS().

◆ _FEATURE_IDX

#define _FEATURE_IDX ( A,
B,
C,
D )
Value:
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define _FEATURE_IDX_SIMPLE(_, name, __, ___)

Referenced by INITIALIZE_PASS().

◆ _FEATURE_IDX_SIMPLE

#define _FEATURE_IDX_SIMPLE ( _,
name,
__,
___ )
Value:

◆ _RESET

#define _RESET ( TYPE,
NAME,
SHAPE,
__ )
Value:
std::memset(Runner.getTensorUntyped(FeatureIDs::NAME), 0, \
getTotalSize<TYPE>(SHAPE));

Referenced by INITIALIZE_PASS().

◆ DEBUG_TYPE

#define DEBUG_TYPE   "ml-regalloc"

Definition at line 47 of file MLRegAllocEvictAdvisor.cpp.

◆ DecisionName

#define DecisionName   "index_to_evict"

Referenced by INITIALIZE_PASS().

◆ RA_EVICT_FEATURES_LIST

#define RA_EVICT_FEATURES_LIST ( M)

Referenced by INITIALIZE_PASS().

◆ SET

#define SET ( ID,
TYPE,
VAL )
Value:
do { \
Runner->getTensor<TYPE>(FeatureIDs::ID)[Pos] = static_cast<TYPE>(VAL); \
if (!DoNotNormalize.test(FeatureIDs::ID)) \
Largest[FeatureIDs::ID] = \
std::max(Largest[FeatureIDs::ID], static_cast<float>(VAL)); \
} while (false)

Enumeration Type Documentation

◆ MLGORegAllocModelChoice

enum class MLGORegAllocModelChoice
strong
Enumerator
Default 

Definition at line 95 of file MLRegAllocEvictAdvisor.cpp.

Function Documentation

◆ createMLGORegAllocModelRunner()

std::unique_ptr< MLModelRunner > createMLGORegAllocModelRunner ( LLVMContext & ,
const std::vector< TensorSpec > &  )
inlinestatic

Definition at line 99 of file MLRegAllocEvictAdvisor.cpp.

Referenced by INITIALIZE_PASS().

◆ INITIALIZE_PASS()

INITIALIZE_PASS ( RegAllocScoring ,
"regallocscoringpass" ,
"Register Allocation Scoring Pass" ,
false ,
false  )

The ML evictor (commonalities between release and development mode)

This just calls Evaluate on the Runner, but in the development mode case, if we're just capturing the log of the default advisor, it needs to call the latter instead, so we need to pass all the necessary parameters for it. In the development case, it will also log.

Load the features of the given VirtReg (allocated or not) at column Pos, but if that can't be evicted, return false instead.

Common provider for legacy and new pass managers.

Definition at line 172 of file MLRegAllocEvictAdvisor.cpp.

References _DECL_FEATURES, _FEATURE_IDX, _RESET, llvm::AnalysisUsage::addRequired(), llvm::append_range(), assert(), llvm::RegAllocEvictionAdvisor::canEvictHintInterference(), createMLGORegAllocModelRunner(), llvm::createReleaseModeModelRunner(), llvm::TensorSpec::createSpec(), DecisionName, llvm::DecisionSpec, llvm::Pass::doInitialization(), llvm::dyn_cast(), llvm::LLVMContext::emitError(), llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::end(), llvm::FeatureCount, llvm::DenseMapBase< DerivedT, KeyT, ValueT, KeyInfoT, BucketT >::find(), llvm::RegAllocEvictionAdvisorProvider::getAdvisor(), llvm::RegAllocEvictionAdvisorAnalysisLegacy::getAnalysisUsage(), getContext(), llvm::Function::getContext(), llvm::MachineFunction::getFunction(), llvm::MachineFunction::getName(), HaveMLIRLoweringRegAlloc, llvm::Register::id(), llvm::InputFeatures, InteractiveChannelBaseName, llvm::RegAllocEvictionAdvisorAnalysisLegacy::logRewardIfNeeded(), llvm::RegAllocEvictionAdvisorProvider::logRewardIfNeeded(), Loops, llvm::NumberOfInterferences, llvm::PerLiveRangeShape, RA, RA_EVICT_FEATURES_LIST, Reg, llvm::RegAllocEvictionAdvisorAnalysisLegacy::RegAllocEvictionAdvisorAnalysisLegacy(), llvm::RegAllocEvictionAdvisorProvider::RegAllocEvictionAdvisorProvider(), T, and llvm::RegAllocEvictionAdvisor::tryFindEvictionCandidate().

Variable Documentation

◆ HaveMLIRLoweringRegAlloc

bool HaveMLIRLoweringRegAlloc = false
constexpr

Definition at line 94 of file MLRegAllocEvictAdvisor.cpp.

Referenced by INITIALIZE_PASS().

◆ InteractiveChannelBaseName

cl::opt< std::string > InteractiveChannelBaseName("regalloc-evict-interactive-channel-base", cl::Hidden, cl::desc( "Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out")) ( "regalloc-evict-interactive-channel-base" ,
cl::Hidden ,
cl::desc( "Base file path for the interactive mode. The incoming filename should " "have the name <regalloc-evict-interactive-channel-base>.in, while the " "outgoing name should be " "<regalloc-evict-interactive-channel-base>.out")  )
static

◆ MaxEvictionCount

cl::opt< unsigned > MaxEvictionCount("mlregalloc-max-eviction-count", cl::Hidden, cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted"), cl::init(100)) ( "mlregalloc-max-eviction-count" ,
cl::Hidden ,
cl::desc("The maximum number of times a live range can be " "evicted before preventing it from being evicted") ,
cl::init(100)  )
static

◆ SelectedMLGORegAllocModel