llvm.org GIT mirror llvm / 8f4b1ec
the MinPad argument to PadToColumn only really makes sense to be 1, just remove the argument and replace it with 1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79246 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
7 changed file(s) with 59 addition(s) and 61 deletion(s). Raw diff Collapse all Expand all
118118 Scanned = begin();
119119 }
120120
121 /// PadToColumn - Align the output to some column number.
121 /// PadToColumn - Align the output to some column number. If the current
122 /// column is already equal to or more than NewCol, PadToColumn inserts one
123 /// space.
122124 ///
123125 /// \param NewCol - The column to move to.
124 /// \param MinPad - The minimum space to give after the most
125 /// recent I/O, even if the current column + minpad > newcol.
126 ///
127 void PadToColumn(unsigned NewCol, unsigned MinPad = 0);
126 void PadToColumn(unsigned NewCol);
128127
129128 private:
130129 void releaseStream() {
332332 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
333333 << CPI << ':';
334334 if (VerboseAsm) {
335 O.PadToColumn(TAI->getCommentColumn(), 1);
335 O.PadToColumn(TAI->getCommentColumn());
336336 O << TAI->getCommentString() << " constant ";
337337 WriteTypeSymbolic(O, CPE.getType(), MF->getFunction()->getParent());
338338 }
605605
606606 void AsmPrinter::EOL(const std::string &Comment) const {
607607 if (VerboseAsm && !Comment.empty()) {
608 O.PadToColumn(TAI->getCommentColumn(), 1);
608 O.PadToColumn(TAI->getCommentColumn());
609609 O << TAI->getCommentString()
610610 << ' '
611611 << Comment;
615615
616616 void AsmPrinter::EOL(const char* Comment) const {
617617 if (VerboseAsm && *Comment) {
618 O.PadToColumn(TAI->getCommentColumn(), 1);
618 O.PadToColumn(TAI->getCommentColumn());
619619 O << TAI->getCommentString()
620620 << ' '
621621 << Comment;
10191019 if (TAI->getData64bitsDirective(AddrSpace)) {
10201020 O << TAI->getData64bitsDirective(AddrSpace) << i;
10211021 if (VerboseAsm) {
1022 O.PadToColumn(TAI->getCommentColumn(), 1);
1022 O.PadToColumn(TAI->getCommentColumn());
10231023 O << TAI->getCommentString() << " double " << Val;
10241024 }
10251025 O << '\n';
10261026 } else if (TD->isBigEndian()) {
10271027 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
10281028 if (VerboseAsm) {
1029 O.PadToColumn(TAI->getCommentColumn(), 1);
1029 O.PadToColumn(TAI->getCommentColumn());
10301030 O << TAI->getCommentString()
10311031 << " most significant word of double " << Val;
10321032 }
10331033 O << '\n';
10341034 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
10351035 if (VerboseAsm) {
1036 O.PadToColumn(TAI->getCommentColumn(), 1);
1036 O.PadToColumn(TAI->getCommentColumn());
10371037 O << TAI->getCommentString()
10381038 << " least significant word of double " << Val;
10391039 }
10411041 } else {
10421042 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
10431043 if (VerboseAsm) {
1044 O.PadToColumn(TAI->getCommentColumn(), 1);
1044 O.PadToColumn(TAI->getCommentColumn());
10451045 O << TAI->getCommentString()
10461046 << " least significant word of double " << Val;
10471047 }
10481048 O << '\n';
10491049 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
10501050 if (VerboseAsm) {
1051 O.PadToColumn(TAI->getCommentColumn(), 1);
1051 O.PadToColumn(TAI->getCommentColumn());
10521052 O << TAI->getCommentString()
10531053 << " most significant word of double " << Val;
10541054 }
10601060 O << TAI->getData32bitsDirective(AddrSpace)
10611061 << CFP->getValueAPF().bitcastToAPInt().getZExtValue();
10621062 if (VerboseAsm) {
1063 O.PadToColumn(TAI->getCommentColumn(), 1);
1063 O.PadToColumn(TAI->getCommentColumn());
10641064 O << TAI->getCommentString() << " float " << Val;
10651065 }
10661066 O << '\n';
10781078 if (TD->isBigEndian()) {
10791079 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
10801080 if (VerboseAsm) {
1081 O.PadToColumn(TAI->getCommentColumn(), 1);
1081 O.PadToColumn(TAI->getCommentColumn());
10821082 O << TAI->getCommentString()
10831083 << " most significant halfword of x86_fp80 ~"
10841084 << DoubleVal.convertToDouble();
10861086 O << '\n';
10871087 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
10881088 if (VerboseAsm) {
1089 O.PadToColumn(TAI->getCommentColumn(), 1);
1089 O.PadToColumn(TAI->getCommentColumn());
10901090 O << TAI->getCommentString() << " next halfword";
10911091 }
10921092 O << '\n';
10931093 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
10941094 if (VerboseAsm) {
1095 O.PadToColumn(TAI->getCommentColumn(), 1);
1095 O.PadToColumn(TAI->getCommentColumn());
10961096 O << TAI->getCommentString() << " next halfword";
10971097 }
10981098 O << '\n';
10991099 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
11001100 if (VerboseAsm) {
1101 O.PadToColumn(TAI->getCommentColumn(), 1);
1101 O.PadToColumn(TAI->getCommentColumn());
11021102 O << TAI->getCommentString() << " next halfword";
11031103 }
11041104 O << '\n';
11051105 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
11061106 if (VerboseAsm) {
1107 O.PadToColumn(TAI->getCommentColumn(), 1);
1107 O.PadToColumn(TAI->getCommentColumn());
11081108 O << TAI->getCommentString()
11091109 << " least significant halfword";
11101110 }
11121112 } else {
11131113 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
11141114 if (VerboseAsm) {
1115 O.PadToColumn(TAI->getCommentColumn(), 1);
1115 O.PadToColumn(TAI->getCommentColumn());
11161116 O << TAI->getCommentString()
11171117 << " least significant halfword of x86_fp80 ~"
11181118 << DoubleVal.convertToDouble();
11201120 O << '\n';
11211121 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
11221122 if (VerboseAsm) {
1123 O.PadToColumn(TAI->getCommentColumn(), 1);
1123 O.PadToColumn(TAI->getCommentColumn());
11241124 O << TAI->getCommentString()
11251125 << " next halfword";
11261126 }
11271127 O << '\n';
11281128 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
11291129 if (VerboseAsm) {
1130 O.PadToColumn(TAI->getCommentColumn(), 1);
1130 O.PadToColumn(TAI->getCommentColumn());
11311131 O << TAI->getCommentString()
11321132 << " next halfword";
11331133 }
11341134 O << '\n';
11351135 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
11361136 if (VerboseAsm) {
1137 O.PadToColumn(TAI->getCommentColumn(), 1);
1137 O.PadToColumn(TAI->getCommentColumn());
11381138 O << TAI->getCommentString()
11391139 << " next halfword";
11401140 }
11411141 O << '\n';
11421142 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
11431143 if (VerboseAsm) {
1144 O.PadToColumn(TAI->getCommentColumn(), 1);
1144 O.PadToColumn(TAI->getCommentColumn());
11451145 O << TAI->getCommentString()
11461146 << " most significant halfword";
11471147 }
11581158 if (TD->isBigEndian()) {
11591159 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
11601160 if (VerboseAsm) {
1161 O.PadToColumn(TAI->getCommentColumn(), 1);
1161 O.PadToColumn(TAI->getCommentColumn());
11621162 O << TAI->getCommentString()
11631163 << " most significant word of ppc_fp128";
11641164 }
11651165 O << '\n';
11661166 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
11671167 if (VerboseAsm) {
1168 O.PadToColumn(TAI->getCommentColumn(), 1);
1168 O.PadToColumn(TAI->getCommentColumn());
11691169 O << TAI->getCommentString()
11701170 << " next word";
11711171 }
11721172 O << '\n';
11731173 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
11741174 if (VerboseAsm) {
1175 O.PadToColumn(TAI->getCommentColumn(), 1);
1175 O.PadToColumn(TAI->getCommentColumn());
11761176 O << TAI->getCommentString()
11771177 << " next word";
11781178 }
11791179 O << '\n';
11801180 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
11811181 if (VerboseAsm) {
1182 O.PadToColumn(TAI->getCommentColumn(), 1);
1182 O.PadToColumn(TAI->getCommentColumn());
11831183 O << TAI->getCommentString()
11841184 << " least significant word";
11851185 }
11871187 } else {
11881188 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
11891189 if (VerboseAsm) {
1190 O.PadToColumn(TAI->getCommentColumn(), 1);
1190 O.PadToColumn(TAI->getCommentColumn());
11911191 O << TAI->getCommentString()
11921192 << " least significant word of ppc_fp128";
11931193 }
11941194 O << '\n';
11951195 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
11961196 if (VerboseAsm) {
1197 O.PadToColumn(TAI->getCommentColumn(), 1);
1197 O.PadToColumn(TAI->getCommentColumn());
11981198 O << TAI->getCommentString()
11991199 << " next word";
12001200 }
12011201 O << '\n';
12021202 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
12031203 if (VerboseAsm) {
1204 O.PadToColumn(TAI->getCommentColumn(), 1);
1204 O.PadToColumn(TAI->getCommentColumn());
12051205 O << TAI->getCommentString()
12061206 << " next word";
12071207 }
12081208 O << '\n';
12091209 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
12101210 if (VerboseAsm) {
1211 O.PadToColumn(TAI->getCommentColumn(), 1);
1211 O.PadToColumn(TAI->getCommentColumn());
12121212 O << TAI->getCommentString()
12131213 << " most significant word";
12141214 }
12411241 else if (TD->isBigEndian()) {
12421242 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
12431243 if (VerboseAsm) {
1244 O.PadToColumn(TAI->getCommentColumn(), 1);
1244 O.PadToColumn(TAI->getCommentColumn());
12451245 O << TAI->getCommentString()
12461246 << " most significant half of i64 " << Val;
12471247 }
12481248 O << '\n';
12491249 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
12501250 if (VerboseAsm) {
1251 O.PadToColumn(TAI->getCommentColumn(), 1);
1251 O.PadToColumn(TAI->getCommentColumn());
12521252 O << TAI->getCommentString()
12531253 << " least significant half of i64 " << Val;
12541254 }
12561256 } else {
12571257 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
12581258 if (VerboseAsm) {
1259 O.PadToColumn(TAI->getCommentColumn(), 1);
1259 O.PadToColumn(TAI->getCommentColumn());
12601260 O << TAI->getCommentString()
12611261 << " least significant half of i64 " << Val;
12621262 }
12631263 O << '\n';
12641264 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
12651265 if (VerboseAsm) {
1266 O.PadToColumn(TAI->getCommentColumn(), 1);
1266 O.PadToColumn(TAI->getCommentColumn());
12671267 O << TAI->getCommentString()
12681268 << " most significant half of i64 " << Val;
12691269 }
13071307 if (const ConstantInt *CI = dyn_cast(CV)) {
13081308 SmallString<40> S;
13091309 CI->getValue().toStringUnsigned(S, 16);
1310 O.PadToColumn(TAI->getCommentColumn(), 1);
1310 O.PadToColumn(TAI->getCommentColumn());
13111311 O << TAI->getCommentString() << " 0x" << S.c_str();
13121312 }
13131313 }
15731573 /// that is an implicit def.
15741574 void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
15751575 if (VerboseAsm) {
1576 O.PadToColumn(TAI->getCommentColumn(), 1);
1576 O.PadToColumn(TAI->getCommentColumn());
15771577 O << TAI->getCommentString() << " implicit-def: "
15781578 << TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
15791579 }
16341634 if (printComment) {
16351635 if (const BasicBlock *BB = MBB->getBasicBlock())
16361636 if (BB->hasName()) {
1637 O.PadToColumn(TAI->getCommentColumn(), 1);
1637 O.PadToColumn(TAI->getCommentColumn());
16381638 O << TAI->getCommentString() << ' ';
16391639 WriteAsOperand(O, BB, /*PrintType=*/false);
16401640 }
17681768
17691769 DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
17701770
1771 // Print source line info
1772 O.PadToColumn(TAI->getCommentColumn(), 1);
1771 // Print source line info.
1772 O.PadToColumn(TAI->getCommentColumn());
17731773 O << TAI->getCommentString() << " SrcLine ";
17741774 if (DLT.CompileUnit->hasInitializer()) {
17751775 Constant *Name = DLT.CompileUnit->getInitializer();
17901790 DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
17911791
17921792 // Print source line info
1793 O.PadToColumn(TAI->getCommentColumn(), 1);
1793 O.PadToColumn(TAI->getCommentColumn());
17941794 O << TAI->getCommentString() << " SrcLine ";
17951795 if (DLT.CompileUnit->hasInitializer()) {
17961796 Constant *Name = DLT.CompileUnit->getInitializer();
18161816 if (loop) {
18171817 // Print a newline after bb# annotation.
18181818 O << "\n";
1819 O.PadToColumn(TAI->getCommentColumn(), 1);
1819 O.PadToColumn(TAI->getCommentColumn());
18201820 O << TAI->getCommentString() << " Loop Depth " << loop->getLoopDepth()
18211821 << '\n';
18221822
1823 O.PadToColumn(TAI->getCommentColumn(), 1);
1823 O.PadToColumn(TAI->getCommentColumn());
18241824
18251825 MachineBasicBlock *Header = loop->getHeader();
18261826 assert(Header && "No header for loop");
18361836
18371837 if (loop->empty()) {
18381838 O << '\n';
1839 O.PadToColumn(TAI->getCommentColumn(), 1);
1839 O.PadToColumn(TAI->getCommentColumn());
18401840 O << TAI->getCommentString() << " Inner Loop";
18411841 }
18421842
18481848 assert(Header && "No header for loop");
18491849
18501850 O << '\n';
1851 O.PadToColumn(TAI->getCommentColumn(), 1);
1851 O.PadToColumn(TAI->getCommentColumn());
18521852 O << TAI->getCommentString() << Indent(CurLoop->getLoopDepth()-1)
18531853 << " Inside Loop BB" << getFunctionNumber() << "_"
18541854 << Header->getNumber() << " Depth " << CurLoop->getLoopDepth();
18671867 assert(Header && "No header for loop");
18681868
18691869 O << '\n';
1870 O.PadToColumn(TAI->getCommentColumn(), 1);
1870 O.PadToColumn(TAI->getCommentColumn());
18711871
18721872 O << TAI->getCommentString() << Indent((*cl)->getLoopDepth()-1)
18731873 << " Child Loop BB" << getFunctionNumber() << "_"
5050 /// \param MinPad - The minimum space to give after the most recent
5151 /// I/O, even if the current column + minpad > newcol.
5252 ///
53 void formatted_raw_ostream::PadToColumn(unsigned NewCol, unsigned MinPad) {
53 void formatted_raw_ostream::PadToColumn(unsigned NewCol) {
5454 // Figure out what's in the buffer and add it to the column count.
5555 ComputeColumn();
5656
5757 // Output spaces until we reach the desired column.
5858 unsigned num = NewCol - ColumnScanned;
59 if (NewCol < ColumnScanned || num < MinPad)
60 num = MinPad;
59 if (NewCol < ColumnScanned || num < 1)
60 num = 1;
6161
6262 // Keep a buffer of spaces handy to speed up processing.
6363 const char *Spaces = " "
6464 " ";
6565
6666 assert(num < MAX_COLUMN_PAD && "Unexpectedly large column padding");
67
6867 write(Spaces, num);
6968 }
7069
216216
217217 O << CurrentFnName << ':';
218218 if (VerboseAsm) {
219 O.PadToColumn(TAI->getCommentColumn(), 1);
219 O.PadToColumn(TAI->getCommentColumn());
220220 O << TAI->getCommentString() << ' ';
221221 WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
222222 }
920920 EmitAlignment(Align, GVar);
921921 O << name << ":";
922922 if (VerboseAsm) {
923 O.PadToColumn(TAI->getCommentColumn(), 1);
923 O.PadToColumn(TAI->getCommentColumn());
924924 O << TAI->getCommentString() << ' ';
925925 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
926926 }
942942 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
943943 }
944944 if (VerboseAsm) {
945 O.PadToColumn(TAI->getCommentColumn(), 1);
945 O.PadToColumn(TAI->getCommentColumn());
946946 O << TAI->getCommentString() << ' ';
947947 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
948948 }
986986 EmitAlignment(Align, GVar);
987987 O << name << ":";
988988 if (VerboseAsm){
989 O.PadToColumn(TAI->getCommentColumn(), 1);
989 O.PadToColumn(TAI->getCommentColumn());
990990 O << TAI->getCommentString() << ' ';
991991 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
992992 }
523523
524524 O << name << ":";
525525 if (VerboseAsm)
526 O.PadToColumn(TAI->getCommentColumn(), 1);
526 O.PadToColumn(TAI->getCommentColumn());
527527 O << TAI->getCommentString()
528528 << " " << GV->getName();
529529 O << '\n';
16891689 }
16901690
16911691 if (BB->getParent() == 0) {
1692 Out.PadToColumn(50, 1);
1692 Out.PadToColumn(50);
16931693 Out << "; Error: Block without parent!";
16941694 } else if (BB != &BB->getParent()->getEntryBlock()) { // Not the entry block?
16951695 // Output predecessors for the block...
1696 Out.PadToColumn(50, 1);
1696 Out.PadToColumn(50);
16971697 Out << ";";
16981698 pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB);
16991699
17281728 ///
17291729 void AssemblyWriter::printInfoComment(const Value &V) {
17301730 if (V.getType() != Type::getVoidTy(V.getContext())) {
1731 Out.PadToColumn(50, 1);
1731 Out.PadToColumn(50);
17321732 Out << "; <";
17331733 TypePrinter.print(V.getType(), Out);
17341734 Out << "> [#uses=" << V.getNumUses() << ']'; // Output # uses
176176 CurColumn++ * OperandSpacing;
177177 Operands.push_back(
178178 AsmWriterOperand("O.PadToColumn(" +
179 utostr(DestColumn) + ",1);\n",
179 utostr(DestColumn) + ");\n",
180180 AsmWriterOperand::isLiteralStatementOperand));
181181 }
182182 break;
210210 unsigned DestColumn = FirstOperandColumn +
211211 CurColumn++ * OperandSpacing;
212212 Operands.push_back(
213 AsmWriterOperand("O.PadToColumn(" + utostr(DestColumn) + ", 1);\n",
213 AsmWriterOperand("O.PadToColumn(" + utostr(DestColumn) + ");\n",
214214 AsmWriterOperand::isLiteralStatementOperand));
215215 break;
216216 } else if (std::string("${|}\\").find(AsmString[DollarPos+1])