diff options
author | Mircea Trofin <mtrofin@google.com> | 2021-12-20 19:42:38 -0800 |
---|---|---|
committer | Mircea Trofin <mtrofin@google.com> | 2022-01-04 08:11:49 -0800 |
commit | 64e56f8356416d213bd271c18b766e748a00e095 (patch) | |
tree | 21b00de30f71aa7ed0957b9efc97b2cdd8b3dfee | |
parent | 71059f26d31398d109be057e35bb8c5960d8aaf6 (diff) | |
download | llvm-64e56f8356416d213bd271c18b766e748a00e095.tar.gz |
[NFC] Expose isRematerializable and copyHint from CalcSpillWeights
We need to reuse them for the ML regalloc eviction advisor, as we
'explode' the weight calculation into sub-features.
Differential Revision: https://reviews.llvm.org/D116074
-rw-r--r-- | llvm/include/llvm/CodeGen/CalcSpillWeights.h | 12 | ||||
-rw-r--r-- | llvm/lib/CodeGen/CalcSpillWeights.cpp | 13 |
2 files changed, 19 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/CalcSpillWeights.h b/llvm/include/llvm/CodeGen/CalcSpillWeights.h index 0b6ed079b38e..bfd5bab3d1c0 100644 --- a/llvm/include/llvm/CodeGen/CalcSpillWeights.h +++ b/llvm/include/llvm/CodeGen/CalcSpillWeights.h @@ -80,6 +80,18 @@ class VirtRegMap; /// live intervals. void calculateSpillWeightsAndHints(); + /// Return the preferred allocation register for reg, given a COPY + /// instruction. + static Register copyHint(const MachineInstr *MI, unsigned Reg, + const TargetRegisterInfo &TRI, + const MachineRegisterInfo &MRI); + + /// Determine if all values in LI are rematerializable. + static bool isRematerializable(const LiveInterval &LI, + const LiveIntervals &LIS, + const VirtRegMap &VRM, + const TargetInstrInfo &TII); + protected: /// Helper function for weight calculations. /// (Re)compute LI's spill weight and allocation hint, or, for non null diff --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp b/llvm/lib/CodeGen/CalcSpillWeights.cpp index 5f9982cd155d..84a0e4142bb6 100644 --- a/llvm/lib/CodeGen/CalcSpillWeights.cpp +++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp @@ -43,9 +43,9 @@ void VirtRegAuxInfo::calculateSpillWeightsAndHints() { } // Return the preferred allocation register for reg, given a COPY instruction. -static Register copyHint(const MachineInstr *MI, unsigned Reg, - const TargetRegisterInfo &TRI, - const MachineRegisterInfo &MRI) { +Register VirtRegAuxInfo::copyHint(const MachineInstr *MI, unsigned Reg, + const TargetRegisterInfo &TRI, + const MachineRegisterInfo &MRI) { unsigned Sub, HSub; Register HReg; if (MI->getOperand(0).getReg() == Reg) { @@ -77,9 +77,10 @@ static Register copyHint(const MachineInstr *MI, unsigned Reg, } // Check if all values in LI are rematerializable -static bool isRematerializable(const LiveInterval &LI, const LiveIntervals &LIS, - const VirtRegMap &VRM, - const TargetInstrInfo &TII) { +bool VirtRegAuxInfo::isRematerializable(const LiveInterval &LI, + const LiveIntervals &LIS, + const VirtRegMap &VRM, + const TargetInstrInfo &TII) { Register Reg = LI.reg(); Register Original = VRM.getOriginal(Reg); for (LiveInterval::const_vni_iterator I = LI.vni_begin(), E = LI.vni_end(); |