LLVM  17.0.0git
RegAllocPriorityAdvisor.h
Go to the documentation of this file.
1 //===- RegAllocPriorityAdvisor.h - live ranges priority advisor -*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLVM_CODEGEN_REGALLOCPRIORITYADVISOR_H
10 #define LLVM_CODEGEN_REGALLOCPRIORITYADVISOR_H
11 
14 #include "llvm/Pass.h"
15 
16 namespace llvm {
17 
18 class MachineFunction;
19 class VirtRegMap;
20 class RAGreedy;
21 
22 /// Interface to the priority advisor, which is responsible for prioritizing
23 /// live ranges.
25 public:
28  virtual ~RegAllocPriorityAdvisor() = default;
29 
30  /// Find the priority value for a live range. A float value is used since ML
31  /// prefers it.
32  virtual unsigned getPriority(const LiveInterval &LI) const = 0;
33 
35  SlotIndexes *const Indexes);
36 
37 protected:
38  const RAGreedy &RA;
40  VirtRegMap *const VRM;
42  const TargetRegisterInfo *const TRI;
47 };
48 
50 public:
52  SlotIndexes *const Indexes)
54 
55 private:
56  unsigned getPriority(const LiveInterval &LI) const override;
57 };
58 
60 public:
62 
64  : ImmutablePass(ID), Mode(Mode){};
65  static char ID;
66 
67  /// Get an advisor for the given context (i.e. machine function, etc)
68  virtual std::unique_ptr<RegAllocPriorityAdvisor>
69  getAdvisor(const MachineFunction &MF, const RAGreedy &RA) = 0;
70  AdvisorMode getAdvisorMode() const { return Mode; }
71  virtual void logRewardIfNeeded(const MachineFunction &MF,
72  llvm::function_ref<float()> GetReward){};
73 
74 protected:
75  // This analysis preserves everything, and subclasses may have additional
76  // requirements.
77  void getAnalysisUsage(AnalysisUsage &AU) const override {
78  AU.setPreservesAll();
79  }
80 
81 private:
82  StringRef getPassName() const override;
83  const AdvisorMode Mode;
84 };
85 
86 /// Specialization for the API used by the analysis infrastructure to create
87 /// an instance of the priority advisor.
89 
90 RegAllocPriorityAdvisorAnalysis *createReleaseModePriorityAdvisor();
91 
92 RegAllocPriorityAdvisorAnalysis *createDevelopmentModePriorityAdvisor();
93 
94 } // namespace llvm
95 
96 #endif // LLVM_CODEGEN_REGALLOCPRIORITYADVISOR_H
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::RegAllocPriorityAdvisor::RegAllocPriorityAdvisor
RegAllocPriorityAdvisor(const RegAllocPriorityAdvisor &)=delete
Pass
print lazy value Lazy Value Info Printer Pass
Definition: LazyValueInfo.cpp:2066
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:279
llvm::MachineRegisterInfo
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Definition: MachineRegisterInfo.h:51
Pass.h
llvm::RegAllocPriorityAdvisor::getPriority
virtual unsigned getPriority(const LiveInterval &LI) const =0
Find the priority value for a live range.
llvm::RegAllocPriorityAdvisorAnalysis::RegAllocPriorityAdvisorAnalysis
RegAllocPriorityAdvisorAnalysis(AdvisorMode Mode)
Definition: RegAllocPriorityAdvisor.h:63
llvm::RegAllocPriorityAdvisor::RegClassPriorityTrumpsGlobalness
const bool RegClassPriorityTrumpsGlobalness
Definition: RegAllocPriorityAdvisor.h:45
llvm::VirtRegMap
Definition: VirtRegMap.h:33
llvm::RAGreedy
Definition: RegAllocGreedy.h:61
llvm::RegAllocPriorityAdvisorAnalysis::logRewardIfNeeded
virtual void logRewardIfNeeded(const MachineFunction &MF, llvm::function_ref< float()> GetReward)
Definition: RegAllocPriorityAdvisor.h:71
llvm::callDefaultCtor< RegAllocPriorityAdvisorAnalysis >
Pass * callDefaultCtor< RegAllocPriorityAdvisorAnalysis >()
Specialization for the API used by the analysis infrastructure to create an instance of the priority ...
Definition: RegAllocPriorityAdvisor.cpp:72
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:236
llvm::RegAllocPriorityAdvisor
Interface to the priority advisor, which is responsible for prioritizing live ranges.
Definition: RegAllocPriorityAdvisor.h:24
llvm::DefaultPriorityAdvisor::DefaultPriorityAdvisor
DefaultPriorityAdvisor(const MachineFunction &MF, const RAGreedy &RA, SlotIndexes *const Indexes)
Definition: RegAllocPriorityAdvisor.h:51
llvm::RegAllocPriorityAdvisorAnalysis::getAdvisor
virtual std::unique_ptr< RegAllocPriorityAdvisor > getAdvisor(const MachineFunction &MF, const RAGreedy &RA)=0
Get an advisor for the given context (i.e. machine function, etc)
llvm::RegAllocPriorityAdvisor::Indexes
SlotIndexes *const Indexes
Definition: RegAllocPriorityAdvisor.h:44
llvm::createDevelopmentModePriorityAdvisor
RegAllocPriorityAdvisorAnalysis * createDevelopmentModePriorityAdvisor()
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::RegAllocPriorityAdvisor::~RegAllocPriorityAdvisor
virtual ~RegAllocPriorityAdvisor()=default
llvm::RegAllocPriorityAdvisor::RegClassInfo
const RegisterClassInfo & RegClassInfo
Definition: RegAllocPriorityAdvisor.h:43
llvm::RegAllocPriorityAdvisorAnalysis::getAdvisorMode
AdvisorMode getAdvisorMode() const
Definition: RegAllocPriorityAdvisor.h:70
llvm::SlotIndexes
SlotIndexes pass.
Definition: SlotIndexes.h:319
llvm::RegAllocPriorityAdvisorAnalysis::AdvisorMode
AdvisorMode
Definition: RegAllocPriorityAdvisor.h:61
llvm::LiveInterval
LiveInterval - This class represents the liveness of a register, or stack slot.
Definition: LiveInterval.h:686
llvm::RegAllocPriorityAdvisor::MRI
MachineRegisterInfo *const MRI
Definition: RegAllocPriorityAdvisor.h:41
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::RegAllocPriorityAdvisor::RA
const RAGreedy & RA
Definition: RegAllocPriorityAdvisor.h:38
llvm::function_ref
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLFunctionalExtras.h:36
llvm::RegAllocPriorityAdvisorAnalysis::AdvisorMode::Default
@ Default
llvm::RegAllocPriorityAdvisorAnalysis::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: RegAllocPriorityAdvisor.h:77
llvm::RegAllocPriorityAdvisor::LIS
LiveIntervals *const LIS
Definition: RegAllocPriorityAdvisor.h:39
llvm::createReleaseModePriorityAdvisor
RegAllocPriorityAdvisorAnalysis * createReleaseModePriorityAdvisor()
Definition: MLRegallocPriorityAdvisor.cpp:260
llvm::RegAllocPriorityAdvisor::TRI
const TargetRegisterInfo *const TRI
Definition: RegAllocPriorityAdvisor.h:42
llvm::RegisterClassInfo
Definition: RegisterClassInfo.h:29
llvm::RegAllocPriorityAdvisorAnalysis::AdvisorMode::Release
@ Release
RA
SI optimize exec mask operations pre RA
Definition: SIOptimizeExecMaskingPreRA.cpp:71
llvm::MachineFunction
Definition: MachineFunction.h:258
llvm::DefaultPriorityAdvisor
Definition: RegAllocPriorityAdvisor.h:49
llvm::RegAllocPriorityAdvisorAnalysis
Definition: RegAllocPriorityAdvisor.h:59
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::RegAllocPriorityAdvisorAnalysis::AdvisorMode::Development
@ Development
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::RegAllocPriorityAdvisorAnalysis::ID
static char ID
Definition: RegAllocPriorityAdvisor.h:64
llvm::LiveIntervals
Definition: LiveIntervals.h:53
llvm::RegAllocPriorityAdvisor::ReverseLocalAssignment
const bool ReverseLocalAssignment
Definition: RegAllocPriorityAdvisor.h:46
RegAllocEvictionAdvisor.h
llvm::RegAllocPriorityAdvisor::VRM
VirtRegMap *const VRM
Definition: RegAllocPriorityAdvisor.h:40
SlotIndexes.h