summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-05-20 00:42:57 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-05-20 00:42:57 +0000
commit0d77da4ef808c8e06b26dd3cc3595e8dcd94c14d (patch)
treefe09873f47836b889cf52de933a7884df385d6bc
parent78d947b4f59fd12f370e5ab132a36aeb5e6d3bfd (diff)
downloadbcm5719-llvm-0d77da4ef808c8e06b26dd3cc3595e8dcd94c14d.tar.gz
bcm5719-llvm-0d77da4ef808c8e06b26dd3cc3595e8dcd94c14d.zip
[RegBankSelect] Refactor assignmentMatch to avoid testing the current
register bank twice. Prior to this change, we were checking if the assignment for the current machine operand was matching, then we would check if the mismatch requires to insert repair code. We actually already have this information from the first check, so just pass it along. NFCI. llvm-svn: 270166
-rw-r--r--llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h6
-rw-r--r--llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp14
2 files changed, 15 insertions, 5 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h b/llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
index 80ecd2f2f44..95e1560839f 100644
--- a/llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
+++ b/llvm/include/llvm/CodeGen/GlobalISel/RegBankSelect.h
@@ -164,8 +164,12 @@ private:
void init(MachineFunction &MF);
/// Check if \p Reg is already assigned what is described by \p ValMapping.
+ /// \p OnlyAssign == true means that \p Reg just needs to be assigned a
+ /// register bank. I.e., no repairing is necessary to have the
+ /// assignment match.
bool assignmentMatch(unsigned Reg,
- const RegisterBankInfo::ValueMapping &ValMapping) const;
+ const RegisterBankInfo::ValueMapping &ValMapping,
+ 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
diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
index 2bd1534d722..76442ad278a 100644
--- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp
@@ -41,7 +41,10 @@ void RegBankSelect::init(MachineFunction &MF) {
}
bool RegBankSelect::assignmentMatch(
- unsigned Reg, const RegisterBankInfo::ValueMapping &ValMapping) const {
+ unsigned Reg, const RegisterBankInfo::ValueMapping &ValMapping,
+ bool &OnlyAssign) const {
+ // By default we assume we will have to repair something.
+ OnlyAssign = false;
// Each part of a break down needs to end up in a different register.
// In other word, Reg assignement does not match.
if (ValMapping.BreakDown.size() > 1)
@@ -49,6 +52,9 @@ bool RegBankSelect::assignmentMatch(
const RegisterBank *CurRegBank = RBI->getRegBank(Reg, *MRI, *TRI);
const RegisterBank *DesiredRegBrank = ValMapping.BreakDown[0].RegBank;
+ // Reg is free of assignment, a simple assignment will make the
+ // register bank to match.
+ OnlyAssign = CurRegBank == nullptr;
DEBUG(dbgs() << "Does assignment already match: ";
if (CurRegBank) dbgs() << *CurRegBank; else dbgs() << "none";
dbgs() << " against ";
@@ -194,7 +200,8 @@ void RegBankSelect::assignInstr(MachineInstr &MI) {
const RegisterBankInfo::ValueMapping &ValMapping =
DefaultMapping.getOperandMapping(OpIdx);
// If Reg is already properly mapped, move on.
- if (assignmentMatch(Reg, ValMapping))
+ bool OnlyAssign;
+ if (assignmentMatch(Reg, ValMapping, OnlyAssign))
continue;
// For uses, we may need to create a new temporary.
@@ -210,8 +217,7 @@ void RegBankSelect::assignInstr(MachineInstr &MI) {
// Therefore, create a new temporary for Reg.
assert(ValMapping.BreakDown.size() == 1 &&
"Support for complex break down not supported yet");
- if (TargetRegisterInfo::isPhysicalRegister(Reg) ||
- MRI->getRegClassOrRegBank(Reg)) {
+ if (!OnlyAssign) {
if (!MO.isDef() && MI.isPHI()) {
// Phis are already copies, so there is nothing to repair.
// Note: This will not hold when we support break downs with
OpenPOWER on IntegriCloud