LLVM: lib/CodeGen/RegAllocScore.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
24
25using namespace llvm;
26
27namespace llvm {
38}
39
40#define DEBUG_TYPE "regalloc-score"
41
43 CopyCounts += Other.copyCounts();
44 LoadCounts += Other.loadCounts();
45 StoreCounts += Other.storeCounts();
46 LoadStoreCounts += Other.loadStoreCounts();
47 CheapRematCounts += Other.cheapRematCounts();
48 ExpensiveRematCounts += Other.expensiveRematCounts();
49 return *this;
50}
51
60
62 return !(*this == Other);
63}
64
66 double Ret = 0.0;
73
74 return Ret;
75}
76
89
94 IsTriviallyRematerializable) {
96
98 double BlockFreqRelativeToEntrypoint = GetBBFreq(MBB);
100
102 if (MI.isDebugInstr() || MI.isKill() || MI.isInlineAsm()) {
103 continue;
104 }
105 if (MI.isCopy()) {
106 MBBScore.onCopy(BlockFreqRelativeToEntrypoint);
107 } else if (IsTriviallyRematerializable(MI)) {
108 if (MI.getDesc().isAsCheapAsAMove()) {
109 MBBScore.onCheapRemat(BlockFreqRelativeToEntrypoint);
110 } else {
112 }
113 } else if (MI.mayLoad() && MI.mayStore()) {
114 MBBScore.onLoadStore(BlockFreqRelativeToEntrypoint);
115 } else if (MI.mayLoad()) {
116 MBBScore.onLoad(BlockFreqRelativeToEntrypoint);
117 } else if (MI.mayStore()) {
118 MBBScore.onStore(BlockFreqRelativeToEntrypoint);
119 }
120 }
121 Total += MBBScore;
122 }
124}
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
double getBlockFreqRelativeToEntryBlock(const MachineBasicBlock *MBB) const
Compute the frequency of the block, relative to the entry block.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
Representation of each machine instruction.
LLVM_ABI_FOR_TEST bool operator==(const RegAllocScore &Other) const
Definition RegAllocScore.cpp:52
double copyCounts() const
void onLoadStore(double Freq)
RegAllocScore & operator+=(const RegAllocScore &Other)
Definition RegAllocScore.cpp:42
void onCheapRemat(double Freq)
bool operator!=(const RegAllocScore &Other) const
Definition RegAllocScore.cpp:61
double cheapRematCounts() const
void onStore(double Freq)
double storeCounts() const
LLVM_ABI_FOR_TEST double getScore() const
Definition RegAllocScore.cpp:65
void onExpensiveRemat(double Freq)
double expensiveRematCounts() const
double loadStoreCounts() const
double loadCounts() const
bool isReMaterializable(const MachineInstr &MI) const
Return true if the instruction would be materializable at a point in the containing function where al...
virtual const TargetInstrInfo * getInstrInfo() const
An efficient, type-erasing, non-owning reference to a callable.
initializer< Ty > init(const Ty &Val)
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI cl::opt< double > LoadWeight("regalloc-load-weight", cl::init(4.0), cl::Hidden)
LLVM_ABI cl::opt< double > CopyWeight("regalloc-copy-weight", cl::init(0.2), cl::Hidden)
LLVM_ABI cl::opt< double > ExpensiveRematWeight("regalloc-expensive-remat-weight", cl::init(1.0), cl::Hidden)
RegAllocScore calculateRegAllocScore(const MachineFunction &MF, const MachineBlockFrequencyInfo &MBFI)
Calculate a score.
Definition RegAllocScore.cpp:78
LLVM_ABI cl::opt< double > StoreWeight("regalloc-store-weight", cl::init(1.0), cl::Hidden)
LLVM_ABI cl::opt< double > CheapRematWeight("regalloc-cheap-remat-weight", cl::init(0.2), cl::Hidden)