From 9a2ae85e6726c2bf9495cd72c4fbf95f305524f5 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Thu, 7 Apr 2016 23:31:58 +0000 Subject: [PATCH] [RegisterBankInfo] Add print and dump method to the InstructionMapping helper class. llvm-svn: 265747 --- llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h | 13 +++++++++++++ llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 16 ++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 9dafcc0..0a810da 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -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 RegisterBankInfo::ValueMapping &ValMapping) { 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 diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index 262459f..f3bf169 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -447,3 +447,19 @@ void RegisterBankInfo::InstructionMapping::verify( 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 << '}'; + } +} -- 2.7.4