1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[RegisterBankInfo] Add print and dump method to the InstructionMapping

helper class.

llvm-svn: 265747
This commit is contained in:
Quentin Colombet 2016-04-07 23:31:58 +00:00
parent 980ab75040
commit d8b8e21c6f
2 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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 << '}';
}
}