llvm.org GIT mirror llvm / 33adcfb
rename TAI -> MAI, being careful not to make MAILJMP instructions :) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79777 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
50 changed file(s) with 562 addition(s) and 562 deletion(s). Raw diff Collapse all Expand all
9595
9696 /// Target Asm Printer information.
9797 ///
98 const MCAsmInfo *TAI;
98 const MCAsmInfo *MAI;
9999
100100 /// Target Register Information.
101101 ///
6262
6363 /// beginAssembly/finishAssembly - Emit module metadata as assembly code.
6464 virtual void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
65 const MCAsmInfo &TAI);
65 const MCAsmInfo &MAI);
6666
6767 virtual void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
68 const MCAsmInfo &TAI);
68 const MCAsmInfo &MAI);
6969
7070 virtual ~GCMetadataPrinter();
7171 };
3636
3737 SectionKind getKind() const { return Kind; }
3838
39 virtual void PrintSwitchToSection(const MCAsmInfo &TAI,
39 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
4040 raw_ostream &OS) const = 0;
4141 };
4242
6161 const std::string &getName() const { return Name; }
6262 bool isDirective() const { return IsDirective; }
6363
64 virtual void PrintSwitchToSection(const MCAsmInfo &TAI,
64 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
6565 raw_ostream &OS) const;
6666 };
6767
4747 /// ShouldOmitSectionDirective - Decides whether a '.section' directive
4848 /// should be printed before the section name
4949 bool ShouldOmitSectionDirective(const char *Name,
50 const MCAsmInfo &TAI) const;
50 const MCAsmInfo &MAI) const;
5151
5252 /// ShouldPrintSectionType - Only prints the section type if supported
5353 bool ShouldPrintSectionType(unsigned Ty) const;
170170 unsigned getType() const { return Type; }
171171 unsigned getFlags() const { return Flags; }
172172
173 virtual void PrintSwitchToSection(const MCAsmInfo &TAI,
173 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
174174 raw_ostream &OS) const;
175175
176176
178178 /// MCSectionELF subclasses with target specific section flags should
179179 /// implement this method if they end up adding letters to the attributes
180180 /// list.
181 virtual void PrintTargetSpecificSectionFlags(const MCAsmInfo &TAI,
181 virtual void PrintTargetSpecificSectionFlags(const MCAsmInfo &MAI,
182182 raw_ostream &OS) const {
183183 }
184184
165165 unsigned &TAA, // Out.
166166 unsigned &StubSize); // Out.
167167
168 virtual void PrintSwitchToSection(const MCAsmInfo &TAI,
168 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
169169 raw_ostream &OS) const;
170170 };
171171
240240 ///
241241 /// \arg AP - If given, an AsmPrinter to use for printing instructions.
242242 MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS,
243 const MCAsmInfo &TAI, AsmPrinter *AP = 0);
243 const MCAsmInfo &MAI, AsmPrinter *AP = 0);
244244
245245 // FIXME: These two may end up getting rolled into a single
246246 // createObjectStreamer interface, which implements the assembler backend, and
463463 /// Measure the specified inline asm to determine an approximation of its
464464 /// length.
465465 virtual unsigned getInlineAsmLength(const char *Str,
466 const MCAsmInfo &TAI) const;
466 const MCAsmInfo &MAI) const;
467467 };
468468
469469 /// TargetInstrInfoImpl - This is the default implementation of
5252 const std::string &Features);
5353 typedef AsmPrinter *(*AsmPrinterCtorTy)(formatted_raw_ostream &OS,
5454 TargetMachine &TM,
55 const MCAsmInfo *TAI,
55 const MCAsmInfo *MAI,
5656 bool VerboseAsm);
5757 typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,
5858 MCAsmParser &P);
139139
140140 /// createAsmPrinter - Create a target specific assembly printer pass.
141141 AsmPrinter *createAsmPrinter(formatted_raw_ostream &OS, TargetMachine &TM,
142 const MCAsmInfo *TAI, bool Verbose) const {
142 const MCAsmInfo *MAI, bool Verbose) const {
143143 if (!AsmPrinterCtorFn)
144144 return 0;
145 return AsmPrinterCtorFn(OS, TM, TAI, Verbose);
145 return AsmPrinterCtorFn(OS, TM, MAI, Verbose);
146146 }
147147
148148 /// createAsmParser - Create a target specific assembly parser.
405405
406406 private:
407407 static AsmPrinter *Allocator(formatted_raw_ostream &OS, TargetMachine &TM,
408 const MCAsmInfo *TAI, bool Verbose) {
409 return new AsmPrinterImpl(OS, TM, TAI, Verbose);
408 const MCAsmInfo *MAI, bool Verbose) {
409 return new AsmPrinterImpl(OS, TM, MAI, Verbose);
410410 }
411411 };
412412
5151 AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
5252 const MCAsmInfo *T, bool VDef)
5353 : MachineFunctionPass(&ID), FunctionNumber(0), O(o),
54 TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
54 TM(tm), MAI(T), TRI(tm.getRegisterInfo()),
5555
5656 OutContext(*new MCContext()),
5757 OutStreamer(*createAsmStreamer(OutContext, O, *T, this)),
9898 const_cast(getObjFileLowering())
9999 .Initialize(OutContext, TM);
100100
101 Mang = new Mangler(M, TAI->getGlobalPrefix(), TAI->getPrivateGlobalPrefix(),
102 TAI->getLinkerPrivateGlobalPrefix());
103
104 if (TAI->doesAllowQuotesInName())
101 Mang = new Mangler(M, MAI->getGlobalPrefix(), MAI->getPrivateGlobalPrefix(),
102 MAI->getLinkerPrivateGlobalPrefix());
103
104 if (MAI->doesAllowQuotesInName())
105105 Mang->setUseQuotes(true);
106106
107107 GCModuleInfo *MI = getAnalysisIfAvailable();
108108 assert(MI && "AsmPrinter didn't require GCModuleInfo?");
109109
110 if (TAI->hasSingleParameterDotFile()) {
110 if (MAI->hasSingleParameterDotFile()) {
111111 /* Very minimal debug info. It is ignored if we emit actual
112112 debug info. If we don't, this at helps the user find where
113113 a function came from. */
116116
117117 for (GCModuleInfo::iterator I = MI->begin(), E = MI->end(); I != E; ++I)
118118 if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*I))
119 MP->beginAssembly(O, *this, *TAI);
119 MP->beginAssembly(O, *this, *MAI);
120120
121121 if (!M.getModuleInlineAsm().empty())
122 O << TAI->getCommentString() << " Start of file scope inline assembly\n"
122 O << MAI->getCommentString() << " Start of file scope inline assembly\n"
123123 << M.getModuleInlineAsm()
124 << '\n' << TAI->getCommentString()
124 << '\n' << MAI->getCommentString()
125125 << " End of file scope inline assembly\n";
126126
127 if (TAI->doesSupportDebugInformation() ||
128 TAI->doesSupportExceptionHandling()) {
127 if (MAI->doesSupportDebugInformation() ||
128 MAI->doesSupportExceptionHandling()) {
129129 MMI = getAnalysisIfAvailable();
130130 if (MMI)
131131 MMI->AnalyzeModule(M);
132132 DW = getAnalysisIfAvailable();
133133 if (DW)
134 DW->BeginModule(&M, MMI, O, this, TAI);
134 DW->BeginModule(&M, MMI, O, this, MAI);
135135 }
136136
137137 return false;
144144 PrintGlobalVariable(I);
145145
146146 // Emit final debug information.
147 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
147 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
148148 DW->EndModule();
149149
150150 // If the target wants to know about weak references, print them all.
151 if (TAI->getWeakRefDirective()) {
151 if (MAI->getWeakRefDirective()) {
152152 // FIXME: This is not lazy, it would be nice to only print weak references
153153 // to stuff that is actually used. Note that doing so would require targets
154154 // to notice uses in operands (due to constant exprs etc). This should
158158 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
159159 I != E; ++I) {
160160 if (I->hasExternalWeakLinkage())
161 O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';
161 O << MAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';
162162 }
163163
164164 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I) {
165165 if (I->hasExternalWeakLinkage())
166 O << TAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';
167 }
168 }
169
170 if (TAI->getSetDirective()) {
166 O << MAI->getWeakRefDirective() << Mang->getMangledName(I) << '\n';
167 }
168 }
169
170 if (MAI->getSetDirective()) {
171171 O << '\n';
172172 for (Module::const_alias_iterator I = M.alias_begin(), E = M.alias_end();
173173 I != E; ++I) {
176176 const GlobalValue *GV = cast(I->getAliasedGlobal());
177177 std::string Target = Mang->getMangledName(GV);
178178
179 if (I->hasExternalLinkage() || !TAI->getWeakRefDirective())
179 if (I->hasExternalLinkage() || !MAI->getWeakRefDirective())
180180 O << "\t.globl\t" << Name << '\n';
181181 else if (I->hasWeakLinkage())
182 O << TAI->getWeakRefDirective() << Name << '\n';
182 O << MAI->getWeakRefDirective() << Name << '\n';
183183 else if (!I->hasLocalLinkage())
184184 llvm_unreachable("Invalid alias linkage");
185185
186186 printVisibility(Name, I->getVisibility());
187187
188 O << TAI->getSetDirective() << ' ' << Name << ", " << Target << '\n';
188 O << MAI->getSetDirective() << ' ' << Name << ", " << Target << '\n';
189189 }
190190 }
191191
193193 assert(MI && "AsmPrinter didn't require GCModuleInfo?");
194194 for (GCModuleInfo::iterator I = MI->end(), E = MI->begin(); I != E; )
195195 if (GCMetadataPrinter *MP = GetOrCreateGCPrinter(*--I))
196 MP->finishAssembly(O, *this, *TAI);
196 MP->finishAssembly(O, *this, *MAI);
197197
198198 // If we don't have any trampolines, then we don't require stack memory
199199 // to be executable. Some targets have a directive to declare this.
200200 Function *InitTrampolineIntrinsic = M.getFunction("llvm.init.trampoline");
201201 if (!InitTrampolineIntrinsic || InitTrampolineIntrinsic->use_empty())
202 if (TAI->getNonexecutableStackDirective())
203 O << TAI->getNonexecutableStackDirective() << '\n';
202 if (MAI->getNonexecutableStackDirective())
203 O << MAI->getNonexecutableStackDirective() << '\n';
204204
205205 delete Mang; Mang = 0;
206206 DW = 0; MMI = 0;
213213 AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF) const {
214214 assert(MF && "No machine function?");
215215 return Mang->getMangledName(MF->getFunction(), ".eh",
216 TAI->is_EHSymbolPrivate());
216 MAI->is_EHSymbolPrivate());
217217 }
218218
219219 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
308308 const Type *Ty = CPE.getType();
309309 Offset = NewOffset + TM.getTargetData()->getTypeAllocSize(Ty);
310310
311 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
311 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
312312 << CPI << ':';
313313 if (VerboseAsm) {
314 O.PadToColumn(TAI->getCommentColumn());
315 O << TAI->getCommentString() << " constant ";
314 O.PadToColumn(MAI->getCommentColumn());
315 O << MAI->getCommentString() << " constant ";
316316 WriteTypeSymbolic(O, CPE.getType(), MF->getFunction()->getParent());
317317 }
318318 O << '\n';
368368 // the number of relocations the assembler will generate for the jump table.
369369 // Set directives are all printed before the jump table itself.
370370 SmallPtrSet EmittedSets;
371 if (TAI->getSetDirective() && IsPic)
371 if (MAI->getSetDirective() && IsPic)
372372 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii)
373373 if (EmittedSets.insert(JTBBs[ii]))
374374 printPICJumpTableSetLabel(i, JTBBs[ii]);
378378 // the assembler and linker the extents of the jump table object. The
379379 // second label is actually referenced by the code.
380380 if (JTInDiffSection) {
381 if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix())
381 if (const char *JTLabelPrefix = MAI->getJumpTableSpecialLabelPrefix())
382382 O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n";
383383 }
384384
385 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
385 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
386386 << '_' << i << ":\n";
387387
388388 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
399399
400400 // Use JumpTableDirective otherwise honor the entry size from the jump table
401401 // info.
402 const char *JTEntryDirective = TAI->getJumpTableDirective(isPIC);
402 const char *JTEntryDirective = MAI->getJumpTableDirective(isPIC);
403403 bool HadJTEntryDirective = JTEntryDirective != NULL;
404404 if (!HadJTEntryDirective) {
405405 JTEntryDirective = MJTI->getEntrySize() == 4 ?
406 TAI->getData32bitsDirective() : TAI->getData64bitsDirective();
406 MAI->getData32bitsDirective() : MAI->getData64bitsDirective();
407407 }
408408
409409 O << JTEntryDirective << ' ';
415415 // references to the target basic blocks.
416416 if (!isPIC) {
417417 printBasicBlockLabel(MBB, false, false, false);
418 } else if (TAI->getSetDirective()) {
419 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
418 } else if (MAI->getSetDirective()) {
419 O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
420420 << '_' << uid << "_set_" << MBB->getNumber();
421421 } else {
422422 printBasicBlockLabel(MBB, false, false, false);
423423 // If the arch uses custom Jump Table directives, don't calc relative to
424424 // JT
425425 if (!HadJTEntryDirective)
426 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
426 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI"
427427 << getFunctionNumber() << '_' << uid;
428428 }
429429 }
434434 /// do nothing and return false.
435435 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
436436 if (GV->getName() == "llvm.used") {
437 if (TAI->getUsedDirective() != 0) // No need to emit this at all.
437 if (MAI->getUsedDirective() != 0) // No need to emit this at all.
438438 EmitLLVMUsedList(GV->getInitializer());
439439 return true;
440440 }
467467 return false;
468468 }
469469
470 /// EmitLLVMUsedList - For targets that define a TAI::UsedDirective, mark each
470 /// EmitLLVMUsedList - For targets that define a MAI::UsedDirective, mark each
471471 /// global in the specified llvm.used list for which emitUsedDirectiveFor
472472 /// is true, as being used with this directive.
473473 void AsmPrinter::EmitLLVMUsedList(Constant *List) {
474 const char *Directive = TAI->getUsedDirective();
474 const char *Directive = MAI->getUsedDirective();
475475
476476 // Should be an array of 'i8*'.
477477 ConstantArray *InitList = dyn_cast(List);
512512 const std::string &AsmPrinter::getGlobalLinkName(const GlobalVariable *GV,
513513 std::string &LinkName) const {
514514 if (isa(GV)) {
515 LinkName += TAI->getFunctionAddrPrefix();
515 LinkName += MAI->getFunctionAddrPrefix();
516516 LinkName += Mang->getMangledName(GV);
517 LinkName += TAI->getFunctionAddrSuffix();
517 LinkName += MAI->getFunctionAddrSuffix();
518518 } else {
519 LinkName += TAI->getGlobalVarAddrPrefix();
519 LinkName += MAI->getGlobalVarAddrPrefix();
520520 LinkName += Mang->getMangledName(GV);
521 LinkName += TAI->getGlobalVarAddrSuffix();
521 LinkName += MAI->getGlobalVarAddrSuffix();
522522 }
523523
524524 return LinkName;
585585
586586 void AsmPrinter::EOL(const std::string &Comment) const {
587587 if (VerboseAsm && !Comment.empty()) {
588 O.PadToColumn(TAI->getCommentColumn());
589 O << TAI->getCommentString()
588 O.PadToColumn(MAI->getCommentColumn());
589 O << MAI->getCommentString()
590590 << ' '
591591 << Comment;
592592 }
595595
596596 void AsmPrinter::EOL(const char* Comment) const {
597597 if (VerboseAsm && *Comment) {
598 O.PadToColumn(TAI->getCommentColumn());
599 O << TAI->getCommentString()
598 O.PadToColumn(MAI->getCommentColumn());
599 O << MAI->getCommentString()
600600 << ' '
601601 << Comment;
602602 }
606606 /// EmitULEB128Bytes - Emit an assembler byte data directive to compose an
607607 /// unsigned leb128 value.
608608 void AsmPrinter::EmitULEB128Bytes(unsigned Value) const {
609 if (TAI->hasLEB128()) {
609 if (MAI->hasLEB128()) {
610610 O << "\t.uleb128\t"
611611 << Value;
612612 } else {
613 O << TAI->getData8bitsDirective();
613 O << MAI->getData8bitsDirective();
614614 PrintULEB128(Value);
615615 }
616616 }
618618 /// EmitSLEB128Bytes - print an assembler byte data directive to compose a
619619 /// signed leb128 value.
620620 void AsmPrinter::EmitSLEB128Bytes(int Value) const {
621 if (TAI->hasLEB128()) {
621 if (MAI->hasLEB128()) {
622622 O << "\t.sleb128\t"
623623 << Value;
624624 } else {
625 O << TAI->getData8bitsDirective();
625 O << MAI->getData8bitsDirective();
626626 PrintSLEB128(Value);
627627 }
628628 }
630630 /// EmitInt8 - Emit a byte directive and value.
631631 ///
632632 void AsmPrinter::EmitInt8(int Value) const {
633 O << TAI->getData8bitsDirective();
633 O << MAI->getData8bitsDirective();
634634 PrintHex(Value & 0xFF);
635635 }
636636
637637 /// EmitInt16 - Emit a short directive and value.
638638 ///
639639 void AsmPrinter::EmitInt16(int Value) const {
640 O << TAI->getData16bitsDirective();
640 O << MAI->getData16bitsDirective();
641641 PrintHex(Value & 0xFFFF);
642642 }
643643
644644 /// EmitInt32 - Emit a long directive and value.
645645 ///
646646 void AsmPrinter::EmitInt32(int Value) const {
647 O << TAI->getData32bitsDirective();
647 O << MAI->getData32bitsDirective();
648648 PrintHex(Value);
649649 }
650650
651651 /// EmitInt64 - Emit a long long directive and value.
652652 ///
653653 void AsmPrinter::EmitInt64(uint64_t Value) const {
654 if (TAI->getData64bitsDirective()) {
655 O << TAI->getData64bitsDirective();
654 if (MAI->getData64bitsDirective()) {
655 O << MAI->getData64bitsDirective();
656656 PrintHex(Value);
657657 } else {
658658 if (TM.getTargetData()->isBigEndian()) {
705705 }
706706
707707 void AsmPrinter::EmitString(const char *String, unsigned Size) const {
708 const char* AscizDirective = TAI->getAscizDirective();
708 const char* AscizDirective = MAI->getAscizDirective();
709709 if (AscizDirective)
710710 O << AscizDirective;
711711 else
712 O << TAI->getAsciiDirective();
712 O << MAI->getAsciiDirective();
713713 O << '\"';
714714 for (unsigned i = 0; i < Size; ++i)
715715 printStringChar(O, String[i]);
755755
756756 unsigned FillValue = 0;
757757 if (getCurrentSection()->getKind().isText())
758 FillValue = TAI->getTextAlignFillValue();
758 FillValue = MAI->getTextAlignFillValue();
759759
760760 OutStreamer.EmitValueToAlignment(1 << NumBits, FillValue, 1, 0);
761761 }
764764 ///
765765 void AsmPrinter::EmitZeros(uint64_t NumZeros, unsigned AddrSpace) const {
766766 if (NumZeros) {
767 if (TAI->getZeroDirective()) {
768 O << TAI->getZeroDirective() << NumZeros;
769 if (TAI->getZeroDirectiveSuffix())
770 O << TAI->getZeroDirectiveSuffix();
767 if (MAI->getZeroDirective()) {
768 O << MAI->getZeroDirective() << NumZeros;
769 if (MAI->getZeroDirectiveSuffix())
770 O << MAI->getZeroDirectiveSuffix();
771771 O << '\n';
772772 } else {
773773 for (; NumZeros; --NumZeros)
774 O << TAI->getData8bitsDirective(AddrSpace) << "0\n";
774 O << MAI->getData8bitsDirective(AddrSpace) << "0\n";
775775 }
776776 }
777777 }
789789 // decorating it with GlobalVarAddrPrefix/Suffix or
790790 // FunctionAddrPrefix/Suffix (these all default to "" )
791791 if (isa(GV)) {
792 O << TAI->getFunctionAddrPrefix()
792 O << MAI->getFunctionAddrPrefix()
793793 << Mang->getMangledName(GV)
794 << TAI->getFunctionAddrSuffix();
794 << MAI->getFunctionAddrSuffix();
795795 } else {
796 O << TAI->getGlobalVarAddrPrefix()
796 O << MAI->getGlobalVarAddrPrefix()
797797 << Mang->getMangledName(GV)
798 << TAI->getGlobalVarAddrSuffix();
798 << MAI->getGlobalVarAddrSuffix();
799799 }
800800 } else if (const ConstantExpr *CE = dyn_cast(CV)) {
801801 const TargetData *TD = TM.getTargetData();
928928 ///
929929 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
930930 unsigned NumElts = CVA->getNumOperands();
931 if (TAI->getAscizDirective() && NumElts &&
931 if (MAI->getAscizDirective() && NumElts &&
932932 cast(CVA->getOperand(NumElts-1))->getZExtValue() == 0) {
933 O << TAI->getAscizDirective();
933 O << MAI->getAscizDirective();
934934 printAsCString(O, CVA, NumElts-1);
935935 } else {
936 O << TAI->getAsciiDirective();
936 O << MAI->getAsciiDirective();
937937 printAsCString(O, CVA, NumElts);
938938 }
939939 O << '\n';
993993 if (CFP->getType() == Type::getDoubleTy(Context)) {
994994 double Val = CFP->getValueAPF().convertToDouble(); // for comment only
995995 uint64_t i = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
996 if (TAI->getData64bitsDirective(AddrSpace)) {
997 O << TAI->getData64bitsDirective(AddrSpace) << i;
998 if (VerboseAsm) {
999 O.PadToColumn(TAI->getCommentColumn());
1000 O << TAI->getCommentString() << " double " << Val;
996 if (MAI->getData64bitsDirective(AddrSpace)) {
997 O << MAI->getData64bitsDirective(AddrSpace) << i;
998 if (VerboseAsm) {
999 O.PadToColumn(MAI->getCommentColumn());
1000 O << MAI->getCommentString() << " double " << Val;
10011001 }
10021002 O << '\n';
10031003 } else if (TD->isBigEndian()) {
1004 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
1005 if (VerboseAsm) {
1006 O.PadToColumn(TAI->getCommentColumn());
1007 O << TAI->getCommentString()
1004 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
1005 if (VerboseAsm) {
1006 O.PadToColumn(MAI->getCommentColumn());
1007 O << MAI->getCommentString()
10081008 << " most significant word of double " << Val;
10091009 }
10101010 O << '\n';
1011 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
1012 if (VerboseAsm) {
1013 O.PadToColumn(TAI->getCommentColumn());
1014 O << TAI->getCommentString()
1011 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i);
1012 if (VerboseAsm) {
1013 O.PadToColumn(MAI->getCommentColumn());
1014 O << MAI->getCommentString()
10151015 << " least significant word of double " << Val;
10161016 }
10171017 O << '\n';
10181018 } else {
1019 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i);
1020 if (VerboseAsm) {
1021 O.PadToColumn(TAI->getCommentColumn());
1022 O << TAI->getCommentString()
1019 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i);
1020 if (VerboseAsm) {
1021 O.PadToColumn(MAI->getCommentColumn());
1022 O << MAI->getCommentString()
10231023 << " least significant word of double " << Val;
10241024 }
10251025 O << '\n';
1026 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
1027 if (VerboseAsm) {
1028 O.PadToColumn(TAI->getCommentColumn());
1029 O << TAI->getCommentString()
1026 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(i >> 32);
1027 if (VerboseAsm) {
1028 O.PadToColumn(MAI->getCommentColumn());
1029 O << MAI->getCommentString()
10301030 << " most significant word of double " << Val;
10311031 }
10321032 O << '\n';
10341034 return;
10351035 } else if (CFP->getType() == Type::getFloatTy(Context)) {
10361036 float Val = CFP->getValueAPF().convertToFloat(); // for comment only
1037 O << TAI->getData32bitsDirective(AddrSpace)
1037 O << MAI->getData32bitsDirective(AddrSpace)
10381038 << CFP->getValueAPF().bitcastToAPInt().getZExtValue();
10391039 if (VerboseAsm) {
1040 O.PadToColumn(TAI->getCommentColumn());
1041 O << TAI->getCommentString() << " float " << Val;
1040 O.PadToColumn(MAI->getCommentColumn());
1041 O << MAI->getCommentString() << " float " << Val;
10421042 }
10431043 O << '\n';
10441044 return;
10531053 DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
10541054 &ignored);
10551055 if (TD->isBigEndian()) {
1056 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
1057 if (VerboseAsm) {
1058 O.PadToColumn(TAI->getCommentColumn());
1059 O << TAI->getCommentString()
1056 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
1057 if (VerboseAsm) {
1058 O.PadToColumn(MAI->getCommentColumn());
1059 O << MAI->getCommentString()
10601060 << " most significant halfword of x86_fp80 ~"
10611061 << DoubleVal.convertToDouble();
10621062 }
10631063 O << '\n';
1064 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
1065 if (VerboseAsm) {
1066 O.PadToColumn(TAI->getCommentColumn());
1067 O << TAI->getCommentString() << " next halfword";
1068 }
1069 O << '\n';
1070 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
1071 if (VerboseAsm) {
1072 O.PadToColumn(TAI->getCommentColumn());
1073 O << TAI->getCommentString() << " next halfword";
1074 }
1075 O << '\n';
1076 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
1077 if (VerboseAsm) {
1078 O.PadToColumn(TAI->getCommentColumn());
1079 O << TAI->getCommentString() << " next halfword";
1080 }
1081 O << '\n';
1082 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
1083 if (VerboseAsm) {
1084 O.PadToColumn(TAI->getCommentColumn());
1085 O << TAI->getCommentString()
1064 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
1065 if (VerboseAsm) {
1066 O.PadToColumn(MAI->getCommentColumn());
1067 O << MAI->getCommentString() << " next halfword";
1068 }
1069 O << '\n';
1070 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
1071 if (VerboseAsm) {
1072 O.PadToColumn(MAI->getCommentColumn());
1073 O << MAI->getCommentString() << " next halfword";
1074 }
1075 O << '\n';
1076 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
1077 if (VerboseAsm) {
1078 O.PadToColumn(MAI->getCommentColumn());
1079 O << MAI->getCommentString() << " next halfword";
1080 }
1081 O << '\n';
1082 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
1083 if (VerboseAsm) {
1084 O.PadToColumn(MAI->getCommentColumn());
1085 O << MAI->getCommentString()
10861086 << " least significant halfword";
10871087 }
10881088 O << '\n';
10891089 } else {
1090 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
1091 if (VerboseAsm) {
1092 O.PadToColumn(TAI->getCommentColumn());
1093 O << TAI->getCommentString()
1090 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0]);
1091 if (VerboseAsm) {
1092 O.PadToColumn(MAI->getCommentColumn());
1093 O << MAI->getCommentString()
10941094 << " least significant halfword of x86_fp80 ~"
10951095 << DoubleVal.convertToDouble();
10961096 }
10971097 O << '\n';
1098 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
1099 if (VerboseAsm) {
1100 O.PadToColumn(TAI->getCommentColumn());
1101 O << TAI->getCommentString()
1098 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 16);
1099 if (VerboseAsm) {
1100 O.PadToColumn(MAI->getCommentColumn());
1101 O << MAI->getCommentString()
11021102 << " next halfword";
11031103 }
11041104 O << '\n';
1105 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
1106 if (VerboseAsm) {
1107 O.PadToColumn(TAI->getCommentColumn());
1108 O << TAI->getCommentString()
1105 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 32);
1106 if (VerboseAsm) {
1107 O.PadToColumn(MAI->getCommentColumn());
1108 O << MAI->getCommentString()
11091109 << " next halfword";
11101110 }
11111111 O << '\n';
1112 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
1113 if (VerboseAsm) {
1114 O.PadToColumn(TAI->getCommentColumn());
1115 O << TAI->getCommentString()
1112 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[0] >> 48);
1113 if (VerboseAsm) {
1114 O.PadToColumn(MAI->getCommentColumn());
1115 O << MAI->getCommentString()
11161116 << " next halfword";
11171117 }
11181118 O << '\n';
1119 O << TAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
1120 if (VerboseAsm) {
1121 O.PadToColumn(TAI->getCommentColumn());
1122 O << TAI->getCommentString()
1119 O << MAI->getData16bitsDirective(AddrSpace) << uint16_t(p[1]);
1120 if (VerboseAsm) {
1121 O.PadToColumn(MAI->getCommentColumn());
1122 O << MAI->getCommentString()
11231123 << " most significant halfword";
11241124 }
11251125 O << '\n';
11331133 APInt api = CFP->getValueAPF().bitcastToAPInt();
11341134 const uint64_t *p = api.getRawData();
11351135 if (TD->isBigEndian()) {
1136 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
1137 if (VerboseAsm) {
1138 O.PadToColumn(TAI->getCommentColumn());
1139 O << TAI->getCommentString()
1136 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
1137 if (VerboseAsm) {
1138 O.PadToColumn(MAI->getCommentColumn());
1139 O << MAI->getCommentString()
11401140 << " most significant word of ppc_fp128";
11411141 }
11421142 O << '\n';
1143 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
1144 if (VerboseAsm) {
1145 O.PadToColumn(TAI->getCommentColumn());
1146 O << TAI->getCommentString()
1143 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
1144 if (VerboseAsm) {
1145 O.PadToColumn(MAI->getCommentColumn());
1146 O << MAI->getCommentString()
11471147 << " next word";
11481148 }
11491149 O << '\n';
1150 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
1151 if (VerboseAsm) {
1152 O.PadToColumn(TAI->getCommentColumn());
1153 O << TAI->getCommentString()
1150 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
1151 if (VerboseAsm) {
1152 O.PadToColumn(MAI->getCommentColumn());
1153 O << MAI->getCommentString()
11541154 << " next word";
11551155 }
11561156 O << '\n';
1157 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
1158 if (VerboseAsm) {
1159 O.PadToColumn(TAI->getCommentColumn());
1160 O << TAI->getCommentString()
1157 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
1158 if (VerboseAsm) {
1159 O.PadToColumn(MAI->getCommentColumn());
1160 O << MAI->getCommentString()
11611161 << " least significant word";
11621162 }
11631163 O << '\n';
11641164 } else {
1165 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
1166 if (VerboseAsm) {
1167 O.PadToColumn(TAI->getCommentColumn());
1168 O << TAI->getCommentString()
1165 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1]);
1166 if (VerboseAsm) {
1167 O.PadToColumn(MAI->getCommentColumn());
1168 O << MAI->getCommentString()
11691169 << " least significant word of ppc_fp128";
11701170 }
11711171 O << '\n';
1172 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
1173 if (VerboseAsm) {
1174 O.PadToColumn(TAI->getCommentColumn());
1175 O << TAI->getCommentString()
1172 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[1] >> 32);
1173 if (VerboseAsm) {
1174 O.PadToColumn(MAI->getCommentColumn());
1175 O << MAI->getCommentString()
11761176 << " next word";
11771177 }
11781178 O << '\n';
1179 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
1180 if (VerboseAsm) {
1181 O.PadToColumn(TAI->getCommentColumn());
1182 O << TAI->getCommentString()
1179 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0]);
1180 if (VerboseAsm) {
1181 O.PadToColumn(MAI->getCommentColumn());
1182 O << MAI->getCommentString()
11831183 << " next word";
11841184 }
11851185 O << '\n';
1186 O << TAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
1187 if (VerboseAsm) {
1188 O.PadToColumn(TAI->getCommentColumn());
1189 O << TAI->getCommentString()
1186 O << MAI->getData32bitsDirective(AddrSpace) << uint32_t(p[0] >> 32);
1187 if (VerboseAsm) {
1188 O.PadToColumn(MAI->getCommentColumn());
1189 O << MAI->getCommentString()
11901190 << " most significant word";
11911191 }
11921192 O << '\n';
12131213 else
12141214 Val = RawData[i];
12151215
1216 if (TAI->getData64bitsDirective(AddrSpace))
1217 O << TAI->getData64bitsDirective(AddrSpace) << Val << '\n';
1216 if (MAI->getData64bitsDirective(AddrSpace))
1217 O << MAI->getData64bitsDirective(AddrSpace) << Val << '\n';
12181218 else if (TD->isBigEndian()) {
1219 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
1220 if (VerboseAsm) {
1221 O.PadToColumn(TAI->getCommentColumn());
1222 O << TAI->getCommentString()
1219 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
1220 if (VerboseAsm) {
1221 O.PadToColumn(MAI->getCommentColumn());
1222 O << MAI->getCommentString()
12231223 << " most significant half of i64 " << Val;
12241224 }
12251225 O << '\n';
1226 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
1227 if (VerboseAsm) {
1228 O.PadToColumn(TAI->getCommentColumn());
1229 O << TAI->getCommentString()
1226 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
1227 if (VerboseAsm) {
1228 O.PadToColumn(MAI->getCommentColumn());
1229 O << MAI->getCommentString()
12301230 << " least significant half of i64 " << Val;
12311231 }
12321232 O << '\n';
12331233 } else {
1234 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
1235 if (VerboseAsm) {
1236 O.PadToColumn(TAI->getCommentColumn());
1237 O << TAI->getCommentString()
1234 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val);
1235 if (VerboseAsm) {
1236 O.PadToColumn(MAI->getCommentColumn());
1237 O << MAI->getCommentString()
12381238 << " least significant half of i64 " << Val;
12391239 }
12401240 O << '\n';
1241 O << TAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
1242 if (VerboseAsm) {
1243 O.PadToColumn(TAI->getCommentColumn());
1244 O << TAI->getCommentString()
1241 O << MAI->getData32bitsDirective(AddrSpace) << unsigned(Val >> 32);
1242 if (VerboseAsm) {
1243 O.PadToColumn(MAI->getCommentColumn());
1244 O << MAI->getCommentString()
12451245 << " most significant half of i64 " << Val;
12461246 }
12471247 O << '\n';
12841284 if (const ConstantInt *CI = dyn_cast(CV)) {
12851285 SmallString<40> S;
12861286 CI->getValue().toStringUnsigned(S, 16);
1287 O.PadToColumn(TAI->getCommentColumn());
1288 O << TAI->getCommentString() << " 0x" << S.str();
1287 O.PadToColumn(MAI->getCommentColumn());
1288 O << MAI->getCommentString() << " 0x" << S.str();
12891289 }
12901290 }
12911291 O << '\n';
13041304 /// for their own strange codes.
13051305 void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const {
13061306 if (!strcmp(Code, "private")) {
1307 O << TAI->getPrivateGlobalPrefix();
1307 O << MAI->getPrivateGlobalPrefix();
13081308 } else if (!strcmp(Code, "comment")) {
13091309 if (VerboseAsm)
1310 O << TAI->getCommentString();
1310 O << MAI->getCommentString();
13111311 } else if (!strcmp(Code, "uid")) {
13121312 // Comparing the address of MI isn't sufficient, because machineinstrs may
13131313 // be allocated to the same address across functions.
13321332 /// processDebugLoc - Processes the debug information of each machine
13331333 /// instruction's DebugLoc.
13341334 void AsmPrinter::processDebugLoc(DebugLoc DL) {
1335 if (!TAI || !DW)
1335 if (!MAI || !DW)
13361336 return;
13371337
1338 if (TAI->doesSupportDebugInformation() && DW->ShouldEmitDwarfDebug()) {
1338 if (MAI->doesSupportDebugInformation() && DW->ShouldEmitDwarfDebug()) {
13391339 if (!DL.isUnknown()) {
13401340 DebugLocTuple CurDLT = MF->getDebugLocTuple(DL);
13411341
13671367 // If this asmstr is empty, just print the #APP/#NOAPP markers.
13681368 // These are useful to see where empty asm's wound up.
13691369 if (AsmStr[0] == 0) {
1370 O << TAI->getCommentString() << TAI->getInlineAsmStart() << "\n\t";
1371 O << TAI->getCommentString() << TAI->getInlineAsmEnd() << '\n';
1370 O << MAI->getCommentString() << MAI->getInlineAsmStart() << "\n\t";
1371 O << MAI->getCommentString() << MAI->getInlineAsmEnd() << '\n';
13721372 return;
13731373 }
13741374
1375 O << TAI->getCommentString() << TAI->getInlineAsmStart() << "\n\t";
1375 O << MAI->getCommentString() << MAI->getInlineAsmStart() << "\n\t";
13761376
13771377 // The variant of the current asmprinter.
1378 int AsmPrinterVariant = TAI->getAssemblerDialect();
1378 int AsmPrinterVariant = MAI->getAssemblerDialect();
13791379
13801380 int CurVariant = -1; // The number of the {.|.|.} region we are in.
13811381 const char *LastEmitted = AsmStr; // One past the last character emitted.
15431543 }
15441544 }
15451545 }
1546 O << "\n\t" << TAI->getCommentString() << TAI->getInlineAsmEnd() << '\n';
1546 O << "\n\t" << MAI->getCommentString() << MAI->getInlineAsmEnd() << '\n';
15471547 }
15481548
15491549 /// printImplicitDef - This method prints the specified machine instruction
15501550 /// that is an implicit def.
15511551 void AsmPrinter::printImplicitDef(const MachineInstr *MI) const {
15521552 if (VerboseAsm) {
1553 O.PadToColumn(TAI->getCommentColumn());
1554 O << TAI->getCommentString() << " implicit-def: "
1553 O.PadToColumn(MAI->getCommentColumn());
1554 O << MAI->getCommentString() << " implicit-def: "
15551555 << TRI->getAsmName(MI->getOperand(0).getReg()) << '\n';
15561556 }
15571557 }
15631563 }
15641564
15651565 void AsmPrinter::printLabel(unsigned Id) const {
1566 O << TAI->getPrivateGlobalPrefix() << "label" << Id << ":\n";
1566 O << MAI->getPrivateGlobalPrefix() << "label" << Id << ":\n";
15671567 }
15681568
15691569 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
15941594 EmitAlignment(Log2_32(Align));
15951595 }
15961596
1597 O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << '_'
1597 O << MAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << '_'
15981598 << MBB->getNumber();
15991599 if (printColon)
16001600 O << ':';
16011601 if (printComment) {
16021602 if (const BasicBlock *BB = MBB->getBasicBlock())
16031603 if (BB->hasName()) {
1604 O.PadToColumn(TAI->getCommentColumn());
1605 O << TAI->getCommentString() << ' ';
1604 O.PadToColumn(MAI->getCommentColumn());
1605 O << MAI->getCommentString() << ' ';
16061606 WriteAsOperand(O, BB, /*PrintType=*/false);
16071607 }
16081608
16151615 /// specified MachineBasicBlock for a jumptable entry.
16161616 void AsmPrinter::printPICJumpTableSetLabel(unsigned uid,
16171617 const MachineBasicBlock *MBB) const {
1618 if (!TAI->getSetDirective())
1618 if (!MAI->getSetDirective())
16191619 return;
16201620
1621 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
1621 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
16221622 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
16231623 printBasicBlockLabel(MBB, false, false, false);
1624 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
1624 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
16251625 << '_' << uid << '\n';
16261626 }
16271627
16281628 void AsmPrinter::printPICJumpTableSetLabel(unsigned uid, unsigned uid2,
16291629 const MachineBasicBlock *MBB) const {
1630 if (!TAI->getSetDirective())
1630 if (!MAI->getSetDirective())
16311631 return;
16321632
1633 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
1633 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
16341634 << getFunctionNumber() << '_' << uid << '_' << uid2
16351635 << "_set_" << MBB->getNumber() << ',';
16361636 printBasicBlockLabel(MBB, false, false, false);
1637 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
1637 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
16381638 << '_' << uid << '_' << uid2 << '\n';
16391639 }
16401640
16511651 case Type::IntegerTyID: {
16521652 unsigned BitWidth = cast(type)->getBitWidth();
16531653 if (BitWidth <= 8)
1654 O << TAI->getData8bitsDirective(AddrSpace);
1654 O << MAI->getData8bitsDirective(AddrSpace);
16551655 else if (BitWidth <= 16)
1656 O << TAI->getData16bitsDirective(AddrSpace);
1656 O << MAI->getData16bitsDirective(AddrSpace);
16571657 else if (BitWidth <= 32)
1658 O << TAI->getData32bitsDirective(AddrSpace);
1658 O << MAI->getData32bitsDirective(AddrSpace);
16591659 else if (BitWidth <= 64) {
1660 assert(TAI->getData64bitsDirective(AddrSpace) &&
1660 assert(MAI->getData64bitsDirective(AddrSpace) &&
16611661 "Target cannot handle 64-bit constant exprs!");
1662 O << TAI->getData64bitsDirective(AddrSpace);
1662 O << MAI->getData64bitsDirective(AddrSpace);
16631663 } else {
16641664 llvm_unreachable("Target cannot handle given data directive width!");
16651665 }
16671667 }
16681668 case Type::PointerTyID:
16691669 if (TD->getPointerSize() == 8) {
1670 assert(TAI->getData64bitsDirective(AddrSpace) &&
1670 assert(MAI->getData64bitsDirective(AddrSpace) &&
16711671 "Target cannot handle 64-bit pointer exprs!");
1672 O << TAI->getData64bitsDirective(AddrSpace);
1672 O << MAI->getData64bitsDirective(AddrSpace);
16731673 } else if (TD->getPointerSize() == 2) {
1674 O << TAI->getData16bitsDirective(AddrSpace);
1674 O << MAI->getData16bitsDirective(AddrSpace);
16751675 } else if (TD->getPointerSize() == 1) {
1676 O << TAI->getData8bitsDirective(AddrSpace);
1676 O << MAI->getData8bitsDirective(AddrSpace);
16771677 } else {
1678 O << TAI->getData32bitsDirective(AddrSpace);
1678 O << MAI->getData32bitsDirective(AddrSpace);
16791679 }
16801680 break;
16811681 }
16841684 void AsmPrinter::printVisibility(const std::string& Name,
16851685 unsigned Visibility) const {
16861686 if (Visibility == GlobalValue::HiddenVisibility) {
1687 if (const char *Directive = TAI->getHiddenDirective())
1687 if (const char *Directive = MAI->getHiddenDirective())
16881688 O << Directive << Name << '\n';
16891689 } else if (Visibility == GlobalValue::ProtectedVisibility) {
1690 if (const char *Directive = TAI->getProtectedDirective())
1690 if (const char *Directive = MAI->getProtectedDirective())
16911691 O << Directive << Name << '\n';
16921692 }
16931693 }
17361736 DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
17371737
17381738 // Print source line info.
1739 O.PadToColumn(TAI->getCommentColumn());
1740 O << TAI->getCommentString() << " SrcLine ";
1739 O.PadToColumn(MAI->getCommentColumn());
1740 O << MAI->getCommentString() << " SrcLine ";
17411741 if (DLT.CompileUnit->hasInitializer()) {
17421742 Constant *Name = DLT.CompileUnit->getInitializer();
17431743 if (ConstantArray *NameString = dyn_cast(Name))
17571757 DebugLocTuple DLT = MF->getDebugLocTuple(MI.getDebugLoc());
17581758
17591759 // Print source line info
1760 O.PadToColumn(TAI->getCommentColumn());
1761 O << TAI->getCommentString() << " SrcLine ";
1760 O.PadToColumn(MAI->getCommentColumn());
1761 O << MAI->getCommentString() << " SrcLine ";
17621762 if (DLT.CompileUnit->hasInitializer()) {
17631763 Constant *Name = DLT.CompileUnit->getInitializer();
17641764 if (ConstantArray *NameString = dyn_cast(Name))
17911791 ///
17921792 static void PrintChildLoopComment(formatted_raw_ostream &O,
17931793 const MachineLoop *loop,
1794 const MCAsmInfo *TAI,
1794 const MCAsmInfo *MAI,
17951795 int FunctionNumber) {
17961796 // Add child loop information
17971797 for(MachineLoop::iterator cl = loop->begin(),
18021802 assert(Header && "No header for loop");
18031803
18041804 O << '\n';
1805 O.PadToColumn(TAI->getCommentColumn());
1806
1807 O << TAI->getCommentString();
1805 O.PadToColumn(MAI->getCommentColumn());
1806
1807 O << MAI->getCommentString();
18081808 Indent(O, (*cl)->getLoopDepth()-1)
18091809 << " Child Loop BB" << FunctionNumber << "_"
18101810 << Header->getNumber() << " Depth " << (*cl)->getLoopDepth();
18111811
1812 PrintChildLoopComment(O, *cl, TAI, FunctionNumber);
1812 PrintChildLoopComment(O, *cl, MAI, FunctionNumber);
18131813 }
18141814 }
18151815
18231823 if (loop) {
18241824 // Print a newline after bb# annotation.
18251825 O << "\n";
1826 O.PadToColumn(TAI->getCommentColumn());
1827 O << TAI->getCommentString() << " Loop Depth " << loop->getLoopDepth()
1826 O.PadToColumn(MAI->getCommentColumn());
1827 O << MAI->getCommentString() << " Loop Depth " << loop->getLoopDepth()
18281828 << '\n';
18291829
1830 O.PadToColumn(TAI->getCommentColumn());
1830 O.PadToColumn(MAI->getCommentColumn());
18311831
18321832 MachineBasicBlock *Header = loop->getHeader();
18331833 assert(Header && "No header for loop");
18341834
18351835 if (Header == &MBB) {
1836 O << TAI->getCommentString() << " Loop Header";
1837 PrintChildLoopComment(O, loop, TAI, getFunctionNumber());
1836 O << MAI->getCommentString() << " Loop Header";
1837 PrintChildLoopComment(O, loop, MAI, getFunctionNumber());
18381838 }
18391839 else {
1840 O << TAI->getCommentString() << " Loop Header is BB"
1840 O << MAI->getCommentString() << " Loop Header is BB"
18411841 << getFunctionNumber() << "_" << loop->getHeader()->getNumber();
18421842 }
18431843
18441844 if (loop->empty()) {
18451845 O << '\n';
1846 O.PadToColumn(TAI->getCommentColumn());
1847 O << TAI->getCommentString() << " Inner Loop";
1846 O.PadToColumn(MAI->getCommentColumn());
1847 O << MAI->getCommentString() << " Inner Loop";
18481848 }
18491849
18501850 // Add parent loop information
18551855 assert(Header && "No header for loop");
18561856
18571857 O << '\n';
1858 O.PadToColumn(TAI->getCommentColumn());
1859 O << TAI->getCommentString();
1858 O.PadToColumn(MAI->getCommentColumn());
1859 O << MAI->getCommentString();
18601860 Indent(O, CurLoop->getLoopDepth()-1)
18611861 << " Inside Loop BB" << getFunctionNumber() << "_"
18621862 << Header->getNumber() << " Depth " << CurLoop->getLoopDepth();
13331333
13341334 // Print out .file directives to specify files for .loc directives. These are
13351335 // printed out early so that they precede any .loc directives.
1336 if (TAI->hasDotLocAndDotFile()) {
1336 if (MAI->hasDotLocAndDotFile()) {
13371337 for (unsigned i = 1, e = getNumSourceIds()+1; i != e; ++i) {
13381338 // Remember source id starts at 1.
13391339 std::pair Id = getSourceDirectoryAndFileIds(i);
16531653 unsigned Line, unsigned Col) {
16541654 unsigned LabelID = MMI->NextLabelID();
16551655
1656 if (!TAI->doesDwarfUsesInlineInfoSection())
1656 if (!MAI->doesDwarfUsesInlineInfoSection())
16571657 return LabelID;
16581658
16591659 if (TimePassesIsEnabled)
17311731
17321732 /// RecordInlinedFnEnd - Indicate the end of inlined subroutine.
17331733 unsigned DwarfDebug::RecordInlinedFnEnd(DISubprogram &SP) {
1734 if (!TAI->doesDwarfUsesInlineInfoSection())
1734 if (!MAI->doesDwarfUsesInlineInfoSection())
17351735 return 0;
17361736
17371737 if (TimePassesIsEnabled)
18431843 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
18441844
18451845 // Dwarf sections base addresses.
1846 if (TAI->doesDwarfRequireFrameSection()) {
1846 if (MAI->doesDwarfRequireFrameSection()) {
18471847 Asm->OutStreamer.SwitchSection(TLOF.getDwarfFrameSection());
18481848 EmitLabel("section_debug_frame", 0);
18491849 }
20362036 void DwarfDebug::EmitDebugLines() {
20372037 // If the target is using .loc/.file, the assembler will be emitting the
20382038 // .debug_line table automatically.
2039 if (TAI->hasDotLocAndDotFile())
2039 if (MAI->hasDotLocAndDotFile())
20402040 return;
20412041
20422042 // Minimum line delta, thus ranging from -10..(255-10).
21152115
21162116 /*if (Asm->isVerbose()) {
21172117 const MCSection *S = SectionMap[j + 1];
2118 O << '\t' << TAI->getCommentString() << " Section"
2118 O << '\t' << MAI->getCommentString() << " Section"
21192119 << S->getName() << '\n';
21202120 }*/
21212121 Asm->EOL();
21352135 else {
21362136 std::pair SourceID =
21372137 getSourceDirectoryAndFileIds(LineInfo.getSourceID());
2138 O << '\t' << TAI->getCommentString() << ' '
2138 O << '\t' << MAI->getCommentString() << ' '
21392139 << getSourceDirectoryName(SourceID.first) << ' '
21402140 << getSourceFileName(SourceID.second)
21412141 <<" :" << utostr_32(LineInfo.getLine()) << '\n';
21962196 /// EmitCommonDebugFrame - Emit common frame info into a debug frame section.
21972197 ///
21982198 void DwarfDebug::EmitCommonDebugFrame() {
2199 if (!TAI->doesDwarfRequireFrameSection())
2199 if (!MAI->doesDwarfRequireFrameSection())
22002200 return;
22012201
22022202 int stackGrowth =
22422242 /// section.
22432243 void
22442244 DwarfDebug::EmitFunctionDebugFrame(const FunctionDebugFrameInfo&DebugFrameInfo){
2245 if (!TAI->doesDwarfRequireFrameSection())
2245 if (!MAI->doesDwarfRequireFrameSection())
22462246 return;
22472247
22482248 // Start the dwarf frame section.
24262426 /// __debug_info section, and the low_pc is the starting address for the
24272427 /// inlining instance.
24282428 void DwarfDebug::EmitDebugInlineInfo() {
2429 if (!TAI->doesDwarfUsesInlineInfoSection())
2429 if (!MAI->doesDwarfUsesInlineInfoSection())
24302430 return;
24312431
24322432 if (!ModuleCU)
24782478 Asm->EmitInt32(SP->getOffset()); Asm->EOL("DIE offset");
24792479
24802480 if (TD->getPointerSize() == sizeof(int32_t))
2481 O << TAI->getData32bitsDirective();
2481 O << MAI->getData32bitsDirective();
24822482 else
2483 O << TAI->getData64bitsDirective();
2483 O << MAI->getData64bitsDirective();
24842484
24852485 PrintLabelName("label", *LI); Asm->EOL("low_pc");
24862486 }
5959 // Begin eh frame section.
6060 Asm->OutStreamer.SwitchSection(Asm->getObjFileLowering().getEHFrameSection());
6161
62 if (TAI->is_EHSymbolPrivate())
63 O << TAI->getPrivateGlobalPrefix();
62 if (MAI->is_EHSymbolPrivate())
63 O << MAI->getPrivateGlobalPrefix();
6464
6565 O << "EH_frame" << Index << ":\n";
6666 EmitLabel("section_eh_frame", Index);
9898 Asm->EmitULEB128Bytes(7);
9999 Asm->EOL("Augmentation Size");
100100
101 if (TAI->getNeedsIndirectEncoding()) {
101 if (MAI->getNeedsIndirectEncoding()) {
102102 Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4 |
103103 dwarf::DW_EH_PE_indirect);
104104 Asm->EOL("Personality (pcrel sdata4 indirect)");
108108 }
109109
110110 PrintRelDirective(true);
111 O << TAI->getPersonalityPrefix();
111 O << MAI->getPersonalityPrefix();
112112 Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
113 O << TAI->getPersonalitySuffix();
114 if (strcmp(TAI->getPersonalitySuffix(), "+4@GOTPCREL"))
115 O << "-" << TAI->getPCSymbol();
113 O << MAI->getPersonalitySuffix();
114 if (strcmp(MAI->getPersonalitySuffix(), "+4@GOTPCREL"))
115 O << "-" << MAI->getPCSymbol();
116116 Asm->EOL("Personality");
117117
118118 Asm->EmitInt8(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4);
156156 // Externally visible entry into the functions eh frame info. If the
157157 // corresponding function is static, this should not be externally visible.
158158 if (!TheFunc->hasLocalLinkage())
159 if (const char *GlobalEHDirective = TAI->getGlobalEHDirective())
159 if (const char *GlobalEHDirective = MAI->getGlobalEHDirective())
160160 O << GlobalEHDirective << EHFrameInfo.FnName << "\n";
161161
162162 // If corresponding function is weak definition, this should be too.
163 if (TheFunc->isWeakForLinker() && TAI->getWeakDefDirective())
164 O << TAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
163 if (TheFunc->isWeakForLinker() && MAI->getWeakDefDirective())
164 O << MAI->getWeakDefDirective() << EHFrameInfo.FnName << "\n";
165165
166166 // If there are no calls then you can't unwind. This may mean we can omit the
167167 // EH Frame, but some environments do not handle weak absolute symbols. If
169169 // info is to be available for non-EH uses.
170170 if (!EHFrameInfo.hasCalls && !UnwindTablesMandatory &&
171171 (!TheFunc->isWeakForLinker() ||
172 !TAI->getWeakDefDirective() ||
173 TAI->getSupportsWeakOmittedEHFrame())) {
172 !MAI->getWeakDefDirective() ||
173 MAI->getSupportsWeakOmittedEHFrame())) {
174174 O << EHFrameInfo.FnName << " = 0\n";
175175 // This name has no connection to the function, so it might get
176176 // dead-stripped when the function is not, erroneously. Prohibit
177177 // dead-stripping unconditionally.
178 if (const char *UsedDirective = TAI->getUsedDirective())
178 if (const char *UsedDirective = MAI->getUsedDirective())
179179 O << UsedDirective << EHFrameInfo.FnName << "\n\n";
180180 } else {
181181 O << EHFrameInfo.FnName << ":\n";
232232 // on unused functions (calling undefined externals) being dead-stripped to
233233 // link correctly. Yes, there really is.
234234 if (MMI->isUsedFunction(EHFrameInfo.function))
235 if (const char *UsedDirective = TAI->getUsedDirective())
235 if (const char *UsedDirective = MAI->getUsedDirective())
236236 O << UsedDirective << EHFrameInfo.FnName << "\n\n";
237237 }
238238 }
429429 // create a call-site entry with no landing pad for the region between the
430430 // try-ranges.
431431 if (SawPotentiallyThrowing &&
432 TAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
432 MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
433433 CallSiteEntry Site = { LastLabel, BeginLabel, 0, 0 };
434434 CallSites.push_back(Site);
435435 PreviousIsInvoke = false;
471471 // function may throw, create a call-site entry with no landing pad for the
472472 // region following the try-range.
473473 if (SawPotentiallyThrowing &&
474 TAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
474 MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf) {
475475 CallSiteEntry Site = { LastLabel, 0, 0, 0 };
476476 CallSites.push_back(Site);
477477 }
545545 const unsigned LandingPadSize = sizeof(int32_t); // DW_EH_PE_udata4
546546 unsigned SizeSites;
547547
548 bool HaveTTData = (TAI->getExceptionHandlingType() == ExceptionHandling::SjLj)
548 bool HaveTTData = (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj)
549549 ? (!TypeInfos.empty() || !FilterIds.empty()) : true;
550550
551551
552 if (TAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
552 if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
553553 SizeSites = 0;
554554 } else
555555 SizeSites = CallSites.size() *
556556 (SiteStartSize + SiteLengthSize + LandingPadSize);
557557 for (unsigned i = 0, e = CallSites.size(); i < e; ++i) {
558558 SizeSites += MCAsmInfo::getULEB128Size(CallSites[i].Action);
559 if (TAI->getExceptionHandlingType() == ExceptionHandling::SjLj)
559 if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj)
560560 SizeSites += MCAsmInfo::getULEB128Size(i);
561561 }
562562 // Type infos.
587587 }
588588
589589 EmitLabel("exception", SubprogramCount);
590 if (TAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
590 if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
591591 std::string SjLjName = "_lsda_";
592592 SjLjName += MF->getFunction()->getName().str();
593593 EmitLabel(SjLjName.c_str(), 0);
656656 #endif
657657
658658 // SjLj Exception handilng
659 if (TAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
659 if (MAI->getExceptionHandlingType() == ExceptionHandling::SjLj) {
660660 Asm->EmitInt8(dwarf::DW_EH_PE_udata4);
661661 Asm->EOL("Call site format (DW_EH_PE_udata4)");
662662 Asm->EmitULEB128Bytes(SizeSites);
681681 }
682682 } else {
683683 // DWARF Exception handling
684 assert(TAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
684 assert(MAI->getExceptionHandlingType() == ExceptionHandling::Dwarf);
685685
686686 // The call-site table is a list of all call sites that may throw an
687687 // exception (including C++ 'throw' statements) in the procedure
835835 /// EndModule - Emit all exception information that should come after the
836836 /// content.
837837 void DwarfException::EndModule() {
838 if (TAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
838 if (MAI->getExceptionHandlingType() != ExceptionHandling::Dwarf)
839839 return;
840840 if (TimePassesIsEnabled)
841841 ExceptionTimer->startTimer();
863863 this->MF = MF;
864864 shouldEmitTable = shouldEmitMoves = false;
865865
866 if (MMI && TAI->doesSupportExceptionHandling()) {
866 if (MMI && MAI->doesSupportExceptionHandling()) {
867867 // Map all labels and get rid of any dead landing pads.
868868 MMI->TidyLandingPads();
869869
2727
2828 Dwarf::Dwarf(raw_ostream &OS, AsmPrinter *A, const MCAsmInfo *T,
2929 const char *flavor)
30 : O(OS), Asm(A), TAI(T), TD(Asm->TM.getTargetData()),
30 : O(OS), Asm(A), MAI(T), TD(Asm->TM.getTargetData()),
3131 RI(Asm->TM.getRegisterInfo()), M(NULL), MF(NULL), MMI(NULL),
3232 SubprogramCount(0), Flavor(flavor), SetCounter(1) {}
3333
3434 void Dwarf::PrintRelDirective(bool Force32Bit, bool isInSection) const {
35 if (isInSection && TAI->getDwarfSectionOffsetDirective())
36 O << TAI->getDwarfSectionOffsetDirective();
35 if (isInSection && MAI->getDwarfSectionOffsetDirective())
36 O << MAI->getDwarfSectionOffsetDirective();
3737 else if (Force32Bit || TD->getPointerSize() == sizeof(int32_t))
38 O << TAI->getData32bitsDirective();
38 O << MAI->getData32bitsDirective();
3939 else
40 O << TAI->getData64bitsDirective();
40 O << MAI->getData64bitsDirective();
4141 }
4242
4343 /// PrintLabelName - Print label name in form used by Dwarf writer.
4444 ///
4545 void Dwarf::PrintLabelName(const char *Tag, unsigned Number) const {
46 O << TAI->getPrivateGlobalPrefix() << Tag;
46 O << MAI->getPrivateGlobalPrefix() << Tag;
4747 if (Number) O << Number;
4848 }
4949 void Dwarf::PrintLabelName(const char *Tag, unsigned Number,
5050 const char *Suffix) const {
51 O << TAI->getPrivateGlobalPrefix() << Tag;
51 O << MAI->getPrivateGlobalPrefix() << Tag;
5252 if (Number) O << Number;
5353 O << Suffix;
5454 }
6666 bool IsPCRelative, bool Force32Bit) const {
6767 PrintRelDirective(Force32Bit);
6868 PrintLabelName(Tag, Number);
69 if (IsPCRelative) O << "-" << TAI->getPCSymbol();
69 if (IsPCRelative) O << "-" << MAI->getPCSymbol();
7070 }
7171 void Dwarf::EmitReference(const std::string &Name, bool IsPCRelative,
7272 bool Force32Bit) const {
7373 PrintRelDirective(Force32Bit);
7474 O << Name;
75 if (IsPCRelative) O << "-" << TAI->getPCSymbol();
75 if (IsPCRelative) O << "-" << MAI->getPCSymbol();
7676 }
7777
7878 /// EmitDifference - Emit the difference between two labels. Some assemblers do
8181 void Dwarf::EmitDifference(const char *TagHi, unsigned NumberHi,
8282 const char *TagLo, unsigned NumberLo,
8383 bool IsSmall) {
84 if (TAI->needsSet()) {
84 if (MAI->needsSet()) {
8585 O << "\t.set\t";
8686 PrintLabelName("set", SetCounter, Flavor);
8787 O << ",";
107107 bool useSet) {
108108 bool printAbsolute = false;
109109 if (isEH)
110 printAbsolute = TAI->isAbsoluteEHSectionOffsets();
110 printAbsolute = MAI->isAbsoluteEHSectionOffsets();
111111 else
112 printAbsolute = TAI->isAbsoluteDebugSectionOffsets();
113
114 if (TAI->needsSet() && useSet) {
112 printAbsolute = MAI->isAbsoluteDebugSectionOffsets();
113
114 if (MAI->needsSet() && useSet) {
115115 O << "\t.set\t";
116116 PrintLabelName("set", SetCounter, Flavor);
117117 O << ",";
4242 ///
4343 AsmPrinter *Asm;
4444
45 /// TAI - Target asm information.
45 /// MAI - Target asm information.
4646 ///
47 const MCAsmInfo *TAI;
47 const MCAsmInfo *MAI;
4848
4949 /// TD - Target data.
5050 ///
8787 //
8888 const AsmPrinter *getAsm() const { return Asm; }
8989 MachineModuleInfo *getMMI() const { return MMI; }
90 const MCAsmInfo *getMCAsmInfo() const { return TAI; }
90 const MCAsmInfo *getMCAsmInfo() const { return MAI; }
9191 const TargetData *getTargetData() const { return TD; }
9292
9393 void PrintRelDirective(bool Force32Bit = false,
2929 class VISIBILITY_HIDDEN OcamlGCMetadataPrinter : public GCMetadataPrinter {
3030 public:
3131 void beginAssembly(raw_ostream &OS, AsmPrinter &AP,
32 const MCAsmInfo &TAI);
32 const MCAsmInfo &MAI);
3333
3434 void finishAssembly(raw_ostream &OS, AsmPrinter &AP,
35 const MCAsmInfo &TAI);
35 const MCAsmInfo &MAI);
3636 };
3737
3838 }
4343 void llvm::linkOcamlGCPrinter() { }
4444
4545 static void EmitCamlGlobal(const Module &M, raw_ostream &OS, AsmPrinter &AP,
46 const MCAsmInfo &TAI, const char *Id) {
46 const MCAsmInfo &MAI, const char *Id) {
4747 const std::string &MId = M.getModuleIdentifier();
4848
4949 std::string Mangled;
50 Mangled += TAI.getGlobalPrefix();
50 Mangled += MAI.getGlobalPrefix();
5151 Mangled += "caml";
5252 size_t Letter = Mangled.size();
5353 Mangled.append(MId.begin(), std::find(MId.begin(), MId.end(), '.'));
5757 // Capitalize the first letter of the module name.
5858 Mangled[Letter] = toupper(Mangled[Letter]);
5959
60 if (const char *GlobalDirective = TAI.getGlobalDirective())
60 if (const char *GlobalDirective = MAI.getGlobalDirective())
6161 OS << GlobalDirective << Mangled << "\n";
6262 OS << Mangled << ":\n";
6363 }
6464
6565 void OcamlGCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
66 const MCAsmInfo &TAI) {
66 const MCAsmInfo &MAI) {
6767 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
68 EmitCamlGlobal(getModule(), OS, AP, TAI, "code_begin");
68 EmitCamlGlobal(getModule(), OS, AP, MAI, "code_begin");
6969
7070 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
71 EmitCamlGlobal(getModule(), OS, AP, TAI, "data_begin");
71 EmitCamlGlobal(getModule(), OS, AP, MAI, "data_begin");
7272 }
7373
7474 /// emitAssembly - Print the frametable. The ocaml frametable format is thus:
8888 /// either condition is detected in a function which uses the GC.
8989 ///
9090 void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
91 const MCAsmInfo &TAI) {
91 const MCAsmInfo &MAI) {
9292 const char *AddressDirective;
9393 int AddressAlignLog;
9494 if (AP.TM.getTargetData()->getPointerSize() == sizeof(int32_t)) {
95 AddressDirective = TAI.getData32bitsDirective();
95 AddressDirective = MAI.getData32bitsDirective();
9696 AddressAlignLog = 2;
9797 } else {
98 AddressDirective = TAI.getData64bitsDirective();
98 AddressDirective = MAI.getData64bitsDirective();
9999 AddressAlignLog = 3;
100100 }
101101
102102 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getTextSection());
103 EmitCamlGlobal(getModule(), OS, AP, TAI, "code_end");
103 EmitCamlGlobal(getModule(), OS, AP, MAI, "code_end");
104104
105105 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
106 EmitCamlGlobal(getModule(), OS, AP, TAI, "data_end");
106 EmitCamlGlobal(getModule(), OS, AP, MAI, "data_end");
107107
108108 OS << AddressDirective << 0; // FIXME: Why does ocaml emit this??
109109 AP.EOL();
110110
111111 AP.OutStreamer.SwitchSection(AP.getObjFileLowering().getDataSection());
112 EmitCamlGlobal(getModule(), OS, AP, TAI, "frametable");
112 EmitCamlGlobal(getModule(), OS, AP, MAI, "frametable");
113113
114114 for (iterator I = begin(), IE = end(); I != IE; ++I) {
115115 GCFunctionInfo &FI = **I;
125125 llvm_report_error(Msg.str()); // Very rude!
126126 }
127127
128 OS << "\t" << TAI.getCommentString() << " live roots for "
128 OS << "\t" << MAI.getCommentString() << " live roots for "
129129 << FI.getFunction().getName() << "\n";
130130
131131 for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
140140 }
141141
142142 OS << AddressDirective
143 << TAI.getPrivateGlobalPrefix() << "label" << J->Num;
143 << MAI.getPrivateGlobalPrefix() << "label" << J->Num;
144144 AP.EOL("call return address");
145145
146146 AP.EmitInt16(FrameSize);
7979 isLittleEndian(TM.getTargetData()->isLittleEndian()),
8080 ElfHdr(isLittleEndian, is64Bit) {
8181
82 TAI = TM.getMCAsmInfo();
82 MAI = TM.getMCAsmInfo();
8383 TEW = TM.getELFWriterInfo();
8484
8585 // Create the object code emitter object for this target.
686686 SymbolList.push_back(ELFSym::getExtSym(*I));
687687
688688 // Emit non-executable stack note
689 if (TAI->getNonexecutableStackDirective())
689 if (MAI->getNonexecutableStackDirective())
690690 getNonExecStackSection();
691691
692692 // Emit a symbol for each section created until now, skip null section
8585 /// and other object file specific stuff
8686 const TargetLoweringObjectFile &TLOF;
8787
88 /// TAI - Target Asm Info, provide information about section names for
88 /// MAI - Target Asm Info, provide information about section names for
8989 /// globals and other target specific stuff.
90 const MCAsmInfo *TAI;
90 const MCAsmInfo *MAI;
9191
9292 //===------------------------------------------------------------------===//
9393 // Properties inferred automatically from the target machine.
117117 unsigned NumSections; // Always = SectionList.size()
118118
119119 /// SectionLookup - This is a mapping from section name to section number in
120 /// the SectionList. Used to quickly gather the Section Index from TAI names
120 /// the SectionList. Used to quickly gather the Section Index from MAI names
121121 std::map SectionLookup;
122122
123123 /// PendingGlobals - Globals not processed as symbols yet.
1919 GCMetadataPrinter::~GCMetadataPrinter() { }
2020
2121 void GCMetadataPrinter::beginAssembly(raw_ostream &OS, AsmPrinter &AP,
22 const MCAsmInfo &TAI) {
22 const MCAsmInfo &MAI) {
2323 // Default is no action.
2424 }
2525
2626 void GCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
27 const MCAsmInfo &TAI) {
27 const MCAsmInfo &MAI) {
2828 // Default is no action.
2929 }
6767 };
6868
6969 MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
70 const MCAsmInfo *TAI);
70 const MCAsmInfo *MAI);
7171
7272 struct SymCmp {
7373 // FIXME: this does not appear to be sorting 'f' after 'F'
3434 ObjectCodeEmitter(&mos), MOW(mow), TM(MOW.TM) {
3535 is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
3636 isLittleEndian = TM.getTargetData()->isLittleEndian();
37 TAI = TM.getMCAsmInfo();
37 MAI = TM.getMCAsmInfo();
3838 }
3939
4040 /// startFunction - This callback is invoked when a new machine function is
6060
6161 // Create symbol for function entry
6262 const GlobalValue *FuncV = MF.getFunction();
63 MachOSym FnSym(FuncV, MOW.Mang->getMangledName(FuncV), MOS->Index, TAI);
63 MachOSym FnSym(FuncV, MOW.Mang->getMangledName(FuncV), MOS->Index, MAI);
6464 FnSym.n_value = getCurrentPCOffset();
6565
6666 // add it to the symtab.
2929 /// machine directly, indicating what header values and flags to set.
3030 bool is64Bit, isLittleEndian;
3131
32 const MCAsmInfo *TAI;
32 const MCAsmInfo *MAI;
3333
3434 /// Relocations - These are the relocations that the function needs, as
3535 /// emitted.
6060 is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
6161 isLittleEndian = TM.getTargetData()->isLittleEndian();
6262
63 TAI = TM.getMCAsmInfo();
63 MAI = TM.getMCAsmInfo();
6464
6565 // Create the machine code emitter object for this target.
6666 MachOCE = new MachOCodeEmitter(*this, *getTextSection(true));
220220 }
221221 // Globals without external linkage apparently do not go in the symbol table.
222222 if (!GV->hasLocalLinkage()) {
223 MachOSym Sym(GV, Mang->getMangledName(GV), Sec->Index, TAI);
223 MachOSym Sym(GV, Mang->getMangledName(GV), Sec->Index, MAI);
224224 Sym.n_value = Sec->size();
225225 SymbolTable.push_back(Sym);
226226 }
255255 if (NoInit || GV->hasLinkOnceLinkage() || GV->hasWeakLinkage() ||
256256 GV->hasCommonLinkage()) {
257257 MachOSym ExtOrCommonSym(GV, Mang->getMangledName(GV),
258 MachOSym::NO_SECT, TAI);
258 MachOSym::NO_SECT, MAI);
259259 // For undefined (N_UNDF) external (N_EXT) types, n_value is the size in
260260 // bytes of the symbol.
261261 ExtOrCommonSym.n_value = Size;
453453 for (std::vector::iterator I = PendingGlobals.begin(),
454454 E = PendingGlobals.end(); I != E; ++I) {
455455 if (GVOffset[*I] == 0 && GVSection[*I] == 0) {
456 MachOSym UndfSym(*I, Mang->getMangledName(*I), MachOSym::NO_SECT, TAI);
456 MachOSym UndfSym(*I, Mang->getMangledName(*I), MachOSym::NO_SECT, MAI);
457457 SymbolTable.push_back(UndfSym);
458458 GVOffset[*I] = -1;
459459 }
742742 //===----------------------------------------------------------------------===//
743743
744744 MachOSym::MachOSym(const GlobalValue *gv, std::string name, uint8_t sect,
745 const MCAsmInfo *TAI) :
745 const MCAsmInfo *MAI) :
746746 GV(gv), n_strx(0), n_type(sect == NO_SECT ? N_UNDF : N_SECT), n_sect(sect),
747747 n_desc(0), n_value(0) {
748748
758758 case GlobalValue::CommonLinkage:
759759 assert(!isa(gv) && "Unexpected linkage type for Function!");
760760 case GlobalValue::ExternalLinkage:
761 GVName = TAI->getGlobalPrefix() + name;
761 GVName = MAI->getGlobalPrefix() + name;
762762 n_type |= GV->hasHiddenVisibility() ? N_PEXT : N_EXT;
763763 break;
764764 case GlobalValue::PrivateLinkage:
765 GVName = TAI->getPrivateGlobalPrefix() + name;
765 GVName = MAI->getPrivateGlobalPrefix() + name;
766766 break;
767767 case GlobalValue::LinkerPrivateLinkage:
768 GVName = TAI->getLinkerPrivateGlobalPrefix() + name;
768 GVName = MAI->getLinkerPrivateGlobalPrefix() + name;
769769 break;
770770 case GlobalValue::InternalLinkage:
771 GVName = TAI->getGlobalPrefix() + name;
771 GVName = MAI->getGlobalPrefix() + name;
772772 break;
773773 }
774774 }
7777 bool is64Bit, isLittleEndian;
7878
7979 // Target Asm Info
80 const MCAsmInfo *TAI;
80 const MCAsmInfo *MAI;
8181
8282 /// Header - An instance of MachOHeader that we will update while we build
8383 /// the file, and then emit during finalization.
6565 UsedDirective = 0;
6666 WeakRefDirective = 0;
6767 WeakDefDirective = 0;
68 // FIXME: These are ELFish - move to ELFTAI.
68 // FIXME: These are ELFish - move to ELFMAI.
6969 HiddenDirective = "\t.hidden\t";
7070 ProtectedDirective = "\t.protected\t";
7171 AbsoluteDebugSectionOffsets = false;
2323
2424 class MCAsmStreamer : public MCStreamer {
2525 raw_ostream &OS;
26 const MCAsmInfo &TAI;
26 const MCAsmInfo &MAI;
2727 AsmPrinter *Printer;
2828 public:
2929 MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const MCAsmInfo &tai,
3030 AsmPrinter *_AsmPrinter)
31 : MCStreamer(Context), OS(_OS), TAI(tai), Printer(_AsmPrinter) {}
31 : MCStreamer(Context), OS(_OS), MAI(tai), Printer(_AsmPrinter) {}
3232 ~MCAsmStreamer() {}
3333
3434 /// @name MCStreamer Interface
101101 assert(Section && "Cannot switch to a null section!");
102102 if (Section != CurSection) {
103103 CurSection = Section;
104 Section->PrintSwitchToSection(TAI, OS);
104 Section->PrintSwitchToSection(MAI, OS);
105105 }
106106 }
107107
229229 if (isPowerOf2_32(ByteAlignment)) {
230230 switch (ValueSize) {
231231 default: llvm_unreachable("Invalid size for machine code value!");
232 case 1: OS << TAI.getAlignDirective(); break;
233 // FIXME: use TAI for this!
232 case 1: OS << MAI.getAlignDirective(); break;
233 // FIXME: use MAI for this!
234234 case 2: OS << ".p2alignw "; break;
235235 case 4: OS << ".p2alignl "; break;
236236 case 8: llvm_unreachable("Unsupported alignment size!");
237237 }
238238
239 if (TAI.getAlignmentIsInBytes())
239 if (MAI.getAlignmentIsInBytes())
240240 OS << ByteAlignment;
241241 else
242242 OS << Log2_32(ByteAlignment);
252252 }
253253
254254 // Non-power of two alignment. This is not widely supported by assemblers.
255 // FIXME: Parameterize this based on TAI.
255 // FIXME: Parameterize this based on MAI.
256256 switch (ValueSize) {
257257 default: llvm_unreachable("Invalid size for machine code value!");
258258 case 1: OS << ".balign"; break;
313313 }
314314
315315 MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS,
316 const MCAsmInfo &TAI, AsmPrinter *AP) {
317 return new MCAsmStreamer(Context, OS, TAI, AP);
318 }
316 const MCAsmInfo &MAI, AsmPrinter *AP) {
317 return new MCAsmStreamer(Context, OS, MAI, AP);
318 }
2828 return new (Ctx) MCSectionCOFF(Name, IsDirective, K);
2929 }
3030
31 void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &TAI,
31 void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
3232 raw_ostream &OS) const {
3333
3434 if (isDirective()) {
2222 // ShouldOmitSectionDirective - Decides whether a '.section' directive
2323 // should be printed before the section name
2424 bool MCSectionELF::ShouldOmitSectionDirective(const char *Name,
25 const MCAsmInfo &TAI) const {
25 const MCAsmInfo &MAI) const {
2626
2727 // FIXME: Does .section .bss/.data/.text work everywhere??
2828 if (strcmp(Name, ".text") == 0 ||
2929 strcmp(Name, ".data") == 0 ||
3030 (strcmp(Name, ".bss") == 0 &&
31 !TAI.usesELFSectionDirectiveForBSS()))
31 !MAI.usesELFSectionDirectiveForBSS()))
3232 return true;
3333
3434 return false;
4343 return true;
4444 }
4545
46 void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &TAI,
46 void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
4747 raw_ostream &OS) const {
4848
49 if (ShouldOmitSectionDirective(SectionName.c_str(), TAI)) {
49 if (ShouldOmitSectionDirective(SectionName.c_str(), MAI)) {
5050 OS << '\t' << getSectionName() << '\n';
5151 return;
5252 }
5454 OS << "\t.section\t" << getSectionName();
5555
5656 // Handle the weird solaris syntax if desired.
57 if (TAI.usesSunStyleELFSectionSwitchSyntax() &&
57 if (MAI.usesSunStyleELFSectionSwitchSyntax() &&
5858 !(Flags & MCSectionELF::SHF_MERGE)) {
5959 if (Flags & MCSectionELF::SHF_ALLOC)
6060 OS << ",#alloc";
8181
8282 // If there are target-specific flags, print them.
8383 if (Flags & ~MCSectionELF::TARGET_INDEP_SHF)
84 PrintTargetSpecificSectionFlags(TAI, OS);
84 PrintTargetSpecificSectionFlags(MAI, OS);
8585
8686 OS << '"';
8787
8989 OS << ',';
9090
9191 // If comment string is '@', e.g. as on ARM - use '%' instead
92 if (TAI.getCommentString()[0] == '@')
92 if (MAI.getCommentString()[0] == '@')
9393 OS << '%';
9494 else
9595 OS << '@';
7171 Reserved2, K);
7272 }
7373
74 void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &TAI,
74 void MCSectionMachO::PrintSwitchToSection(const MCAsmInfo &MAI,
7575 raw_ostream &OS) const {
7676 OS << "\t.section\t" << getSegmentName() << ',' << getSectionName();
7777
404404 unsigned ARMBaseInstrInfo::GetInstSizeInBytes(const MachineInstr *MI) const {
405405 const MachineBasicBlock &MBB = *MI->getParent();
406406 const MachineFunction *MF = MBB.getParent();
407 const MCAsmInfo *TAI = MF->getTarget().getMCAsmInfo();
407 const MCAsmInfo *MAI = MF->getTarget().getMCAsmInfo();
408408
409409 // Basic size info comes from the TSFlags field.
410410 const TargetInstrDesc &TID = MI->getDesc();
415415 default: {
416416 // If this machine instr is an inline asm, measure it.
417417 if (MI->getOpcode() == ARM::INLINEASM)
418 return getInlineAsmLength(MI->getOperand(0).getSymbolName(), *TAI);
418 return getInlineAsmLength(MI->getOperand(0).getSymbolName(), *MAI);
419419 if (MI->isLabel())
420420 return 0;
421421 switch (Opc) {
220220
221221 if (ACPV->hasModifier()) O << "(" << ACPV->getModifier() << ")";
222222 if (ACPV->getPCAdjustment() != 0) {
223 O << "-(" << TAI->getPrivateGlobalPrefix() << "PC"
223 O << "-(" << MAI->getPrivateGlobalPrefix() << "PC"
224224 << ACPV->getLabelId()
225225 << "+" << (unsigned)ACPV->getPCAdjustment();
226226 if (ACPV->mustAddCurrentAddress())
279279 O << "\t.globl\t" << CurrentFnName << "\n";
280280 O << "\t.weak_definition\t" << CurrentFnName << "\n";
281281 } else {
282 O << TAI->getWeakRefDirective() << CurrentFnName << "\n";
282 O << MAI->getWeakRefDirective() << CurrentFnName << "\n";
283283 }
284284 break;
285285 }
327327 }
328328 }
329329
330 if (TAI->hasDotTypeDotSizeDirective())
330 if (MAI->hasDotTypeDotSizeDirective())
331331 O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
332332
333333 // Emit post-function debug information.
409409 break;
410410 }
411411 case MachineOperand::MO_ConstantPoolIndex:
412 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
412 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
413413 << '_' << MO.getIndex();
414414 break;
415415 case MachineOperand::MO_JumpTableIndex:
416 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
416 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
417417 << '_' << MO.getIndex();
418418 break;
419419 default:
422422 }
423423
424424 static void printSOImm(formatted_raw_ostream &O, int64_t V, bool VerboseAsm,
425 const MCAsmInfo *TAI) {
425 const MCAsmInfo *MAI) {
426426 // Break it up into two parts that make up a shifter immediate.
427427 V = ARM_AM::getSOImmVal(V);
428428 assert(V != -1 && "Not a valid so_imm value!");
436436 O << "#" << Imm << ", " << Rot;
437437 // Pretty printed version.
438438 if (VerboseAsm)
439 O << ' ' << TAI->getCommentString()
439 O << ' ' << MAI->getCommentString()
440440 << ' ' << (int)ARM_AM::rotr32(Imm, Rot);
441441 } else {
442442 O << "#" << Imm;
448448 void ARMAsmPrinter::printSOImmOperand(const MachineInstr *MI, int OpNum) {
449449 const MachineOperand &MO = MI->getOperand(OpNum);
450450 assert(MO.isImm() && "Not a valid so_imm value!");
451 printSOImm(O, MO.getImm(), VerboseAsm, TAI);
451 printSOImm(O, MO.getImm(), VerboseAsm, MAI);
452452 }
453453
454454 /// printSOImm2PartOperand - SOImm is broken into two pieces using a 'mov'
458458 assert(MO.isImm() && "Not a valid so_imm value!");
459459 unsigned V1 = ARM_AM::getSOImmTwoPartFirst(MO.getImm());
460460 unsigned V2 = ARM_AM::getSOImmTwoPartSecond(MO.getImm());
461 printSOImm(O, V1, VerboseAsm, TAI);
461 printSOImm(O, V1, VerboseAsm, MAI);
462462 O << "\n\torr";
463463 printPredicateOperand(MI, 2);
464464 O << " ";
466466 O << ", ";
467467 printOperand(MI, 0);
468468 O << ", ";
469 printSOImm(O, V2, VerboseAsm, TAI);
469 printSOImm(O, V2, VerboseAsm, MAI);
470470 }
471471
472472 // so_reg is a 4-operand unit corresponding to register forms of the A5.1
880880
881881 void ARMAsmPrinter::printPCLabel(const MachineInstr *MI, int OpNum) {
882882 int Id = (int)MI->getOperand(OpNum).getImm();
883 O << TAI->getPrivateGlobalPrefix() << "PC" << Id;
883 O << MAI->getPrivateGlobalPrefix() << "PC" << Id;
884884 }
885885
886886 void ARMAsmPrinter::printRegisterList(const MachineInstr *MI, int OpNum) {
901901 // data itself.
902902 if (!strcmp(Modifier, "label")) {
903903 unsigned ID = MI->getOperand(OpNum).getImm();
904 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
904 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
905905 << '_' << ID << ":\n";
906906 } else {
907907 assert(!strcmp(Modifier, "cpentry") && "Unknown modifier for CPE");
923923 const MachineOperand &MO1 = MI->getOperand(OpNum);
924924 const MachineOperand &MO2 = MI->getOperand(OpNum+1); // Unique Id
925925 unsigned JTI = MO1.getIndex();
926 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
926 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
927927 << '_' << JTI << '_' << MO2.getImm() << ":\n";
928928
929 const char *JTEntryDirective = TAI->getData32bitsDirective();
929 const char *JTEntryDirective = MAI->getData32bitsDirective();
930930
931931 const MachineFunction *MF = MI->getParent()->getParent();
932932 const MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
933933 const std::vector &JT = MJTI->getJumpTables();
934934 const std::vector &JTBBs = JT[JTI].MBBs;
935 bool UseSet= TAI->getSetDirective() && TM.getRelocationModel() == Reloc::PIC_;
935 bool UseSet= MAI->getSetDirective() && TM.getRelocationModel() == Reloc::PIC_;
936936 SmallPtrSet JTSets;
937937 for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
938938 MachineBasicBlock *MBB = JTBBs[i];
943943
944944 O << JTEntryDirective << ' ';
945945 if (UseSet)
946 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
946 O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
947947 << '_' << JTI << '_' << MO2.getImm()
948948 << "_set_" << MBB->getNumber();
949949 else if (TM.getRelocationModel() == Reloc::PIC_) {
950950 printBasicBlockLabel(MBB, false, false, false);
951 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
951 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI"
952952 << getFunctionNumber() << '_' << JTI << '_' << MO2.getImm();
953953 } else {
954954 printBasicBlockLabel(MBB, false, false, false);
962962 const MachineOperand &MO1 = MI->getOperand(OpNum);
963963 const MachineOperand &MO2 = MI->getOperand(OpNum+1); // Unique Id
964964 unsigned JTI = MO1.getIndex();
965 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
965 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
966966 << '_' << JTI << '_' << MO2.getImm() << ":\n";
967967
968968 const MachineFunction *MF = MI->getParent()->getParent();
978978 for (unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
979979 MachineBasicBlock *MBB = JTBBs[i];
980980 if (ByteOffset)
981 O << TAI->getData8bitsDirective();
981 O << MAI->getData8bitsDirective();
982982 else if (HalfWordOffset)
983 O << TAI->getData16bitsDirective();
983 O << MAI->getData16bitsDirective();
984984 if (ByteOffset || HalfWordOffset) {
985985 O << '(';
986986 printBasicBlockLabel(MBB, false, false, false);
987 O << "-" << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
987 O << "-" << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
988988 << '_' << JTI << '_' << MO2.getImm() << ")/2";
989989 } else {
990990 O << "\tb.w ";
11711171 // Don't put things that should go in the cstring section into "comm".
11721172 !TheSection->getKind().isMergeableCString()) {
11731173 if (GVar->hasExternalLinkage()) {
1174 if (const char *Directive = TAI->getZeroFillDirective()) {
1174 if (const char *Directive = MAI->getZeroFillDirective()) {
11751175 O << "\t.globl\t" << name << "\n";
11761176 O << Directive << "__DATA, __common, " << name << ", "
11771177 << Size << ", " << Align << "\n";
11841184
11851185 if (isDarwin) {
11861186 if (GVar->hasLocalLinkage()) {
1187 O << TAI->getLCOMMDirective() << name << "," << Size
1187 O << MAI->getLCOMMDirective() << name << "," << Size
11881188 << ',' << Align;
11891189 } else if (GVar->hasCommonLinkage()) {
1190 O << TAI->getCOMMDirective() << name << "," << Size
1190 O << MAI->getCOMMDirective() << name << "," << Size
11911191 << ',' << Align;
11921192 } else {
11931193 OutStreamer.SwitchSection(TheSection);
11941194 O << "\t.globl " << name << '\n'
1195 << TAI->getWeakDefDirective() << name << '\n';
1195 << MAI->getWeakDefDirective() << name << '\n';
11961196 EmitAlignment(Align, GVar);
11971197 O << name << ":";
11981198 if (VerboseAsm) {
1199 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
1199 O << "\t\t\t\t" << MAI->getCommentString() << ' ';
12001200 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12011201 }
12021202 O << '\n';
12031203 EmitGlobalConstant(C);
12041204 return;
12051205 }
1206 } else if (TAI->getLCOMMDirective() != NULL) {
1206 } else if (MAI->getLCOMMDirective() != NULL) {
12071207 if (GVar->hasLocalLinkage()) {
1208 O << TAI->getLCOMMDirective() << name << "," << Size;
1208 O << MAI->getLCOMMDirective() << name << "," << Size;
12091209 } else {
1210 O << TAI->getCOMMDirective() << name << "," << Size;
1211 if (TAI->getCOMMDirectiveTakesAlignment())
1212 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
1210 O << MAI->getCOMMDirective() << name << "," << Size;
1211 if (MAI->getCOMMDirectiveTakesAlignment())
1212 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
12131213 }
12141214 } else {
12151215 if (GVar->hasLocalLinkage())
12161216 O << "\t.local\t" << name << "\n";
1217 O << TAI->getCOMMDirective() << name << "," << Size;
1218 if (TAI->getCOMMDirectiveTakesAlignment())
1219 O << "," << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
1217 O << MAI->getCOMMDirective() << name << "," << Size;
1218 if (MAI->getCOMMDirectiveTakesAlignment())
1219 O << "," << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
12201220 }
12211221 if (VerboseAsm) {
1222 O << "\t\t" << TAI->getCommentString() << " ";
1222 O << "\t\t" << MAI->getCommentString() << " ";
12231223 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12241224 }
12251225 O << "\n";
12571257 EmitAlignment(Align, GVar);
12581258 O << name << ":";
12591259 if (VerboseAsm) {
1260 O << "\t\t\t\t" << TAI->getCommentString() << " ";
1260 O << "\t\t\t\t" << MAI->getCommentString() << " ";
12611261 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
12621262 }
12631263 O << "\n";
1264 if (TAI->hasDotTypeDotSizeDirective())
1264 if (MAI->hasDotTypeDotSizeDirective())
12651265 O << "\t.size " << name << ", " << Size << "\n";
12661266
12671267 EmitGlobalConstant(C);
9898 return;
9999
100100 case MachineOperand::MO_ConstantPoolIndex:
101 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
101 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
102102 << MO.getIndex();
103103 return;
104104
111111 return;
112112
113113 case MachineOperand::MO_JumpTableIndex:
114 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
114 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
115115 << '_' << MO.getIndex();
116116 return;
117117
154154 case Function::WeakODRLinkage:
155155 case Function::LinkOnceAnyLinkage:
156156 case Function::LinkOnceODRLinkage:
157 O << TAI->getWeakRefDirective() << CurrentFnName << "\n";
157 O << MAI->getWeakRefDirective() << CurrentFnName << "\n";
158158 break;
159159 }
160160
223223 case GlobalValue::WeakAnyLinkage:
224224 case GlobalValue::WeakODRLinkage:
225225 case GlobalValue::CommonLinkage:
226 O << TAI->getWeakRefDirective() << name << '\n';
226 O << MAI->getWeakRefDirective() << name << '\n';
227227 break;
228228 case GlobalValue::AppendingLinkage:
229229 case GlobalValue::ExternalLinkage:
230 O << TAI->getGlobalDirective() << name << "\n";
230 O << MAI->getGlobalDirective() << name << "\n";
231231 break;
232232 case GlobalValue::InternalLinkage:
233233 case GlobalValue::PrivateLinkage:
238238 }
239239
240240 // 3: Type, Size, Align
241 if (TAI->hasDotTypeDotSizeDirective()) {
241 if (MAI->hasDotTypeDotSizeDirective()) {
242242 O << "\t.type\t" << name << ", @object\n";
243243 O << "\t.size\t" << name << ", " << Size << "\n";
244244 }
3939 class VISIBILITY_HIDDEN BlackfinAsmPrinter : public AsmPrinter {
4040 public:
4141 BlackfinAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
42 const MCAsmInfo *TAI, bool V)
43 : AsmPrinter(O, TM, TAI, V) {}
42 const MCAsmInfo *MAI, bool V)
43 : AsmPrinter(O, TM, MAI, V) {}
4444
4545 virtual const char *getPassName() const {
4646 return "Blackfin Assembly Printer";
7474 case GlobalValue::LinkerPrivateLinkage:
7575 break;
7676 case GlobalValue::ExternalLinkage:
77 O << TAI->getGlobalDirective() << name << "\n";
77 O << MAI->getGlobalDirective() << name << "\n";
7878 break;
7979 case GlobalValue::LinkOnceAnyLinkage:
8080 case GlobalValue::LinkOnceODRLinkage:
8181 case GlobalValue::WeakAnyLinkage:
8282 case GlobalValue::WeakODRLinkage:
83 O << TAI->getGlobalDirective() << name << "\n";
84 O << TAI->getWeakDefDirective() << name << "\n";
83 O << MAI->getGlobalDirective() << name << "\n";
84 O << MAI->getWeakDefDirective() << name << "\n";
8585 break;
8686 }
8787 }
179179 O << Mang->makeNameProper(MO.getSymbolName());
180180 break;
181181 case MachineOperand::MO_ConstantPoolIndex:
182 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
182 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
183183 << MO.getIndex();
184184 break;
185185 case MachineOperand::MO_JumpTableIndex:
186 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
186 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
187187 << '_' << MO.getIndex();
188188 break;
189189 default:
324324 printBasicBlockLabel(MO.getMBB());
325325 return;
326326 case MachineOperand::MO_JumpTableIndex:
327 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
327 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
328328 << '_' << MO.getIndex();
329329 return;
330330 case MachineOperand::MO_ConstantPoolIndex:
331 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
331 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
332332 << '_' << MO.getIndex();
333333 return;
334334 case MachineOperand::MO_ExternalSymbol:
335335 // Computing the address of an external symbol, not calling it.
336336 if (TM.getRelocationModel() != Reloc::Static) {
337 std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
337 std::string Name(MAI->getGlobalPrefix()); Name += MO.getSymbolName();
338338 GVStubs.insert(Name);
339339 O << "L" << Name << "$non_lazy_ptr";
340340 return;
341341 }
342 O << TAI->getGlobalPrefix() << MO.getSymbolName();
342 O << MAI->getGlobalPrefix() << MO.getSymbolName();
343343 return;
344344 case MachineOperand::MO_GlobalAddress: {
345345 // Computing the address of a global symbol, not calling it.
527527 O << name << ":\n";
528528 O << "\t.zero " << Size << '\n';
529529 } else if (GVar->hasLocalLinkage()) {
530 O << TAI->getLCOMMDirective() << name << ',' << Size;
530 O << MAI->getLCOMMDirective() << name << ',' << Size;
531531 } else {
532532 O << ".comm " << name << ',' << Size;
533533 }
534 O << "\t\t" << TAI->getCommentString() << " '";
534 O << "\t\t" << MAI->getCommentString() << " '";
535535 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
536536 O << "'\n";
537537 return;
565565 }
566566
567567 EmitAlignment(Align, GVar);
568 O << name << ":\t\t\t\t" << TAI->getCommentString() << " '";
568 O << name << ":\t\t\t\t" << MAI->getCommentString() << " '";
569569 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
570570 O << "'\n";
571571
4343 class VISIBILITY_HIDDEN MSP430AsmPrinter : public AsmPrinter {
4444 public:
4545 MSP430AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
46 const MCAsmInfo *TAI, bool V)
47 : AsmPrinter(O, TM, TAI, V) {}
46 const MCAsmInfo *MAI, bool V)
47 : AsmPrinter(O, TM, MAI, V) {}
4848
4949 virtual const char *getPassName() const {
5050 return "MSP430 Assembly Printer";
131131 printMachineInstruction(II);
132132 }
133133
134 if (TAI->hasDotTypeDotSizeDirective())
134 if (MAI->hasDotTypeDotSizeDirective())
135135 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
136136
137137 // We didn't modify anything
179179 }
180180 case MachineOperand::MO_ExternalSymbol: {
181181 bool isCallOp = Modifier && !strcmp(Modifier, "call");
182 std::string Name(TAI->getGlobalPrefix());
182 std::string Name(MAI->getGlobalPrefix());
183183 Name += MO.getSymbolName();
184184 if (isCallOp)
185185 O << '#';
220220
221221 printVisibility(CurrentFnName, F->getVisibility());
222222
223 if ((TAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux())
223 if ((MAI->hasDotTypeDotSizeDirective()) && Subtarget->isLinux())
224224 O << "\t.type\t" << CurrentFnName << ", @function\n";
225225
226226 O << CurrentFnName << ":\n";
240240 O << "\t.set\treorder\n";
241241
242242 O << "\t.end\t" << CurrentFnName << '\n';
243 if (TAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
243 if (MAI->hasDotTypeDotSizeDirective() && !Subtarget->isLinux())
244244 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
245245 }
246246
369369 break;
370370
371371 case MachineOperand::MO_JumpTableIndex:
372 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
372 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
373373 << '_' << MO.getIndex();
374374 break;
375375
376376 case MachineOperand::MO_ConstantPoolIndex:
377 O << TAI->getPrivateGlobalPrefix() << "CPI"
377 O << MAI->getPrivateGlobalPrefix() << "CPI"
378378 << getFunctionNumber() << "_" << MO.getIndex();
379379 break;
380380
479479 if (GVar->hasLocalLinkage())
480480 O << "\t.local\t" << name << '\n';
481481
482 O << TAI->getCOMMDirective() << name << ',' << Size;
483 if (TAI->getCOMMDirectiveTakesAlignment())
482 O << MAI->getCOMMDirective() << name << ',' << Size;
483 if (MAI->getCOMMDirectiveTakesAlignment())
484484 O << ',' << (1 << Align);
485485
486486 O << '\n';
502502 // or something. For now, just emit them as external.
503503 case GlobalValue::ExternalLinkage:
504504 // If external or appending, declare as a global symbol
505 O << TAI->getGlobalDirective() << name << '\n';
505 O << MAI->getGlobalDirective() << name << '\n';
506506 // Fall Through
507507 case GlobalValue::PrivateLinkage:
508508 case GlobalValue::LinkerPrivateLinkage:
522522
523523 EmitAlignment(Align, GVar);
524524
525 if (TAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
525 if (MAI->hasDotTypeDotSizeDirective() && printSizeAndType) {
526526 O << "\t.type " << name << ",@object\n";
527527 O << "\t.size " << name << ',' << Size << '\n';
528528 }
3636 const MCAsmInfo *T, bool V)
3737 : AsmPrinter(O, TM, T, V), DbgInfo(O, T) {
3838 PTLI = static_cast(TM.getTargetLowering());
39 PTAI = static_cast(T);
39 PMAI = static_cast(T);
4040 PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering();
4141 }
4242
198198 // If no libcalls used, return.
199199 if (LibcallDecls.empty()) return;
200200
201 O << TAI->getCommentString() << "External decls for libcalls - BEGIN." <<"\n";
201 O << MAI->getCommentString() << "External decls for libcalls - BEGIN." <<"\n";
202202 // Remove duplicate entries.
203203 LibcallDecls.sort(is_before);
204204 LibcallDecls.unique(is_duplicate);
205205
206206 for (std::list::const_iterator I = LibcallDecls.begin();
207207 I != LibcallDecls.end(); I++) {
208 O << TAI->getExternDirective() << *I << "\n";
209 O << TAI->getExternDirective() << PAN::getArgsLabel(*I) << "\n";
210 O << TAI->getExternDirective() << PAN::getRetvalLabel(*I) << "\n";
211 }
212 O << TAI->getCommentString() << "External decls for libcalls - END." <<"\n";
208 O << MAI->getExternDirective() << *I << "\n";
209 O << MAI->getExternDirective() << PAN::getArgsLabel(*I) << "\n";
210 O << MAI->getExternDirective() << PAN::getRetvalLabel(*I) << "\n";
211 }
212 O << MAI->getCommentString() << "External decls for libcalls - END." <<"\n";
213213 }
214214
215215 /// doInitialization - Perfrom Module level initializations here.
249249 ///
250250 void PIC16AsmPrinter::EmitFunctionDecls(Module &M) {
251251 // Emit declarations for external functions.
252 O <<"\n"<<TAI->getCommentString() << "Function Declarations - BEGIN." <<"\n";
252 O <<"\n"<<MAI->getCommentString() << "Function Declarations - BEGIN." <<"\n";
253253 for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) {
254254 if (I->isIntrinsic())
255255 continue;
271271 // tracking both kind of references in printInstrunction.
272272 if (I->isDeclaration() && PAN::isMemIntrinsic(Name)) continue;
273273
274 const char *directive = I->isDeclaration() ? TAI->getExternDirective() :
275 TAI->getGlobalDirective();
274 const char *directive = I->isDeclaration() ? MAI->getExternDirective() :
275 MAI->getGlobalDirective();
276276
277277 O << directive << Name << "\n";
278278 O << directive << PAN::getRetvalLabel(Name) << "\n";
279279 O << directive << PAN::getArgsLabel(Name) << "\n";
280280 }
281281
282 O << TAI->getCommentString() << "Function Declarations - END." <<"\n";
282 O << MAI->getCommentString() << "Function Declarations - END." <<"\n";
283283 }
284284
285285 // Emit variables imported from other Modules.
287287 std::vector Items = PTOF->ExternalVarDecls->Items;
288288 if (!Items.size()) return;
289289
290 O << "\n" << TAI->getCommentString() << "Imported Variables - BEGIN" << "\n";
290 O << "\n" << MAI->getCommentString() << "Imported Variables - BEGIN" << "\n";
291291 for (unsigned j = 0; j < Items.size(); j++) {
292 O << TAI->getExternDirective() << Mang->getMangledName(Items[j]) << "\n";
293 }
294 O << TAI->getCommentString() << "Imported Variables - END" << "\n";
292 O << MAI->getExternDirective() << Mang->getMangledName(Items[j]) << "\n";
293 }
294 O << MAI->getCommentString() << "Imported Variables - END" << "\n";
295295 }
296296
297297 // Emit variables defined in this module and are available to other modules.
299299 std::vector Items = PTOF->ExternalVarDefs->Items;
300300 if (!Items.size()) return;
301301
302 O << "\n" << TAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
302 O << "\n" << MAI->getCommentString() << "Exported Variables - BEGIN" << "\n";
303303 for (unsigned j = 0; j < Items.size(); j++) {
304 O << TAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n";
305 }
306 O << TAI->getCommentString() << "Exported Variables - END" << "\n";
304 O << MAI->getGlobalDirective() << Mang->getMangledName(Items[j]) << "\n";
305 }
306 O << MAI->getCommentString() << "Exported Variables - END" << "\n";
307307 }
308308
309309 // Emit initialized data placed in ROM.
6969 PIC16TargetObjectFile *PTOF;
7070 PIC16TargetLowering *PTLI;
7171 PIC16DbgInfo DbgInfo;
72 const PIC16MCAsmInfo *PTAI;
72 const PIC16MCAsmInfo *PMAI;
7373 std::list LibcallDecls; // List of extern decls.
7474 };
7575 } // end of namespace
3131 static MCSectionPIC16 *Create(const StringRef &Name,
3232 SectionKind K, MCContext &Ctx);
3333
34 virtual void PrintSwitchToSection(const MCAsmInfo &TAI,
34 virtual void PrintSwitchToSection(const MCAsmInfo &MAI,
3535 raw_ostream &OS) const;
3636 };
3737
449449 bool HasAux = false;
450450 int Aux[PIC16Dbg::AuxSize] = { 0 };
451451 std::string TagName = "";
452 std::string VarName = TAI->getGlobalPrefix()+DIGV.getGlobal()->getNameStr();
452 std::string VarName = MAI->getGlobalPrefix()+DIGV.getGlobal()->getNameStr();
453453 PopulateDebugInfo(Ty, TypeNo, HasAux, Aux, TagName);
454454 // Emit debug info only if type information is availaible.
455455 if (TypeNo != PIC16Dbg::T_NULL) {
9191
9292 class PIC16DbgInfo {
9393 formatted_raw_ostream &O;
94 const MCAsmInfo *TAI;
94 const MCAsmInfo *MAI;
9595 std::string CurFile;
9696 unsigned CurLine;
9797
101101
102102 public:
103103 PIC16DbgInfo(formatted_raw_ostream &o, const MCAsmInfo *T)
104 : O(o), TAI(T) {
104 : O(o), MAI(T) {
105105 CurFile = "";
106106 CurLine = 0;
107107 EmitDebugDirectives = false;
2424 }
2525
2626
27 void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &TAI,
27 void MCSectionPIC16::PrintSwitchToSection(const MCAsmInfo &MAI,
2828 raw_ostream &OS) const {
2929 OS << getName() << '\n';
3030 }
323323 // Map symbol -> label of TOC entry.
324324 if (TOC.count(Name) == 0) {
325325 std::string Label;
326 Label += TAI->getPrivateGlobalPrefix();
326 Label += MAI->getPrivateGlobalPrefix();
327327 Label += "C";
328328 Label += utostr(LabelID++);
329329
405405 printBasicBlockLabel(MO.getMBB());
406406 return;
407407 case MachineOperand::MO_JumpTableIndex:
408 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
408 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
409409 << '_' << MO.getIndex();
410410 // FIXME: PIC relocation model
411411 return;
412412 case MachineOperand::MO_ConstantPoolIndex:
413 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
413 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
414414 << '_' << MO.getIndex();
415415 return;
416416 case MachineOperand::MO_ExternalSymbol: {
417417 // Computing the address of an external symbol, not calling it.
418 std::string Name(TAI->getGlobalPrefix());
418 std::string Name(MAI->getGlobalPrefix());
419419 Name += MO.getSymbolName();
420420
421421 if (TM.getRelocationModel() != Reloc::Static) {
718718 O << name << ":\n";
719719 O << "\t.zero " << Size << '\n';
720720 } else if (GVar->hasLocalLinkage()) {
721 O << TAI->getLCOMMDirective() << name << ',' << Size;
721 O << MAI->getLCOMMDirective() << name << ',' << Size;
722722 } else {
723723 O << ".comm " << name << ',' << Size;
724724 }
725725 if (VerboseAsm) {
726 O << "\t\t" << TAI->getCommentString() << " '";
726 O << "\t\t" << MAI->getCommentString() << " '";
727727 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
728728 O << "'";
729729 }
760760 EmitAlignment(Align, GVar);
761761 O << name << ":";
762762 if (VerboseAsm) {
763 O << "\t\t\t\t" << TAI->getCommentString() << " '";
763 O << "\t\t\t\t" << MAI->getCommentString() << " '";
764764 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
765765 O << "'";
766766 }
957957 O << "\t.zerofill __DATA, __common, " << name << ", "
958958 << Size << ", " << Align;
959959 } else if (GVar->hasLocalLinkage()) {
960 O << TAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
960 O << MAI->getLCOMMDirective() << name << ',' << Size << ',' << Align;
961961 } else if (!GVar->hasCommonLinkage()) {
962962 O << "\t.globl " << name << '\n'
963 << TAI->getWeakDefDirective() << name << '\n';
963 << MAI->getWeakDefDirective() << name << '\n';
964964 EmitAlignment(Align, GVar);
965965 O << name << ":";
966966 if (VerboseAsm) {
967 O << "\t\t\t\t" << TAI->getCommentString() << " ";
967 O << "\t\t\t\t" << MAI->getCommentString() << " ";
968968 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
969969 }
970970 O << '\n';
977977 O << ',' << Align;
978978 }
979979 if (VerboseAsm) {
980 O << "\t\t" << TAI->getCommentString() << " '";
980 O << "\t\t" << MAI->getCommentString() << " '";
981981 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
982982 O << "'";
983983 }
10121012 EmitAlignment(Align, GVar);
10131013 O << name << ":";
10141014 if (VerboseAsm) {
1015 O << "\t\t\t\t" << TAI->getCommentString() << " '";
1015 O << "\t\t\t\t" << MAI->getCommentString() << " '";
10161016 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
10171017 O << "'";
10181018 }
10961096
10971097 O << '\n';
10981098
1099 if (TAI->doesSupportExceptionHandling() && MMI) {
1099 if (MAI->doesSupportExceptionHandling() && MMI) {
11001100 // Add the (possibly multiple) personalities to the set of global values.
11011101 // Only referenced functions get into the Personalities list.
11021102 const std::vector &Personalities = MMI->getPersonalities();
166166 O << MO.getSymbolName();
167167 break;
168168 case MachineOperand::MO_ConstantPoolIndex:
169 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
169 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
170170 << MO.getIndex();
171171 break;
172172 default:
238238 if (GVar->hasLocalLinkage())
239239 O << "\t.local " << name << '\n';
240240
241 O << TAI->getCOMMDirective() << name << ',' << Size;
242 if (TAI->getCOMMDirectiveTakesAlignment())
241 O << MAI->getCOMMDirective() << name << ',' << Size;
242 if (MAI->getCOMMDirectiveTakesAlignment())
243243 O << ',' << (1 << Align);
244244
245245 O << '\n';
261261 // their name or something. For now, just emit them as external.
262262 case GlobalValue::ExternalLinkage:
263263 // If external or appending, declare as a global symbol
264 O << TAI->getGlobalDirective() << name << '\n';
264 O << MAI->getGlobalDirective() << name << '\n';
265265 // FALL THROUGH
266266 case GlobalValue::PrivateLinkage:
267267 case GlobalValue::LinkerPrivateLinkage:
279279
280280 EmitAlignment(Align, GVar);
281281
282 if (TAI->hasDotTypeDotSizeDirective()) {
282 if (MAI->hasDotTypeDotSizeDirective()) {
283283 O << "\t.type " << name << ",#object\n";
284284 O << "\t.size " << name << ',' << Size << '\n';
285285 }
4343 class VISIBILITY_HIDDEN SystemZAsmPrinter : public AsmPrinter {
4444 public:
4545 SystemZAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
46 const MCAsmInfo *TAI, bool V)
47 : AsmPrinter(O, TM, TAI, V) {}
46 const MCAsmInfo *MAI, bool V)
47 : AsmPrinter(O, TM, MAI, V) {}
4848
4949 virtual const char *getPassName() const {
5050 return "SystemZ Assembly Printer";
139139 printMachineInstruction(II);
140140 }
141141
142 if (TAI->hasDotTypeDotSizeDirective())
142 if (MAI->hasDotTypeDotSizeDirective())
143143 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
144144
145145 // Print out jump tables referenced by the function.
181181 return;
182182 }
183183 case MachineOperand::MO_ExternalSymbol: {
184 std::string Name(TAI->getGlobalPrefix());
184 std::string Name(MAI->getGlobalPrefix());
185185 Name += MO.getSymbolName();
186186 O << Name;
187187
223223 printBasicBlockLabel(MO.getMBB());
224224 return;
225225 case MachineOperand::MO_JumpTableIndex:
226 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
226 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
227227 << MO.getIndex();
228228
229229 return;
230230 case MachineOperand::MO_ConstantPoolIndex:
231 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
231 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
232232 << MO.getIndex();
233233
234234 printOffset(MO.getOffset());
241241 break;
242242 }
243243 case MachineOperand::MO_ExternalSymbol: {
244 std::string Name(TAI->getGlobalPrefix());
244 std::string Name(MAI->getGlobalPrefix());
245245 Name += MO.getSymbolName();
246246 O << Name;
247247 break;
329329 if (GVar->hasLocalLinkage())
330330 O << "\t.local\t" << name << '\n';
331331
332 O << TAI->getCOMMDirective() << name << ',' << Size;
333 if (TAI->getCOMMDirectiveTakesAlignment())
334 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
332 O << MAI->getCOMMDirective() << name << ',' << Size;
333 if (MAI->getCOMMDirectiveTakesAlignment())
334 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
335335
336336 if (VerboseAsm) {
337 O << "\t\t" << TAI->getCommentString() << ' ';
337 O << "\t\t" << MAI->getCommentString() << ' ';
338338 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
339339 }
340340 O << '\n';
369369 EmitAlignment(Align, GVar, 1);
370370 O << name << ":";
371371 if (VerboseAsm) {
372 O << "\t\t\t\t" << TAI->getCommentString() << ' ';
372 O << "\t\t\t\t" << MAI->getCommentString() << ' ';
373373 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
374374 }
375375 O << '\n';
376 if (TAI->hasDotTypeDotSizeDirective())
376 if (MAI->hasDotTypeDotSizeDirective())
377377 O << "\t.size\t" << name << ", " << Size << '\n';
378378
379379 EmitGlobalConstant(C);
7272 /// Variable-length instructions are not handled here; this function
7373 /// may be overloaded in the target code to do that.
7474 unsigned TargetInstrInfo::getInlineAsmLength(const char *Str,
75 const MCAsmInfo &TAI) const {
75 const MCAsmInfo &MAI) const {
7676
7777
7878 // Count the number of instructions in the asm.
7979 bool atInsnStart = true;
8080 unsigned Length = 0;
8181 for (; *Str; ++Str) {
82 if (*Str == '\n' || *Str == TAI.getSeparatorChar())
82 if (*Str == '\n' || *Str == MAI.getSeparatorChar())
8383 atInsnStart = true;
8484 if (atInsnStart && !isspace(*Str)) {
85 Length += TAI.getMaxInstLength();
85 Length += MAI.getMaxInstLength();
8686 atInsnStart = false;
8787 }
88 if (atInsnStart && strncmp(Str, TAI.getCommentString(),
89 strlen(TAI.getCommentString())) == 0)
88 if (atInsnStart && strncmp(Str, MAI.getCommentString(),
89 strlen(MAI.getCommentString())) == 0)
9090 atInsnStart = false;
9191 }
9292
192192 case Function::WeakODRLinkage:
193193 if (Subtarget->isTargetDarwin()) {
194194 O << "\t.globl\t" << CurrentFnName << '\n';
195 O << TAI->getWeakDefDirective() << CurrentFnName << '\n';
195 O << MAI->getWeakDefDirective() << CurrentFnName << '\n';
196196 } else if (Subtarget->isTargetCygMing()) {
197197 O << "\t.globl\t" << CurrentFnName << "\n"
198198 "\t.linkonce discard\n";
216216
217217 O << CurrentFnName << ':';
218218 if (VerboseAsm) {
219 O.PadToColumn(TAI->getCommentColumn());
220 O << TAI->getCommentString() << ' ';
219 O.PadToColumn(MAI->getCommentColumn());
220 O << MAI->getCommentString() << ' ';
221221 WriteAsOperand(O, F, /*PrintType=*/false, F->getParent());
222222 }
223223 O << '\n';
254254 emitFunctionHeader(MF);
255255
256256 // Emit pre-function debug and/or EH information.
257 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
257 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
258258 DW->BeginFunction(&MF);
259259
260260 // Print out code for the function.
286286 O << "\tnop\n";
287287 }
288288
289 if (TAI->hasDotTypeDotSizeDirective())
289 if (MAI->hasDotTypeDotSizeDirective())
290290 O << "\t.size\t" << CurrentFnName << ", .-" << CurrentFnName << '\n';
291291
292292 // Emit post-function debug information.
293 if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling())
293 if (MAI->doesSupportDebugInformation() || MAI->doesSupportExceptionHandling())
294294 DW->EndFunction(&MF);
295295
296296 // Print out jump tables referenced by the function.
307307 switch (MO.getType()) {
308308 default: llvm_unreachable("unknown symbol type!");
309309 case MachineOperand::MO_JumpTableIndex:
310 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
310 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << '_'
311311 << MO.getIndex();
312312 break;
313313 case MachineOperand::MO_ConstantPoolIndex:
314 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
314 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
315315 << MO.getIndex();
316316 printOffset(MO.getOffset());
317317 break;
534534
535535 void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
536536 const MachineBasicBlock *MBB) const {
537 if (!TAI->getSetDirective())
537 if (!MAI->getSetDirective())
538538 return;
539539
540540 // We don't need .set machinery if we have GOT-style relocations
541541 if (Subtarget->isPICStyleGOT())
542542 return;
543543
544 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
544 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
545545 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
546546 printBasicBlockLabel(MBB, false, false, false);
547547 if (Subtarget->isPICStyleRIPRel())
548 O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
548 O << '-' << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
549549 << '_' << uid << '\n';
550550 else {
551551 O << '-';
567567 const MachineBasicBlock *MBB,
568568 unsigned uid) const {
569569 const char *JTEntryDirective = MJTI->getEntrySize() == 4 ?
570 TAI->getData32bitsDirective() : TAI->getData64bitsDirective();
570 MAI->getData32bitsDirective() : MAI->getData64bitsDirective();
571571
572572 O << JTEntryDirective << ' ';
573573
574574 if (Subtarget->isPICStyleRIPRel() || Subtarget->isPICStyleStubPIC()) {
575 O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
575 O << MAI->getPrivateGlobalPrefix() << getFunctionNumber()
576576 << '_' << uid << "_set_" << MBB->getNumber();
577577 } else if (Subtarget->isPICStyleGOT()) {
578578 printBasicBlockLabel(MBB, false, false, false);
949949 // Don't put things that should go in the cstring section into "comm".
950950 !TheSection->getKind().isMergeableCString()) {
951951 if (GVar->hasExternalLinkage()) {
952 if (const char *Directive = TAI->getZeroFillDirective()) {
952 if (const char *Directive = MAI->getZeroFillDirective()) {
953953 O << "\t.globl " << name << '\n';
954954 O << Directive << "__DATA, __common, " << name << ", "
955955 << Size << ", " << Align << '\n';
961961 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
962962 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
963963
964 if (TAI->getLCOMMDirective() != NULL) {
964 if (MAI->getLCOMMDirective() != NULL) {
965965 if (GVar->hasLocalLinkage()) {
966 O << TAI->getLCOMMDirective() << name << ',' << Size;
966 O << MAI->getLCOMMDirective() << name << ',' << Size;
967967 if (Subtarget->isTargetDarwin())
968968 O << ',' << Align;
969969 } else if (Subtarget->isTargetDarwin() && !GVar->hasCommonLinkage()) {
970970 O << "\t.globl " << name << '\n'
971 << TAI->getWeakDefDirective() << name << '\n';
971 << MAI->getWeakDefDirective() << name << '\n';
972972 EmitAlignment(Align, GVar);
973973 O << name << ":";
974974 if (VerboseAsm) {
975 O.PadToColumn(TAI->getCommentColumn());
976 O << TAI->getCommentString() << ' ';
975 O.PadToColumn(MAI->getCommentColumn());
976 O << MAI->getCommentString() << ' ';
977977 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
978978 }
979979 O << '\n';
980980 EmitGlobalConstant(C);
981981 return;
982982 } else {
983 O << TAI->getCOMMDirective() << name << ',' << Size;
984 if (TAI->getCOMMDirectiveTakesAlignment())
985 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
983 O << MAI->getCOMMDirective() << name << ',' << Size;
984 if (MAI->getCOMMDirectiveTakesAlignment())
985 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
986986 }
987987 } else {
988988 if (!Subtarget->isTargetCygMing()) {
989989 if (GVar->hasLocalLinkage())
990990 O << "\t.local\t" << name << '\n';
991991 }
992 O << TAI->getCOMMDirective() << name << ',' << Size;
993 if (TAI->getCOMMDirectiveTakesAlignment())
994 O << ',' << (TAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
992 O << MAI->getCOMMDirective() << name << ',' << Size;
993 if (MAI->getCOMMDirectiveTakesAlignment())
994 O << ',' << (MAI->getAlignmentIsInBytes() ? (1 << Align) : Align);
995995 }
996996 if (VerboseAsm) {
997 O.PadToColumn(TAI->getCommentColumn());
998 O << TAI->getCommentString() << ' ';
997 O.PadToColumn(MAI->getCommentColumn());
998 O << MAI->getCommentString() << ' ';
999999 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
10001000 }
10011001 O << '\n';
10121012 case GlobalValue::LinkerPrivateLinkage:
10131013 if (Subtarget->isTargetDarwin()) {
10141014 O << "\t.globl " << name << '\n'
1015 << TAI->getWeakDefDirective() << name << '\n';
1015 << MAI->getWeakDefDirective() << name << '\n';
10161016 } else if (Subtarget->isTargetCygMing()) {
10171017 O << "\t.globl\t" << name << "\n"
10181018 "\t.linkonce same_size\n";
10381038 EmitAlignment(Align, GVar);
10391039 O << name << ":";
10401040 if (VerboseAsm){
1041 O.PadToColumn(TAI->getCommentColumn());
1042 O << TAI->getCommentString() << ' ';
1041 O.PadToColumn(MAI->getCommentColumn());
1042 O << MAI->getCommentString() << ' ';
10431043 WriteAsOperand(O, GVar, /*PrintType=*/false, GVar->getParent());
10441044 }
10451045 O << '\n';
10461046
10471047 EmitGlobalConstant(C);
10481048
1049 if (TAI->hasDotTypeDotSizeDirective())
1049 if (MAI->hasDotTypeDotSizeDirective())
10501050 O << "\t.size\t" << name << ", " << Size << '\n';
10511051 }
10521052
10651065
10661066 // Add the (possibly multiple) personalities to the set of global value
10671067 // stubs. Only referenced functions get into the Personalities list.
1068 if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
1068 if (MAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
10691069 const std::vector &Personalities = MMI->getPersonalities();
10701070 for (unsigned i = 0, e = Personalities.size(); i != e; ++i) {
10711071 if (Personalities[i])
11091109 EmitAlignment(2);
11101110 for (StringMap::iterator I = HiddenGVStubs.begin(),
11111111 E = HiddenGVStubs.end(); I != E; ++I)
1112 O << I->getKeyData() << ":\n" << TAI->getData32bitsDirective()
1112 O << I->getKeyData() << ":\n" << MAI->getData32bitsDirective()
11131113 << I->second << '\n';
11141114 }
11151115
5959 else if (Op.isMBBLabel())
6060 // FIXME: Keep in sync with printBasicBlockLabel. printBasicBlockLabel
6161 // should eventually call into this code, not the other way around.
62 O << TAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction()
62 O << MAI->getPrivateGlobalPrefix() << "BB" << Op.getMBBLabelFunction()
6363 << '_' << Op.getMBBLabelBlock();
6464 else
6565 llvm_unreachable("Unknown pcrel immediate operand");
225225 case MachineOperand::MO_JumpTableIndex: {
226226 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
227227 if (!isMemOp) O << "OFFSET ";
228 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
228 O << MAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
229229 << "_" << MO.getIndex();
230230 return;
231231 }
232232 case MachineOperand::MO_ConstantPoolIndex: {
233233 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
234234 if (!isMemOp) O << "OFFSET ";
235 O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
235 O << "[" << MAI->getPrivateGlobalPrefix() << "CPI"
236236 << getFunctionNumber() << "_" << MO.getIndex();
237237 printOffset(MO.getOffset());
238238 O << "]";
257257 return;
258258 }
259259 case MachineOperand::MO_ExternalSymbol: {
260 O << TAI->getGlobalPrefix() << MO.getSymbolName();
260 O << MAI->getGlobalPrefix() << MO.getSymbolName();
261261 return;
262262 }
263263 default:
292292 }
293293
294294 case MachineOperand::MO_ExternalSymbol:
295 O << TAI->getGlobalPrefix() << MO.getSymbolName();
295 O << MAI->getGlobalPrefix() << MO.getSymbolName();
296296 return;
297297 }
298298 }
356356
357357 void X86IntelAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
358358 const MachineBasicBlock *MBB) const {
359 if (!TAI->getSetDirective())
360 return;
361
362 O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
359 if (!MAI->getSetDirective())
360 return;
361
362 O << MAI->getSetDirective() << ' ' << MAI->getPrivateGlobalPrefix()
363363 << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
364364 printBasicBlockLabel(MBB, false, false, false);
365365 O << '-' << "\"L" << getFunctionNumber() << "$pb\"'\n";
524524
525525 O << name << ":";
526526 if (VerboseAsm)
527 O.PadToColumn(TAI->getCommentColumn());
528 O << TAI->getCommentString()
527 O.PadToColumn(MAI->getCommentColumn());
528 O << MAI->getCommentString()
529529 << " " << GV->getName();
530530 O << '\n';
531531
9696 void XCoreAsmPrinter::
9797 emitGlobalDirective(const std::string &name)
9898 {
99 O << TAI->getGlobalDirective() << name;
99 O << MAI->getGlobalDirective() << name;
100100 O << "\n";
101101 }
102102
116116 if (const ArrayType *ATy = dyn_cast(
117117 cast(GV->getType())->getElementType()))
118118 {
119 O << TAI->getGlobalDirective() << name << ".globound" << "\n";
120 O << TAI->getSetDirective() << name << ".globound" << ","
119 O << MAI->getGlobalDirective() << name << ".globound" << "\n";
120 O << MAI->getSetDirective() << name << ".globound" << ","
121121 << ATy->getNumElements() << "\n";
122122 if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
123123 // TODO Use COMDAT groups for LinkOnceLinkage
124 O << TAI->getWeakDefDirective() << name << ".globound" << "\n";
124 O << MAI->getWeakDefDirective() << name << ".globound" << "\n";
125125 }
126126 }
127127 }
155155 emitGlobalDirective(name);
156156 // TODO Use COMDAT groups for LinkOnceLinkage
157157 if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage()) {
158 O << TAI->getWeakDefDirective() << name << "\n";
158 O << MAI->getWeakDefDirective() << name << "\n";
159159 }
160160 // FALL THROUGH
161161 case GlobalValue::InternalLinkage:
178178 if (GV->isThreadLocal()) {
179179 Size *= MaxThreads;
180180 }
181 if (TAI->hasDotTypeDotSizeDirective()) {
181 if (MAI->hasDotTypeDotSizeDirective()) {
182182 O << "\t.type " << name << ",@object\n";
183183 O << "\t.size " << name << "," << Size << "\n";
184184 }
224224 case Function::WeakAnyLinkage:
225225 case Function::WeakODRLinkage:
226226 // TODO Use COMDAT groups for LinkOnceLinkage
227 O << TAI->getGlobalDirective() << CurrentFnName << "\n";
228 O << TAI->getWeakDefDirective() << CurrentFnName << "\n";
227 O << MAI->getGlobalDirective() << CurrentFnName << "\n";
228