[llvm-mca] Strip leading tabs and spaces from instruction strings before printing. NFC

llvm-svn: 332361
This commit is contained in:
Andrea Di Biagio 2018-05-15 15:18:05 +00:00
parent 787a350021
commit a7c3c45267
3 changed files with 54 additions and 11 deletions

View File

@ -25,11 +25,14 @@ void InstructionInfoView::printView(raw_ostream &OS) const {
const MCSchedModel &SM = STI.getSchedModel();
unsigned Instructions = Source.size();
std::string Instruction;
raw_string_ostream InstrStream(Instruction);
TempStream << "\n\nInstruction Info:\n";
TempStream << "[1]: #uOps\n[2]: Latency\n[3]: RThroughput\n"
<< "[4]: MayLoad\n[5]: MayStore\n[6]: HasSideEffects\n\n";
TempStream << "[1] [2] [3] [4] [5] [6]\tInstructions:\n";
TempStream << "[1] [2] [3] [4] [5] [6] Instructions:\n";
for (unsigned I = 0, E = Instructions; I < E; ++I) {
const MCInst &Inst = Source.getMCInstFromIndex(I);
const MCInstrDesc &MCDesc = MCII.get(Inst.getOpcode());
@ -65,8 +68,15 @@ void InstructionInfoView::printView(raw_ostream &OS) const {
TempStream << (MCDesc.mayLoad() ? " * " : " ");
TempStream << (MCDesc.mayStore() ? " * " : " ");
TempStream << (MCDesc.hasUnmodeledSideEffects() ? " * " : " ");
MCIP.printInst(&Inst, TempStream, "", STI);
TempStream << '\n';
MCIP.printInst(&Inst, InstrStream, "", STI);
InstrStream.flush();
// Consume any tabs or spaces at the beginning of the string.
StringRef Str(Instruction);
Str = Str.ltrim();
TempStream << " " << Str << '\n';
Instruction = "";
}
TempStream.flush();

View File

@ -144,7 +144,10 @@ void ResourcePressureView::printResourcePressurePerInstruction(
TempStream << "\n\nResource pressure by instruction:\n";
printColumnNames(TempStream, STI.getSchedModel());
TempStream << "\tInstructions:\n";
TempStream << "Instructions:\n";
std::string Instruction;
raw_string_ostream InstrStream(Instruction);
for (unsigned I = 0, E = Source.size(); I < E; ++I) {
for (unsigned J = 0; J < NumResourceUnits; ++J) {
@ -152,8 +155,16 @@ void ResourcePressureView::printResourcePressurePerInstruction(
printResourcePressure(TempStream, Usage / Executions);
}
MCIP.printInst(&Source.getMCInstFromIndex(I), TempStream, "", STI);
TempStream << '\n';
MCIP.printInst(&Source.getMCInstFromIndex(I), InstrStream, "", STI);
InstrStream.flush();
StringRef Str(Instruction);
// Remove any tabs or spaces at the beginning of the instruction.
Str = Str.ltrim();
TempStream << Str << '\n';
Instruction = "";
TempStream.flush();
OS << Buffer;
Buffer = "";

View File

@ -133,13 +133,25 @@ void TimelineView::printAverageWaitTimes(raw_ostream &OS) const {
<< "[3]: Average time elapsed from WB until retire stage\n\n";
TempStream << " [0] [1] [2] [3]\n";
// Use a different string stream for the instruction.
std::string Instruction;
raw_string_ostream InstrStream(Instruction);
for (unsigned I = 0, E = WaitTime.size(); I < E; ++I) {
printWaitTimeEntry(TempStream, WaitTime[I], I);
// Append the instruction info at the end of the line.
const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
MCIP.printInst(&Inst, TempStream, "", STI);
TempStream << '\n';
MCIP.printInst(&Inst, InstrStream, "", STI);
InstrStream.flush();
// Consume any tabs or spaces at the beginning of the string.
StringRef Str(Instruction);
Str = Str.ltrim();
TempStream << " " << Str << '\n';
TempStream.flush();
Instruction = "";
OS << Buffer;
Buffer = "";
}
@ -210,6 +222,10 @@ void TimelineView::printTimeline(raw_ostream &OS) const {
TempStream.flush();
OS << Buffer;
// Use a different string stream for the instruction.
std::string Instruction;
raw_string_ostream InstrStream(Instruction);
for (unsigned I = 0, E = Timeline.size(); I < E; ++I) {
Buffer = "";
const TimelineViewEntry &Entry = Timeline[I];
@ -221,9 +237,15 @@ void TimelineView::printTimeline(raw_ostream &OS) const {
printTimelineViewEntry(TempStream, Entry, Iteration, SourceIndex);
// Append the instruction info at the end of the line.
const MCInst &Inst = AsmSequence.getMCInstFromIndex(I);
MCIP.printInst(&Inst, TempStream, "", STI);
TempStream << '\n';
MCIP.printInst(&Inst, InstrStream, "", STI);
InstrStream.flush();
// Consume any tabs or spaces at the beginning of the string.
StringRef Str(Instruction);
Str = Str.ltrim();
TempStream << " " << Str << '\n';
TempStream.flush();
Instruction = "";
OS << Buffer;
}
}