Commit 3e859b73 by Jim Stichnoth

Subzero: For filetype=asm, don't print a blank line for pseudo instrs.

Originally, for each non-deleted instruction, CfgNode::emit() would call the virtual Inst::emit() and then print a newline (also printing end-of-live-range info as necessary). This resulted in clumsy blank lines in the asm output, corresponding to non target specific pseudo instructions such as FakeDef, FakeUse, FakeKill. We change this so that CfgNode::emit() only prints a newline for an InstTarget subclass, or if any end-of-live-range text was printed. If a high-level instruction still wants to emit something in a comment, it's responsible for printing its own newline. BUG= none TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --sz=--asm-verbose=0 TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --sz=--asm-verbose=1 TEST= ./pydir/szbuild_spec2k.py -O2 --force -v --filetype=asm --target=arm32 R=kschimpf@google.com Review URL: https://codereview.chromium.org/1431353003 .
parent f66a85b2
...@@ -954,11 +954,13 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node, ...@@ -954,11 +954,13 @@ void emitRegisterUsage(Ostream &Str, const Cfg *Func, const CfgNode *Node,
Str << "\n"; Str << "\n";
} }
void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, /// Returns true if some text was emitted - in which case the caller definitely
/// needs to emit a newline character.
bool emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
CfgVector<SizeT> &LiveRegCount) { CfgVector<SizeT> &LiveRegCount) {
bool Printed = false;
if (!BuildDefs::dump()) if (!BuildDefs::dump())
return; return Printed;
bool First = true;
Variable *Dest = Instr->getDest(); Variable *Dest = Instr->getDest();
// Normally we increment the live count for the dest register. But we // Normally we increment the live count for the dest register. But we
// shouldn't if the instruction's IsDestRedefined flag is set, because this // shouldn't if the instruction's IsDestRedefined flag is set, because this
...@@ -976,14 +978,15 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr, ...@@ -976,14 +978,15 @@ void emitLiveRangesEnded(Ostream &Str, const Cfg *Func, const Inst *Instr,
ShouldReport = false; ShouldReport = false;
} }
if (ShouldReport) { if (ShouldReport) {
if (First) if (Printed)
Str << " \t# END=";
else
Str << ","; Str << ",";
else
Str << " \t# END=";
Var->emit(Func); Var->emit(Func);
First = false; Printed = true;
} }
} }
return Printed;
} }
void updateStats(Cfg *Func, const Inst *I) { void updateStats(Cfg *Func, const Inst *I) {
...@@ -1068,9 +1071,11 @@ void CfgNode::emit(Cfg *Func) const { ...@@ -1068,9 +1071,11 @@ void CfgNode::emit(Cfg *Func) const {
continue; continue;
} }
I.emit(Func); I.emit(Func);
bool Printed = false;
if (DecorateAsm) if (DecorateAsm)
emitLiveRangesEnded(Str, Func, &I, LiveRegCount); Printed = emitLiveRangesEnded(Str, Func, &I, LiveRegCount);
Str << "\n"; if (Printed || llvm::isa<InstTarget>(&I))
Str << "\n";
updateStats(Func, &I); updateStats(Func, &I);
} }
if (DecorateAsm) { if (DecorateAsm) {
......
...@@ -896,6 +896,7 @@ void InstFakeDef::emit(const Cfg *Func) const { ...@@ -896,6 +896,7 @@ void InstFakeDef::emit(const Cfg *Func) const {
getDest()->emit(Func); getDest()->emit(Func);
Str << " = def.pseudo "; Str << " = def.pseudo ";
emitSources(Func); emitSources(Func);
Str << "\n";
} }
void InstFakeDef::dump(const Cfg *Func) const { void InstFakeDef::dump(const Cfg *Func) const {
......
...@@ -1088,6 +1088,7 @@ void InstARM32Pop::emit(const Cfg *Func) const { ...@@ -1088,6 +1088,7 @@ void InstARM32Pop::emit(const Cfg *Func) const {
} }
} }
Ostream &Str = Func->getContext()->getStrEmit(); Ostream &Str = Func->getContext()->getStrEmit();
bool NeedNewline = false;
if (IntegerCount != 0) { if (IntegerCount != 0) {
Str << "\t" Str << "\t"
<< "pop" << "pop"
...@@ -1101,19 +1102,26 @@ void InstARM32Pop::emit(const Cfg *Func) const { ...@@ -1101,19 +1102,26 @@ void InstARM32Pop::emit(const Cfg *Func) const {
PrintComma = true; PrintComma = true;
} }
} }
Str << "}\n"; Str << "}";
NeedNewline = true;
} }
for (const Operand *Op : Dests) { for (const Operand *Op : Dests) {
if (isScalarIntegerType(Op->getType())) if (isScalarIntegerType(Op->getType()))
continue; continue;
startNextInst(Func); startNextInst(Func);
if (NeedNewline) {
Str << "\n";
NeedNewline = false;
}
Str << "\t" Str << "\t"
<< "vpop" << "vpop"
<< "\t{"; << "\t{";
Op->emit(Func); Op->emit(Func);
Str << "}\n"; Str << "}";
NeedNewline = true;
} }
assert(NeedNewline); // caller will add the newline
} }
void InstARM32Pop::emitIAS(const Cfg *Func) const { void InstARM32Pop::emitIAS(const Cfg *Func) const {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment