summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-05-20 00:55:51 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-05-20 00:55:51 +0000
commit9b176c730949926d55498d428f1ce93b8a8254d6 (patch)
treeb69c9ab411682d8203f1726b506c71b51b08fa94 /include
parent68fddfc32f73df49524be08bd2fd86ebc705e662 (diff)
[RegBankSelect] Refactor the code to split the repairing and mapping of
an instruction. Use the previously introduced RepairingPlacement class to split the code computing the repairing placement from the code doing the actual placement. That way, we will be able to consider different placement and then, only apply the best one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270168 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/GlobalISel/RegBankSelect.h47
1 files changed, 38 insertions, 9 deletions
diff --git a/include/llvm/CodeGen/GlobalISel/RegBankSelect.h b/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
index 40c0b74c863..028fe95d80c 100644
--- a/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
+++ b/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
@@ -468,31 +468,60 @@ private:
bool &OnlyAssign) const;
/// Insert repairing code for \p Reg as specified by \p ValMapping.
- /// The repairing code is inserted before \p DefUseMI if \p IsDef is false
- /// and after otherwise.
+ /// The repairing placement is specified by \p RepairPt.
+ /// \p NewVRegs contains all the registers required to remap \p Reg.
+ /// In other words, the number of registers in NewVRegs must be equal
+ /// to ValMapping.BreakDown.size().
+ ///
/// The transformation could be sketched as:
/// \code
/// ... = op Reg
/// \endcode
/// Becomes
/// \code
- /// <returned reg> = COPY Reg
+ /// <NewRegs> = COPY or extract Reg
/// ... = op Reg
/// \endcode
///
- /// \note This is the responsability of the caller to replace \p Reg
- /// by the returned register.
+ /// and
+ /// \code
+ /// Reg = op ...
+ /// \endcode
+ /// Becomes
+ /// \code
+ /// Reg = op ...
+ /// Reg = COPY or build_sequence <NewRegs>
+ /// \endcode
+ ///
+ /// \pre NewVRegs.size() == ValMapping.BreakDown.size()
///
- /// \return The register of the properly mapped value.
- unsigned repairReg(unsigned Reg,
- const RegisterBankInfo::ValueMapping &ValMapping,
- MachineInstr &DefUseMI, bool IsDef);
+ /// \note The caller is supposed to do the rewriting of op if need be.
+ /// I.e., Reg = op ... => <NewRegs> = NewOp ...
+ void repairReg(
+ MachineOperand &MO, const RegisterBankInfo::ValueMapping &ValMapping,
+ RegBankSelect::RepairingPlacement &RepairPt,
+ const iterator_range<SmallVectorImpl<unsigned>::iterator> &NewVRegs);
/// Set the insertion point of the MIRBuilder to a safe point
/// to insert instructions before (\p Before == true) or after
/// \p InsertPt.
void setSafeInsertionPoint(MachineInstr &InsertPt, bool Before);
+ /// Compute the cost of mapping \p MI with \p InstrMapping and
+ /// compute the repairing placement for such mapping in \p
+ /// RepairPts.
+ MappingCost
+ computeMapping(MachineInstr &MI,
+ const RegisterBankInfo::InstructionMapping &InstrMapping,
+ SmallVectorImpl<RepairingPlacement> &RepairPts);
+
+ /// Apply \p Mapping to \p MI. \p RepairPts represents the different
+ /// mapping action that need to happen for the mapping to be
+ /// applied.
+ void applyMapping(MachineInstr &MI,
+ const RegisterBankInfo::InstructionMapping &InstrMapping,
+ SmallVectorImpl<RepairingPlacement> &RepairPts);
+
public:
// Ctor, nothing fancy.
RegBankSelect();