1 //===-- AsmPrinter.cpp - Common AsmPrinter code ---------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the AsmPrinter class.
12 //===----------------------------------------------------------------------===//
14 #include "llvm/CodeGen/AsmPrinter.h"
15 #include "llvm/Assembly/Writer.h"
16 #include "llvm/DerivedTypes.h"
17 #include "llvm/Constants.h"
18 #include "llvm/Module.h"
19 #include "llvm/CodeGen/MachineConstantPool.h"
20 #include "llvm/CodeGen/MachineJumpTableInfo.h"
21 #include "llvm/Support/Mangler.h"
22 #include "llvm/Support/MathExtras.h"
23 #include "llvm/Target/TargetData.h"
24 #include "llvm/Target/TargetMachine.h"
29 AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm)
30 : FunctionNumber(0), O(o), TM(tm),
33 PrivateGlobalPrefix("."),
34 GlobalVarAddrPrefix(""),
35 GlobalVarAddrSuffix(""),
36 FunctionAddrPrefix(""),
37 FunctionAddrSuffix(""),
38 InlineAsmStart("#APP"),
39 InlineAsmEnd("#NO_APP"),
40 ZeroDirective("\t.zero\t"),
41 ZeroDirectiveSuffix(0),
42 AsciiDirective("\t.ascii\t"),
43 AscizDirective("\t.asciz\t"),
44 Data8bitsDirective("\t.byte\t"),
45 Data16bitsDirective("\t.short\t"),
46 Data32bitsDirective("\t.long\t"),
47 Data64bitsDirective("\t.quad\t"),
48 AlignDirective("\t.align\t"),
49 AlignmentIsInBytes(true),
50 SwitchToSectionDirective("\t.section\t"),
51 TextSectionStartSuffix(""),
52 DataSectionStartSuffix(""),
53 SectionEndDirectiveSuffix(0),
54 ConstantPoolSection("\t.section .rodata\n"),
55 JumpTableSection("\t.section .rodata\n"),
56 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
57 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
59 COMMDirective("\t.comm\t"),
60 COMMDirectiveTakesAlignment(true),
61 HasDotTypeDotSizeDirective(true) {
65 /// SwitchToTextSection - Switch to the specified text section of the executable
66 /// if we are not already in it!
68 void AsmPrinter::SwitchToTextSection(const char *NewSection,
69 const GlobalValue *GV) {
71 if (GV && GV->hasSection())
72 NS = SwitchToSectionDirective + GV->getSection();
76 // If we're already in this section, we're done.
77 if (CurrentSection == NS) return;
79 // Close the current section, if applicable.
80 if (SectionEndDirectiveSuffix && !CurrentSection.empty())
81 O << CurrentSection << SectionEndDirectiveSuffix << "\n";
85 if (!CurrentSection.empty())
86 O << CurrentSection << TextSectionStartSuffix << '\n';
89 /// SwitchToTextSection - Switch to the specified text section of the executable
90 /// if we are not already in it!
92 void AsmPrinter::SwitchToDataSection(const char *NewSection,
93 const GlobalValue *GV) {
95 if (GV && GV->hasSection())
96 NS = SwitchToSectionDirective + GV->getSection();
100 // If we're already in this section, we're done.
101 if (CurrentSection == NS) return;
103 // Close the current section, if applicable.
104 if (SectionEndDirectiveSuffix && !CurrentSection.empty())
105 O << CurrentSection << SectionEndDirectiveSuffix << "\n";
109 if (!CurrentSection.empty())
110 O << CurrentSection << DataSectionStartSuffix << '\n';
114 bool AsmPrinter::doInitialization(Module &M) {
115 Mang = new Mangler(M, GlobalPrefix);
117 if (!M.getModuleInlineAsm().empty())
118 O << CommentString << " Start of file scope inline assembly\n"
119 << M.getModuleInlineAsm()
120 << "\n" << CommentString << " End of file scope inline assembly\n";
122 SwitchToDataSection("", 0); // Reset back to no section.
124 if (MachineDebugInfo *DebugInfo = getAnalysisToUpdate<MachineDebugInfo>()) {
125 DebugInfo->AnalyzeModule(M);
131 bool AsmPrinter::doFinalization(Module &M) {
132 delete Mang; Mang = 0;
136 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
137 // What's my mangled name?
138 CurrentFnName = Mang->getValueName(MF.getFunction());
139 IncrementFunctionNumber();
142 /// EmitConstantPool - Print to the current output stream assembly
143 /// representations of the constants in the constant pool MCP. This is
144 /// used to print out constants which have been "spilled to memory" by
145 /// the code generator.
147 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
148 const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
149 if (CP.empty()) return;
151 SwitchToDataSection(ConstantPoolSection, 0);
152 EmitAlignment(MCP->getConstantPoolAlignment());
153 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
154 O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
155 << ":\t\t\t\t\t" << CommentString << " ";
156 WriteTypeSymbolic(O, CP[i].Val->getType(), 0) << '\n';
157 EmitGlobalConstant(CP[i].Val);
159 unsigned EntSize = TM.getTargetData()->getTypeSize(CP[i].Val->getType());
160 unsigned ValEnd = CP[i].Offset + EntSize;
161 // Emit inter-object padding for alignment.
162 EmitZeros(CP[i+1].Offset-ValEnd);
167 /// EmitJumpTableInfo - Print assembly representations of the jump tables used
168 /// by the current function to the current output stream.
170 void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
171 const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
172 if (JT.empty()) return;
173 const TargetData *TD = TM.getTargetData();
175 // FIXME: someday we need to handle PIC jump tables
176 assert((TM.getRelocationModel() == Reloc::Static ||
177 TM.getRelocationModel() == Reloc::DynamicNoPIC) &&
178 "Unhandled relocation model emitting jump table information!");
180 SwitchToDataSection(JumpTableSection, 0);
181 EmitAlignment(Log2_32(TD->getPointerAlignment()));
182 for (unsigned i = 0, e = JT.size(); i != e; ++i) {
183 O << PrivateGlobalPrefix << "JTI" << getFunctionNumber() << '_' << i
185 const std::vector<MachineBasicBlock*> &JTBBs = JT[i].MBBs;
186 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
187 O << Data32bitsDirective << ' ';
188 printBasicBlockLabel(JTBBs[ii]);
194 /// EmitSpecialLLVMGlobal - Check to see if the specified global is a
195 /// special global used by LLVM. If so, emit it and return true, otherwise
196 /// do nothing and return false.
197 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
198 // Ignore debug and non-emitted data.
199 if (GV->getSection() == "llvm.metadata") return true;
201 if (!GV->hasAppendingLinkage()) return false;
203 assert(GV->hasInitializer() && "Not a special LLVM global!");
205 if (GV->getName() == "llvm.used")
206 return true; // No need to emit this at all.
208 if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
209 SwitchToDataSection(StaticCtorsSection, 0);
211 EmitXXStructorList(GV->getInitializer());
215 if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) {
216 SwitchToDataSection(StaticDtorsSection, 0);
218 EmitXXStructorList(GV->getInitializer());
225 /// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the
226 /// function pointers, ignoring the init priority.
227 void AsmPrinter::EmitXXStructorList(Constant *List) {
228 // Should be an array of '{ int, void ()* }' structs. The first value is the
229 // init priority, which we ignore.
230 if (!isa<ConstantArray>(List)) return;
231 ConstantArray *InitList = cast<ConstantArray>(List);
232 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
233 if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){
234 if (CS->getNumOperands() != 2) return; // Not array of 2-element structs.
236 if (CS->getOperand(1)->isNullValue())
237 return; // Found a null terminator, exit printing.
238 // Emit the function pointer.
239 EmitGlobalConstant(CS->getOperand(1));
243 /// getPreferredAlignmentLog - Return the preferred alignment of the
244 /// specified global, returned in log form. This includes an explicitly
245 /// requested alignment (if the global has one).
246 unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
247 unsigned Alignment = TM.getTargetData()->getTypeAlignmentShift(GV->getType());
248 if (GV->getAlignment() > (1U << Alignment))
249 Alignment = Log2_32(GV->getAlignment());
251 if (GV->hasInitializer()) {
252 // Always round up alignment of global doubles to 8 bytes.
253 if (GV->getType()->getElementType() == Type::DoubleTy && Alignment < 3)
256 // If the global is not external, see if it is large. If so, give it a
258 if (TM.getTargetData()->getTypeSize(GV->getType()->getElementType()) > 128)
259 Alignment = 4; // 16-byte alignment.
265 // EmitAlignment - Emit an alignment directive to the specified power of two.
266 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
267 if (GV && GV->getAlignment())
268 NumBits = Log2_32(GV->getAlignment());
269 if (NumBits == 0) return; // No need to emit alignment.
270 if (AlignmentIsInBytes) NumBits = 1 << NumBits;
271 O << AlignDirective << NumBits << "\n";
274 /// EmitZeros - Emit a block of zeros.
276 void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
279 O << ZeroDirective << NumZeros;
280 if (ZeroDirectiveSuffix)
281 O << ZeroDirectiveSuffix;
284 for (; NumZeros; --NumZeros)
285 O << Data8bitsDirective << "0\n";
290 // Print out the specified constant, without a storage class. Only the
291 // constants valid in constant expressions can occur here.
292 void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
293 if (CV->isNullValue() || isa<UndefValue>(CV))
295 else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
296 assert(CB == ConstantBool::True);
298 } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
299 if (((CI->getValue() << 32) >> 32) == CI->getValue())
302 O << (uint64_t)CI->getValue();
303 else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
305 else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
306 // This is a constant address for a global variable or function. Use the
307 // name of the variable or function as the address value, possibly
308 // decorating it with GlobalVarAddrPrefix/Suffix or
309 // FunctionAddrPrefix/Suffix (these all default to "" )
310 if (isa<Function>(GV))
311 O << FunctionAddrPrefix << Mang->getValueName(GV) << FunctionAddrSuffix;
313 O << GlobalVarAddrPrefix << Mang->getValueName(GV) << GlobalVarAddrSuffix;
314 } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
315 const TargetData *TD = TM.getTargetData();
316 switch(CE->getOpcode()) {
317 case Instruction::GetElementPtr: {
318 // generate a symbolic expression for the byte address
319 const Constant *ptrVal = CE->getOperand(0);
320 std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
321 if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), idxVec)) {
324 EmitConstantValueOnly(ptrVal);
326 O << ") + " << Offset;
328 O << ") - " << -Offset;
330 EmitConstantValueOnly(ptrVal);
334 case Instruction::Cast: {
335 // Support only non-converting or widening casts for now, that is, ones
336 // that do not involve a change in value. This assertion is really gross,
337 // and may not even be a complete check.
338 Constant *Op = CE->getOperand(0);
339 const Type *OpTy = Op->getType(), *Ty = CE->getType();
341 // Remember, kids, pointers can be losslessly converted back and forth
342 // into 32-bit or wider integers, regardless of signedness. :-P
343 assert(((isa<PointerType>(OpTy)
344 && (Ty == Type::LongTy || Ty == Type::ULongTy
345 || Ty == Type::IntTy || Ty == Type::UIntTy))
346 || (isa<PointerType>(Ty)
347 && (OpTy == Type::LongTy || OpTy == Type::ULongTy
348 || OpTy == Type::IntTy || OpTy == Type::UIntTy))
349 || (((TD->getTypeSize(Ty) >= TD->getTypeSize(OpTy))
350 && OpTy->isLosslesslyConvertibleTo(Ty))))
351 && "FIXME: Don't yet support this kind of constant cast expr");
352 EmitConstantValueOnly(Op);
355 case Instruction::Add:
357 EmitConstantValueOnly(CE->getOperand(0));
359 EmitConstantValueOnly(CE->getOperand(1));
363 assert(0 && "Unsupported operator!");
366 assert(0 && "Unknown constant value!");
370 /// toOctal - Convert the low order bits of X into an octal digit.
372 static inline char toOctal(int X) {
376 /// printAsCString - Print the specified array as a C compatible string, only if
377 /// the predicate isString is true.
379 static void printAsCString(std::ostream &O, const ConstantArray *CVA,
381 assert(CVA->isString() && "Array is not string compatible!");
384 for (unsigned i = 0; i != LastElt; ++i) {
386 (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
390 } else if (C == '\\') {
392 } else if (isprint(C)) {
396 case '\b': O << "\\b"; break;
397 case '\f': O << "\\f"; break;
398 case '\n': O << "\\n"; break;
399 case '\r': O << "\\r"; break;
400 case '\t': O << "\\t"; break;
403 O << toOctal(C >> 6);
404 O << toOctal(C >> 3);
405 O << toOctal(C >> 0);
413 /// EmitString - Emit a zero-byte-terminated string constant.
415 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
416 unsigned NumElts = CVA->getNumOperands();
417 if (AscizDirective && NumElts &&
418 cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
420 printAsCString(O, CVA, NumElts-1);
423 printAsCString(O, CVA, NumElts);
428 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
430 void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
431 const TargetData *TD = TM.getTargetData();
433 if (CV->isNullValue() || isa<UndefValue>(CV)) {
434 EmitZeros(TD->getTypeSize(CV->getType()));
436 } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
437 if (CVA->isString()) {
439 } else { // Not a string. Print the values in successive locations
440 for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
441 EmitGlobalConstant(CVA->getOperand(i));
444 } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
445 // Print the fields in successive locations. Pad to align if needed!
446 const StructLayout *cvsLayout = TD->getStructLayout(CVS->getType());
447 uint64_t sizeSoFar = 0;
448 for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
449 const Constant* field = CVS->getOperand(i);
451 // Check if padding is needed and insert one or more 0s.
452 uint64_t fieldSize = TD->getTypeSize(field->getType());
453 uint64_t padSize = ((i == e-1? cvsLayout->StructSize
454 : cvsLayout->MemberOffsets[i+1])
455 - cvsLayout->MemberOffsets[i]) - fieldSize;
456 sizeSoFar += fieldSize + padSize;
458 // Now print the actual field value
459 EmitGlobalConstant(field);
461 // Insert the field padding unless it's zero bytes...
464 assert(sizeSoFar == cvsLayout->StructSize &&
465 "Layout of constant struct may be incorrect!");
467 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
468 // FP Constants are printed as integer constants to avoid losing
470 double Val = CFP->getValue();
471 if (CFP->getType() == Type::DoubleTy) {
472 if (Data64bitsDirective)
473 O << Data64bitsDirective << DoubleToBits(Val) << "\t" << CommentString
474 << " double value: " << Val << "\n";
475 else if (TD->isBigEndian()) {
476 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
477 << "\t" << CommentString << " double most significant word "
479 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
480 << "\t" << CommentString << " double least significant word "
483 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
484 << "\t" << CommentString << " double least significant word " << Val
486 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
487 << "\t" << CommentString << " double most significant word " << Val
492 O << Data32bitsDirective << FloatToBits(Val) << "\t" << CommentString
493 << " float " << Val << "\n";
496 } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
497 if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
498 uint64_t Val = CI->getRawValue();
500 if (Data64bitsDirective)
501 O << Data64bitsDirective << Val << "\n";
502 else if (TD->isBigEndian()) {
503 O << Data32bitsDirective << unsigned(Val >> 32)
504 << "\t" << CommentString << " Double-word most significant word "
506 O << Data32bitsDirective << unsigned(Val)
507 << "\t" << CommentString << " Double-word least significant word "
510 O << Data32bitsDirective << unsigned(Val)
511 << "\t" << CommentString << " Double-word least significant word "
513 O << Data32bitsDirective << unsigned(Val >> 32)
514 << "\t" << CommentString << " Double-word most significant word "
519 } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) {
520 const PackedType *PTy = CP->getType();
522 for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I)
523 EmitGlobalConstant(CP->getOperand(I));
528 const Type *type = CV->getType();
529 switch (type->getTypeID()) {
531 case Type::UByteTyID: case Type::SByteTyID:
532 O << Data8bitsDirective;
534 case Type::UShortTyID: case Type::ShortTyID:
535 O << Data16bitsDirective;
537 case Type::PointerTyID:
538 if (TD->getPointerSize() == 8) {
539 O << Data64bitsDirective;
542 //Fall through for pointer size == int size
543 case Type::UIntTyID: case Type::IntTyID:
544 O << Data32bitsDirective;
546 case Type::ULongTyID: case Type::LongTyID:
547 assert(Data64bitsDirective &&"Target cannot handle 64-bit constant exprs!");
548 O << Data64bitsDirective;
550 case Type::FloatTyID: case Type::DoubleTyID:
551 assert (0 && "Should have already output floating point constant.");
553 assert (0 && "Can't handle printing this type of thing");
556 EmitConstantValueOnly(CV);
560 /// printInlineAsm - This method formats and prints the specified machine
561 /// instruction that is an inline asm.
562 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
563 O << InlineAsmStart << "\n\t";
564 unsigned NumOperands = MI->getNumOperands();
566 // Count the number of register definitions.
567 unsigned NumDefs = 0;
568 for (; MI->getOperand(NumDefs).isDef(); ++NumDefs)
569 assert(NumDefs != NumOperands-1 && "No asm string?");
571 assert(MI->getOperand(NumDefs).isExternalSymbol() && "No asm string?");
573 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
574 const char *AsmStr = MI->getOperand(NumDefs).getSymbolName();
576 // The variant of the current asmprinter: FIXME: change.
577 int AsmPrinterVariant = 0;
579 int CurVariant = -1; // The number of the {.|.|.} region we are in.
580 const char *LastEmitted = AsmStr; // One past the last character emitted.
582 while (*LastEmitted) {
583 switch (*LastEmitted) {
585 // Not a special case, emit the string section literally.
586 const char *LiteralEnd = LastEmitted+1;
587 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
588 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
590 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
591 O.write(LastEmitted, LiteralEnd-LastEmitted);
592 LastEmitted = LiteralEnd;
596 ++LastEmitted; // Consume newline character.
597 O << "\n\t"; // Indent code with newline.
600 ++LastEmitted; // Consume '$' character.
601 if (*LastEmitted == '$') { // $$ -> $
602 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
604 ++LastEmitted; // Consume second '$' character.
608 bool HasCurlyBraces = false;
609 if (*LastEmitted == '{') { // ${variable}
610 ++LastEmitted; // Consume '{' character.
611 HasCurlyBraces = true;
614 const char *IDStart = LastEmitted;
616 long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
617 if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
618 std::cerr << "Bad $ operand number in inline asm string: '"
624 char Modifier[2] = { 0, 0 };
626 if (HasCurlyBraces) {
627 // If we have curly braces, check for a modifier character. This
628 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
629 if (*LastEmitted == ':') {
630 ++LastEmitted; // Consume ':' character.
631 if (*LastEmitted == 0) {
632 std::cerr << "Bad ${:} expression in inline asm string: '"
637 Modifier[0] = *LastEmitted;
638 ++LastEmitted; // Consume modifier character.
641 if (*LastEmitted != '}') {
642 std::cerr << "Bad ${} expression in inline asm string: '"
646 ++LastEmitted; // Consume '}' character.
649 if ((unsigned)Val >= NumOperands-1) {
650 std::cerr << "Invalid $ operand number in inline asm string: '"
655 // Okay, we finally have a value number. Ask the target to print this
657 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
662 // Scan to find the machine operand number for the operand.
664 if (OpNo >= MI->getNumOperands()) break;
665 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
666 OpNo += (OpFlags >> 3) + 1;
669 if (OpNo >= MI->getNumOperands()) {
672 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
673 ++OpNo; // Skip over the ID number.
675 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
676 if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
677 Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
678 Modifier[0] ? Modifier : 0);
680 Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
681 Modifier[0] ? Modifier : 0);
685 std::cerr << "Invalid operand found in inline asm: '"
694 ++LastEmitted; // Consume '{' character.
695 if (CurVariant != -1) {
696 std::cerr << "Nested variants found in inline asm string: '"
700 CurVariant = 0; // We're in the first variant now.
703 ++LastEmitted; // consume '|' character.
704 if (CurVariant == -1) {
705 std::cerr << "Found '|' character outside of variant in inline asm "
706 << "string: '" << AsmStr << "'\n";
709 ++CurVariant; // We're in the next variant.
712 ++LastEmitted; // consume '}' character.
713 if (CurVariant == -1) {
714 std::cerr << "Found '}' character outside of variant in inline asm "
715 << "string: '" << AsmStr << "'\n";
722 O << "\n\t" << InlineAsmEnd << "\n";
725 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
726 /// instruction, using the specified assembler variant. Targets should
727 /// overried this to format as appropriate.
728 bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
729 unsigned AsmVariant, const char *ExtraCode) {
730 // Target doesn't support this yet!
734 bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
736 const char *ExtraCode) {
737 // Target doesn't support this yet!
741 /// printBasicBlockLabel - This method prints the label for the specified
742 /// MachineBasicBlock
743 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
745 bool printComment) const {
746 O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_"
751 O << '\t' << CommentString << MBB->getBasicBlock()->getName();