aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen
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
commitbef8768bd0576eec0470a80e3039cd5d1fd50c6b (patch)
treecdbbfbd8dc140331cb27e6ee91ae5350a4fc9b05 /lib/CodeGen
parent76c4d7696c1eb566d53467a76024c5fdadd448e4 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77740 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen')
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 077d72e93d..e19631fb42 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/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 {