[llvm] r265747 - [RegisterBankInfo] Add print and dump method to the InstructionMapping
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 7 16:31:58 PDT 2016
Author: qcolombet
Date: Thu Apr 7 18:31:58 2016
New Revision: 265747
URL: http://llvm.org/viewvc/llvm-project?rev=265747&view=rev
Log:
[RegisterBankInfo] Add print and dump method to the InstructionMapping
helper class.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=265747&r1=265746&r2=265747&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Thu Apr 7 18:31:58 2016
@@ -151,6 +151,12 @@ public:
/// Verifiy that this mapping makes sense for \p MI.
/// \pre \p MI must be connected to a MachineFunction.
void verify(const MachineInstr &MI) const;
+
+ /// Print this on dbgs() stream.
+ void dump() const;
+
+ /// Print this on \p OS;
+ void print(raw_ostream &OS) const;
};
/// Convenient type to represent the alternatives for mapping an
@@ -397,6 +403,13 @@ operator<<(raw_ostream &OS, const Regist
ValMapping.print(OS);
return OS;
}
+
+inline raw_ostream &
+operator<<(raw_ostream &OS,
+ const RegisterBankInfo::InstructionMapping &InstrMapping) {
+ InstrMapping.print(OS);
+ return OS;
+}
} // End namespace llvm.
#endif
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=265747&r1=265746&r2=265747&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Thu Apr 7 18:31:58 2016
@@ -447,3 +447,19 @@ void RegisterBankInfo::InstructionMappin
MOMapping.verify(RegSize);
}
}
+
+void RegisterBankInfo::InstructionMapping::dump() const {
+ print(dbgs());
+ dbgs() << '\n';
+}
+
+void RegisterBankInfo::InstructionMapping::print(raw_ostream &OS) const {
+ OS << "ID: " << getID() << " Cost: " << getCost() << " Mapping: ";
+
+ for (unsigned OpIdx = 0; OpIdx != NumOperands; ++OpIdx) {
+ const ValueMapping &ValMapping = getOperandMapping(OpIdx);
+ if (OpIdx)
+ OS << ", ";
+ OS << "{ Idx: " << OpIdx << " Map: " << ValMapping << '}';
+ }
+}
More information about the llvm-commits
mailing list