llvm.org GIT mirror llvm / cf20ac4
Various AsmWriter output cleanups. Use WriteAsOperand instead of PrintUnmangledNameSafely. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78878 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
10 changed file(s) with 76 addition(s) and 106 deletion(s). Raw diff Collapse all Expand all
338338 << CPI << ':';
339339 if (VerboseAsm) {
340340 O.PadToColumn(TAI->getCommentColumn(), 1);
341 O << TAI->getCommentString() << ' ';
342 WriteTypeSymbolic(O, CPE.getType(), 0);
341 O << TAI->getCommentString() << " constant ";
342 WriteTypeSymbolic(O, CPE.getType(), MF->getFunction()->getParent());
343343 }
344344 O << '\n';
345345 if (CPE.isMachineConstantPoolEntry())
10231023 O << TAI->getData64bitsDirective(AddrSpace) << i;
10241024 if (VerboseAsm) {
10251025 O.PadToColumn(TAI->getCommentColumn(), 1);
1026 O << TAI->getCommentString() << " double value: " << Val;
1026 O << TAI->getCommentString() << " double " << Val;
10271027 }
10281028 O << '\n';
10291029 } else if (TD->isBigEndian()) {
10311031 if (VerboseAsm) {
10321032 O.PadToColumn(TAI->getCommentColumn(), 1);
10331033 O << TAI->getCommentString()
1034 << " double most significant word " << Val;
1034 << " most significant word of double " << Val;
10351035 }
10361036 O << '\n';
10371037 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
10381038 if (VerboseAsm) {
10391039 O.PadToColumn(TAI->getCommentColumn(), 1);
10401040 O << TAI->getCommentString()
1041 << " double least significant word " << Val;
1041 << " least significant word of double " << Val;
10421042 }
10431043 O << '\n';
10441044 } else {
10461046 if (VerboseAsm) {
10471047 O.PadToColumn(TAI->getCommentColumn(), 1);
10481048 O << TAI->getCommentString()
1049 << " double least significant word " << Val;
1049 << " least significant word of double " << Val;
10501050 }
10511051 O << '\n';
10521052 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
10531053 if (VerboseAsm) {
10541054 O.PadToColumn(TAI->getCommentColumn(), 1);
10551055 O << TAI->getCommentString()
1056 << " double most significant word " << Val;
1056 << " most significant word of double " << Val;
10571057 }
10581058 O << '\n';
10591059 }
10831083 if (VerboseAsm) {
10841084 O.PadToColumn(TAI->getCommentColumn(), 1);
10851085 O << TAI->getCommentString()
1086 << " long double most significant halfword of ~"
1086 << " most significant halfword of x86_fp80 ~"
10871087 << DoubleVal.convertToDouble();
10881088 }
10891089 O << '\n';
10901090 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
10911091 if (VerboseAsm) {
10921092 O.PadToColumn(TAI->getCommentColumn(), 1);
1093 O << TAI->getCommentString() << " long double next halfword";
1093 O << TAI->getCommentString() << " next halfword";
10941094 }
10951095 O << '\n';
10961096 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
10971097 if (VerboseAsm) {
10981098 O.PadToColumn(TAI->getCommentColumn(), 1);
1099 O << TAI->getCommentString() << " long double next halfword";
1099 O << TAI->getCommentString() << " next halfword";
11001100 }
11011101 O << '\n';
11021102 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
11031103 if (VerboseAsm) {
11041104 O.PadToColumn(TAI->getCommentColumn(), 1);
1105 O << TAI->getCommentString() << " long double next halfword";
1105 O << TAI->getCommentString() << " next halfword";
11061106 }
11071107 O << '\n';
11081108 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
11091109 if (VerboseAsm) {
11101110 O.PadToColumn(TAI->getCommentColumn(), 1);
11111111 O << TAI->getCommentString()
1112 << " long double least significant halfword";
1112 << " least significant halfword";
11131113 }
11141114 O << '\n';
11151115 } else {
11171117 if (VerboseAsm) {
11181118 O.PadToColumn(TAI->getCommentColumn(), 1);
11191119 O << TAI->getCommentString()
1120 << " long double least significant halfword of ~"
1120 << " least significant halfword of x86_fp80 ~"
11211121 << DoubleVal.convertToDouble();
11221122 }
11231123 O << '\n';
11251125 if (VerboseAsm) {
11261126 O.PadToColumn(TAI->getCommentColumn(), 1);
11271127 O << TAI->getCommentString()
1128 << " long double next halfword";
1128 << " next halfword";
11291129 }
11301130 O << '\n';
11311131 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
11321132 if (VerboseAsm) {
11331133 O.PadToColumn(TAI->getCommentColumn(), 1);
11341134 O << TAI->getCommentString()
1135 << " long double next halfword";
1135 << " next halfword";
11361136 }
11371137 O << '\n';
11381138 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
11391139 if (VerboseAsm) {
11401140 O.PadToColumn(TAI->getCommentColumn(), 1);
11411141 O << TAI->getCommentString()
1142 << " long double next halfword";
1142 << " next halfword";
11431143 }
11441144 O << '\n';
11451145 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
11461146 if (VerboseAsm) {
11471147 O.PadToColumn(TAI->getCommentColumn(), 1);
11481148 O << TAI->getCommentString()
1149 << " long double most significant halfword";
1149 << " most significant halfword";
11501150 }
11511151 O << '\n';
11521152 }
11631163 if (VerboseAsm) {
11641164 O.PadToColumn(TAI->getCommentColumn(), 1);
11651165 O << TAI->getCommentString()
1166 << " long double most significant word";
1166 << " most significant word of ppc_fp128";
11671167 }
11681168 O << '\n';
11691169 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
11701170 if (VerboseAsm) {
11711171 O.PadToColumn(TAI->getCommentColumn(), 1);
11721172 O << TAI->getCommentString()
1173 << " long double next word";
1173 << " next word";
11741174 }
11751175 O << '\n';
11761176 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
11771177 if (VerboseAsm) {
11781178 O.PadToColumn(TAI->getCommentColumn(), 1);
11791179 O << TAI->getCommentString()
1180 << " long double next word";
1180 << " next word";
11811181 }
11821182 O << '\n';
11831183 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
11841184 if (VerboseAsm) {
11851185 O.PadToColumn(TAI->getCommentColumn(), 1);
11861186 O << TAI->getCommentString()
1187 << " long double least significant word";
1187 << " least significant word";
11881188 }
11891189 O << '\n';
11901190 } else {
11921192 if (VerboseAsm) {
11931193 O.PadToColumn(TAI->getCommentColumn(), 1);
11941194 O << TAI->getCommentString()
1195 << " long double least significant word";
1195 << " least significant word of ppc_fp128";
11961196 }
11971197 O << '\n';
11981198 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
11991199 if (VerboseAsm) {
12001200 O.PadToColumn(TAI->getCommentColumn(), 1);
12011201 O << TAI->getCommentString()
1202 << " long double next word";
1202 << " next word";
12031203 }
12041204 O << '\n';
12051205 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
12061206 if (VerboseAsm) {
12071207 O.PadToColumn(TAI->getCommentColumn(), 1);
12081208 O << TAI->getCommentString()
1209 << " long double next word";
1209 << " next word";
12101210 }
12111211 O << '\n';
12121212 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
12131213 if (VerboseAsm) {
12141214 O.PadToColumn(TAI->getCommentColumn(), 1);
12151215 O << TAI->getCommentString()
1216 << " long double most significant word";
1216 << " most significant word";
12171217 }
12181218 O << '\n';
12191219 }
12461246 if (VerboseAsm) {
12471247 O.PadToColumn(TAI->getCommentColumn(), 1);
12481248 O << TAI->getCommentString()
1249 << " Double-word most significant word " << Val;
1249 << " most significant half of i64 " << Val;
12501250 }
12511251 O << '\n';
12521252 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
12531253 if (VerboseAsm) {
12541254 O.PadToColumn(TAI->getCommentColumn(), 1);
12551255 O << TAI->getCommentString()
1256 << " Double-word least significant word " << Val;
1256 << " least significant half of i64 " << Val;
12571257 }
12581258 O << '\n';
12591259 } else {
12611261 if (VerboseAsm) {
12621262 O.PadToColumn(TAI->getCommentColumn(), 1);
12631263 O << TAI->getCommentString()
1264 << " Double-word least significant word " << Val;
1264 << " least significant half of i64 " << Val;
12651265 }
12661266 O << '\n';
12671267 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
12681268 if (VerboseAsm) {
12691269 O.PadToColumn(TAI->getCommentColumn(), 1);
12701270 O << TAI->getCommentString()
1271 << " Double-word most significant word " << Val;
1271 << " most significant half of i64 " << Val;
12721272 }
12731273 O << '\n';
12741274 }
2020 #include "ARMMachineFunctionInfo.h"
2121 #include "llvm/Constants.h"
2222 #include "llvm/Module.h"
23 #include "llvm/Assembly/Writer.h"
2324 #include "llvm/CodeGen/AsmPrinter.h"
2425 #include "llvm/CodeGen/DwarfWriter.h"
2526 #include "llvm/CodeGen/MachineModuleInfo.h"
11271128 return Result;
11281129 }
11291130
1130 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
1131 /// Don't print things like \\n or \\0.
1132 static void PrintUnmangledNameSafely(const Value *V,
1133 formatted_raw_ostream &OS) {
1134 for (StringRef::iterator it = V->getName().begin(),
1135 ie = V->getName().end(); it != ie; ++it)
1136 if (isprint(*it))
1137 OS << *it;
1138 }
1139
11401131 void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
11411132 const TargetData *TD = TM.getTargetData();
11421133
12031194 O << name << ":";
12041195 if (VerboseAsm) {
12051196 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
1206 PrintUnmangledNameSafely(GVar, O);
1197 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12071198 }
12081199 O << '\n';
12091200 EmitGlobalConstant(C);
12261217 }
12271218 if (VerboseAsm) {
12281219 O << "\t\t" << TAI->getCommentString() << " ";
1229 PrintUnmangledNameSafely(GVar, O);
1220 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12301221 }
12311222 O << "\n";
12321223 return;
12641255 O << name << ":";
12651256 if (VerboseAsm) {
12661257 O << "\t\t\t\t" << TAI->getCommentString() << " ";
1267 PrintUnmangledNameSafely(GVar, O);
1258 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12681259 }
12691260 O << "\n";
12701261 if (TAI->hasDotTypeDotSizeDirective())
486486 return Result;
487487 }
488488
489 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
490 /// Don't print things like \\n or \\0.
491 static void PrintUnmangledNameSafely(const Value *V,
492 formatted_raw_ostream &OS) {
493 for (StringRef::iterator it = V->getName().begin(),
494 ie = V->getName().end(); it != ie; ++it)
495 if (isprint(*it))
496 OS << *it;
497 }
498
499489 /*!
500490 Emit a global variable according to its section, alignment, etc.
501491
540530 O << ".comm " << name << ',' << Size;
541531 }
542532 O << "\t\t" << TAI->getCommentString() << " '";
543 PrintUnmangledNameSafely(GVar, O);
533 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
544534 O << "'\n";
545535 return;
546536 }
574564
575565 EmitAlignment(Align, GVar);
576566 O << name << ":\t\t\t\t" << TAI->getCommentString() << " '";
577 PrintUnmangledNameSafely(GVar, O);
567 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
578568 O << "'\n";
579569
580570 EmitGlobalConstant(C);
645645 return false;
646646 }
647647
648 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
649 /// Don't print things like \\n or \\0.
650 static void PrintUnmangledNameSafely(const Value *V,
651 formatted_raw_ostream &OS) {
652 for (StringRef::iterator it = V->getName().begin(),
653 ie = V->getName().end(); it != ie; ++it)
654 if (isprint(*it))
655 OS << *it;
656 }
657
658648 void PPCLinuxAsmPrinter::PrintGlobalVariable(const GlobalVariable *GVar) {
659649 const TargetData *TD = TM.getTargetData();
660650
694684 }
695685 if (VerboseAsm) {
696686 O << "\t\t" << TAI->getCommentString() << " '";
697 PrintUnmangledNameSafely(GVar, O);
687 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
698688 O << "'";
699689 }
700690 O << '\n';
731721 O << name << ":";
732722 if (VerboseAsm) {
733723 O << "\t\t\t\t" << TAI->getCommentString() << " '";
734 PrintUnmangledNameSafely(GVar, O);
724 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
735725 O << "'";
736726 }
737727 O << '\n';
915905 O << name << ":";
916906 if (VerboseAsm) {
917907 O << "\t\t\t\t" << TAI->getCommentString() << " ";
918 PrintUnmangledNameSafely(GVar, O);
908 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
919909 }
920910 O << '\n';
921911 EmitGlobalConstant(C);
928918 }
929919 if (VerboseAsm) {
930920 O << "\t\t" << TAI->getCommentString() << " '";
931 PrintUnmangledNameSafely(GVar, O);
921 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
932922 O << "'";
933923 }
934924 O << '\n';
963953 O << name << ":";
964954 if (VerboseAsm) {
965955 O << "\t\t\t\t" << TAI->getCommentString() << " '";
966 PrintUnmangledNameSafely(GVar, O);
956 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
967957 O << "'";
968958 }
969959 O << '\n';
1818 #include "llvm/Constants.h"
1919 #include "llvm/DerivedTypes.h"
2020 #include "llvm/Module.h"
21 #include "llvm/Assembly/Writer.h"
2122 #include "llvm/CodeGen/AsmPrinter.h"
2223 #include "llvm/CodeGen/DwarfWriter.h"
2324 #include "llvm/CodeGen/MachineModuleInfo.h"
296297 assert(!Index.getReg() && "Should allocate base register first!");
297298 }
298299
299 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
300 /// Don't print things like \\n or \\0.
301 static void PrintUnmangledNameSafely(const Value *V,
302 formatted_raw_ostream &OS) {
303 for (StringRef::iterator it = V->getName().begin(),
304 ie = V->getName().end(); it != ie; ++it)
305 if (isprint(*it))
306 OS << *it;
307 }
308
309300 void SystemZAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
310301 const TargetData *TD = TM.getTargetData();
311302
342333
343334 if (VerboseAsm) {
344335 O << "\t\t" << TAI->getCommentString() << ' ';
345 PrintUnmangledNameSafely(GVar, O);
336 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
346337 }
347338 O << '\n';
348339 return;
377368 O << name << ":";
378369 if (VerboseAsm) {
379370 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
380 PrintUnmangledNameSafely(GVar, O);
371 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
381372 }
382373 O << '\n';
383374 if (TAI->hasDotTypeDotSizeDirective())
2525 #include "llvm/Type.h"
2626 #include "llvm/ADT/Statistic.h"
2727 #include "llvm/ADT/StringExtras.h"
28 #include "llvm/Assembly/Writer.h"
2829 #include "llvm/MC/MCContext.h"
2930 #include "llvm/MC/MCInst.h"
3031 #include "llvm/MC/MCSectionMachO.h"
5859 llvm_unreachable("Don't know how to print PIC label!");
5960 }
6061
61 /// PrintUnmangledNameSafely - Print out the printable characters in the name.
62 /// Don't print things like \\n or \\0.
63 static void PrintUnmangledNameSafely(const Value *V,
64 formatted_raw_ostream &OS) {
65 for (StringRef::iterator it = V->getName().begin(),
66 ie = V->getName().end(); it != ie; ++it)
67 if (isprint(*it))
68 OS << *it;
69 }
70
7162 static X86MachineFunctionInfo calculateFunctionInfo(const Function *F,
7263 const TargetData *TD) {
7364 X86MachineFunctionInfo Info;
207198 << ";\t.endef\n";
208199 }
209200
210 O << CurrentFnName << ":\n";
201 O << CurrentFnName << ':';
202 if (VerboseAsm) {
203 O.PadToColumn(TAI->getCommentColumn(), 1);
204 O << TAI->getCommentString() << ' ';
205 WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
206 }
207 O << '\n';
208
211209 // Add some workaround for linkonce linkage on Cygwin\MinGW
212210 if (Subtarget->isTargetCygMing() &&
213211 (F->hasLinkOnceLinkage() || F->hasWeakLinkage()))
402400 O << MO.getImm();
403401 return;
404402 case MachineOperand::MO_MachineBasicBlock:
405 printBasicBlockLabel(MO.getMBB(), false, false, VerboseAsm);
403 printBasicBlockLabel(MO.getMBB(), false, false, false);
406404 return;
407405 case MachineOperand::MO_GlobalAddress:
408406 case MachineOperand::MO_ExternalSymbol:
817815 if (VerboseAsm) {
818816 O.PadToColumn(TAI->getCommentColumn(), 1);
819817 O << TAI->getCommentString() << ' ';
820 PrintUnmangledNameSafely(GVar, O);
818 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
821819 }
822820 O << '\n';
823821 EmitGlobalConstant(C);
839837 if (VerboseAsm) {
840838 O.PadToColumn(TAI->getCommentColumn(), 1);
841839 O << TAI->getCommentString() << ' ';
842 PrintUnmangledNameSafely(GVar, O);
840 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
843841 }
844842 O << '\n';
845843 return;
883881 if (VerboseAsm){
884882 O.PadToColumn(TAI->getCommentColumn(), 1);
885883 O << TAI->getCommentString() << ' ';
886 PrintUnmangledNameSafely(GVar, O);
884 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
887885 }
888886 O << '\n';
887
888 EmitGlobalConstant(C);
889
889890 if (TAI->hasDotTypeDotSizeDirective())
890891 O << "\t.size\t" << name << ", " << Size << '\n';
891
892 EmitGlobalConstant(C);
893892 }
894893
895894 bool X86ATTAsmPrinter::doFinalization(Module &M) {
272272 O << MO.getImm();
273273 return;
274274 case MachineOperand::MO_MachineBasicBlock:
275 printBasicBlockLabel(MO.getMBB());
275 printBasicBlockLabel(MO.getMBB(), false, false, false);
276276 return;
277277
278278 case MachineOperand::MO_GlobalAddress: {
0 ; RUN: llvm-as < %s | llvm-dis
11
2 %0 = type { %1, %2 } ; type %0
3 %1 = type { i32 } ; type %1
4 %2 = type { float, double } ; type %2
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
3
4 module asm "this is an inline asm block"
5 module asm "this is another inline asm block"
6
7 %0 = type { %1, %2 }
8 %1 = type { i32 }
9 %2 = type { float, double }
510
611 @0 = global i32 0
712 @1 = global float 3.0
813 @2 = global i8* null
14 @3 = global x86_fp80 0xK4001E000000000000000
915
1016 define float @foo(%0* %p) nounwind {
1117 %t = load %0* %p ; <%0> [#uses=2]
3945 define i8** @sss() {
4046 ret i8** @2
4147 }
48 define x86_fp80* @nnn() {
49 ret x86_fp80* @3
50 }
0 ; RUN: llvm-as < %s | llc | grep ly | count 2
11 ; RUN: llvm-as < %s | llc | grep sty | count 2
2 ; RUN: llvm-as < %s | llc | grep {l.%} | count 2
3 ; RUN: llvm-as < %s | llc | grep {st.%} | count 2
2 ; RUN: llvm-as < %s | llc | grep {l %} | count 2
3 ; RUN: llvm-as < %s | llc | grep {st %} | count 2
44
55 target datalayout = "E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16"
66 target triple = "s390x-linux"
7474 ; LINUX: .type G6,@object
7575 ; LINUX: .section .gnu.linkonce.r.G6,"a",@progbits
7676 ; LINUX: .weak G6
77 ; LINUX: G6: # G6
77 ; LINUX: G6:
78 ; LINUX: .ascii "\001"
7879 ; LINUX: .size G6, 1
79 ; LINUX: .ascii "\001"
8080
8181 ; DARWIN: .section __TEXT,__const_coal,coalesced
8282 ; DARWIN: .globl _G6