Use PadToColumn instead of tabs for aligning comments. Fix one place

that emitted unnecessary whitespace outside of VerboseAsm mode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2009-08-12 18:32:22 +00:00
parent 1a8f36e3ce
commit a12e9d751b

View File

@@ -336,8 +336,9 @@ void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
Offset = NewOffset + TM.getTargetData()->getTypeAllocSize(Ty); Offset = NewOffset + TM.getTargetData()->getTypeAllocSize(Ty);
O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
<< CPI << ":\t\t\t\t\t"; << CPI << ':';
if (VerboseAsm) { if (VerboseAsm) {
O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << ' '; O << TAI->getCommentString() << ' ';
WriteTypeSymbolic(O, CPE.getType(), 0); WriteTypeSymbolic(O, CPE.getType(), 0);
} }
@@ -610,8 +611,8 @@ void AsmPrinter::EOL() const {
void AsmPrinter::EOL(const std::string &Comment) const { void AsmPrinter::EOL(const std::string &Comment) const {
if (VerboseAsm && !Comment.empty()) { if (VerboseAsm && !Comment.empty()) {
O << '\t' O.PadToColumn(TAI->getCommentColumn(), 1);
<< TAI->getCommentString() O << TAI->getCommentString()
<< ' ' << ' '
<< Comment; << Comment;
} }
@@ -620,8 +621,8 @@ void AsmPrinter::EOL(const std::string &Comment) const {
void AsmPrinter::EOL(const char* Comment) const { void AsmPrinter::EOL(const char* Comment) const {
if (VerboseAsm && *Comment) { if (VerboseAsm && *Comment) {
O << '\t' O.PadToColumn(TAI->getCommentColumn(), 1);
<< TAI->getCommentString() O << TAI->getCommentString()
<< ' ' << ' '
<< Comment; << Comment;
} }
@@ -1021,30 +1022,40 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue(); uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (TAI->getData64bitsDirective(AddrSpace)) { if (TAI->getData64bitsDirective(AddrSpace)) {
O << TAI->getData64bitsDirective(AddrSpace) << i; O << TAI->getData64bitsDirective(AddrSpace) << i;
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " double value: " << Val; O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " double value: " << Val;
}
O << '\n'; O << '\n';
} else if (TD->isBigEndian()) { } else if (TD->isBigEndian()) {
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " double most significant word " << Val; << " double most significant word " << Val;
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " double least significant word " << Val; << " double least significant word " << Val;
}
O << '\n'; O << '\n';
} else { } else {
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " double least significant word " << Val; << " double least significant word " << Val;
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " double most significant word " << Val; << " double most significant word " << Val;
}
O << '\n'; O << '\n';
} }
return; return;
@@ -1052,8 +1063,10 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
float Val = CFP->getValueAPF().convertToFloat(); // for comment only float Val = CFP->getValueAPF().convertToFloat(); // for comment only
O << TAI->getData32bitsDirective(AddrSpace) O << TAI->getData32bitsDirective(AddrSpace)
<< CFP->getValueAPF().bitcastToAPInt().getZExtValue(); << CFP->getValueAPF().bitcastToAPInt().getZExtValue();
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " float " << Val; O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " float " << Val;
}
O << '\n'; O << '\n';
return; return;
} else if (CFP->getType() == Type::X86_FP80Ty) { } else if (CFP->getType() == Type::X86_FP80Ty) {
@@ -1068,54 +1081,74 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
&ignored); &ignored);
if (TD->isBigEndian()) { if (TD->isBigEndian()) {
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double most significant halfword of ~" << " long double most significant halfword of ~"
<< DoubleVal.convertToDouble(); << DoubleVal.convertToDouble();
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " long double next halfword"; O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " long double next halfword"; O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " long double next halfword"; O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double least significant halfword"; << " long double least significant halfword";
}
O << '\n'; O << '\n';
} else { } else {
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double least significant halfword of ~" << " long double least significant halfword of ~"
<< DoubleVal.convertToDouble(); << DoubleVal.convertToDouble();
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next halfword"; << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next halfword"; << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next halfword"; << " long double next halfword";
}
O << '\n'; O << '\n';
O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]); O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double most significant halfword"; << " long double most significant halfword";
}
O << '\n'; O << '\n';
} }
EmitZeros(TD->getTypeAllocSize(Type::X86_FP80Ty) - EmitZeros(TD->getTypeAllocSize(Type::X86_FP80Ty) -
@@ -1128,45 +1161,61 @@ void AsmPrinter::EmitGlobalConstantFP(const ConstantFP *CFP,
const uint64_t *p = api.getRawData(); const uint64_t *p = api.getRawData();
if (TD->isBigEndian()) { if (TD->isBigEndian()) {
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double most significant word"; << " long double most significant word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next word"; << " long double next word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next word"; << " long double next word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double least significant word"; << " long double least significant word";
}
O << '\n'; O << '\n';
} else { } else {
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double least significant word"; << " long double least significant word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next word"; << " long double next word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double next word"; << " long double next word";
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32); O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " long double most significant word"; << " long double most significant word";
}
O << '\n'; O << '\n';
} }
return; return;
@@ -1195,25 +1244,33 @@ void AsmPrinter::EmitGlobalConstantLargeInt(const ConstantInt *CI,
O << TAI->getData64bitsDirective(AddrSpace) << Val << '\n'; O << TAI->getData64bitsDirective(AddrSpace) << Val << '\n';
else if (TD->isBigEndian()) { else if (TD->isBigEndian()) {
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " Double-word most significant word " << Val; << " Double-word most significant word " << Val;
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " Double-word least significant word " << Val; << " Double-word least significant word " << Val;
}
O << '\n'; O << '\n';
} else { } else {
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " Double-word least significant word " << Val; << " Double-word least significant word " << Val;
}
O << '\n'; O << '\n';
O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32); O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString()
<< " Double-word most significant word " << Val; << " Double-word most significant word " << Val;
}
O << '\n'; O << '\n';
} }
} }
@@ -1518,10 +1575,12 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
/// printImplicitDef - This method prints the specified machine instruction /// printImplicitDef - This method prints the specified machine instruction
/// that is an implicit def. /// that is an implicit def.
void AsmPrinter::printImplicitDef(const MachineInstr *MI) const { void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
if (VerboseAsm) if (VerboseAsm) {
O << '\t' << TAI->getCommentString() << " implicit-def: " O.PadToColumn(TAI->getCommentColumn(), 1);
O << TAI->getCommentString() << " implicit-def: "
<< TRI->getAsmName(MI->getOperand(0).getReg()) << '\n'; << TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
} }
}
/// printLabel - This method prints a local label used by debug and /// printLabel - This method prints a local label used by debug and
/// exception handling tables. /// exception handling tables.