summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2009-07-31 21:57:10 +0000
committerDavid Greene <greened@obbligato.org>2009-07-31 21:57:10 +0000
commit81bcae5fda609849a50f1fb4ab323c16d173cba2 (patch)
tree776790dda53f5fdddace3a9d8a6168597718a7d1 /llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
parent9ee33ca28e1606306da77f4dc68ac17dc6081384 (diff)
downloadbcm5719-llvm-81bcae5fda609849a50f1fb4ab323c16d173cba2.tar.gz
bcm5719-llvm-81bcae5fda609849a50f1fb4ab323c16d173cba2.zip
Simplify operand padding by keying off tabs in the asm stream. If
padding is disabled, tabs get replaced by spaces except in the case of the first operand, where the tab is output to line up the operands after the mnemonics. Add some better comments and eliminate redundant code. Fix some testcases to not assume tabs. llvm-svn: 77740
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 077d72e93d9..e19631fb425 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -847,8 +847,28 @@ void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV,
}
O << '\n';
}
-
+/// PadToColumn - This gets called every time a tab is emitted. If
+/// column padding is turned on, we replace the tab with the
+/// appropriate amount of padding. If not, we replace the tab with a
+/// space, except for the first operand so that initial operands are
+/// always lined up by tabs.
+void AsmPrinter::PadToColumn(unsigned Operand) const {
+ if (TAI->getOperandColumn(Operand) > 0) {
+ O.PadToColumn(TAI->getOperandColumn(Operand), 1);
+ }
+ else {
+ if (Operand == 1) {
+ // Emit the tab after the mnemonic.
+ O << '\t';
+ }
+ else {
+ // Replace the tab with a space.
+ O << ' ';
+ }
+ }
+}
+
/// EmitZeros - Emit a block of zeros.
///
void AsmPrinter::EmitZeros(uint64_t NumZeros, unsigned AddrSpace) const {
OpenPOWER on IntegriCloud