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/TargetMachine.h"
28 AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm)
29 : FunctionNumber(0), O(o), TM(tm),
32 PrivateGlobalPrefix("."),
33 GlobalVarAddrPrefix(""),
34 GlobalVarAddrSuffix(""),
35 FunctionAddrPrefix(""),
36 FunctionAddrSuffix(""),
37 InlineAsmStart("#APP"),
38 InlineAsmEnd("#NO_APP"),
39 ZeroDirective("\t.zero\t"),
40 ZeroDirectiveSuffix(0),
41 AsciiDirective("\t.ascii\t"),
42 AscizDirective("\t.asciz\t"),
43 Data8bitsDirective("\t.byte\t"),
44 Data16bitsDirective("\t.short\t"),
45 Data32bitsDirective("\t.long\t"),
46 Data64bitsDirective("\t.quad\t"),
47 AlignDirective("\t.align\t"),
48 AlignmentIsInBytes(true),
49 SwitchToSectionDirective("\t.section\t"),
51 ConstantPoolSection("\t.section .rodata\n"),
52 JumpTableSection("\t.section .rodata\n"),
53 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
54 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
56 COMMDirective("\t.comm\t"),
57 COMMDirectiveTakesAlignment(true),
58 HasDotTypeDotSizeDirective(true) {
62 /// SwitchToTextSection - Switch to the specified text section of the executable
63 /// if we are not already in it!
65 void AsmPrinter::SwitchToTextSection(const char *NewSection,
66 const GlobalValue *GV) {
69 // Microsoft ML/MASM has a fundamentally different approach to handling
73 if (GV && GV->hasSection())
74 NS = GV->getSection();
78 if (CurrentSection != NS) {
79 if (!CurrentSection.empty())
80 O << CurrentSection << "\tends\n\n";
82 if (!CurrentSection.empty())
83 O << CurrentSection << "\tsegment 'CODE'\n";
86 if (GV && GV->hasSection())
87 NS = SwitchToSectionDirective + GV->getSection();
89 NS = std::string("\t")+NewSection;
91 if (CurrentSection != NS) {
93 if (!CurrentSection.empty())
94 O << CurrentSection << '\n';
99 /// SwitchToTextSection - Switch to the specified text section of the executable
100 /// if we are not already in it!
102 void AsmPrinter::SwitchToDataSection(const char *NewSection,
103 const GlobalValue *GV) {
105 if (GV && GV->hasSection())
106 NS = SwitchToSectionDirective + GV->getSection();
110 // If we're already in this section, we're done.
111 if (CurrentSection == NS) return;
113 // Microsoft ML/MASM has a fundamentally different approach to handling
117 if (!CurrentSection.empty())
118 O << CurrentSection << "\tends\n\n";
120 if (!CurrentSection.empty())
121 O << CurrentSection << "\tsegment 'DATA'\n";
124 if (!CurrentSection.empty())
125 O << CurrentSection << '\n';
130 bool AsmPrinter::doInitialization(Module &M) {
131 Mang = new Mangler(M, GlobalPrefix);
133 if (!M.getModuleInlineAsm().empty())
134 O << CommentString << " Start of file scope inline assembly\n"
135 << M.getModuleInlineAsm()
136 << "\n" << CommentString << " End of file scope inline assembly\n";
138 SwitchToDataSection("", 0); // Reset back to no section.
140 if (MachineDebugInfo *DebugInfo = getAnalysisToUpdate<MachineDebugInfo>()) {
141 DebugInfo->AnalyzeModule(M);
147 bool AsmPrinter::doFinalization(Module &M) {
148 delete Mang; Mang = 0;
152 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
153 // What's my mangled name?
154 CurrentFnName = Mang->getValueName(MF.getFunction());
155 IncrementFunctionNumber();
158 /// EmitConstantPool - Print to the current output stream assembly
159 /// representations of the constants in the constant pool MCP. This is
160 /// used to print out constants which have been "spilled to memory" by
161 /// the code generator.
163 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
164 const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
165 if (CP.empty()) return;
166 const TargetData *TD = TM.getTargetData();
168 SwitchToDataSection(ConstantPoolSection, 0);
169 EmitAlignment(MCP->getConstantPoolAlignment());
170 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
171 O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
172 << ":\t\t\t\t\t" << CommentString << " ";
173 WriteTypeSymbolic(O, CP[i].Val->getType(), 0) << '\n';
174 EmitGlobalConstant(CP[i].Val);
176 unsigned EntSize = TM.getTargetData()->getTypeSize(CP[i].Val->getType());
177 unsigned ValEnd = CP[i].Offset + EntSize;
178 // Emit inter-object padding for alignment.
179 EmitZeros(CP[i+1].Offset-ValEnd);
184 /// EmitJumpTableInfo - Print assembly representations of the jump tables used
185 /// by the current function to the current output stream.
187 void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
188 const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
189 if (JT.empty()) return;
190 const TargetData *TD = TM.getTargetData();
192 // FIXME: someday we need to handle PIC jump tables
193 assert((TM.getRelocationModel() == Reloc::Static ||
194 TM.getRelocationModel() == Reloc::DynamicNoPIC) &&
195 "Unhandled relocation model emitting jump table information!");
197 SwitchToDataSection(JumpTableSection, 0);
198 EmitAlignment(Log2_32(TD->getPointerAlignment()));
199 for (unsigned i = 0, e = JT.size(); i != e; ++i) {
200 O << PrivateGlobalPrefix << "JTI" << getFunctionNumber() << '_' << i
202 const std::vector<MachineBasicBlock*> &JTBBs = JT[i].MBBs;
203 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
204 O << Data32bitsDirective << ' ';
205 printBasicBlockLabel(JTBBs[ii]);
211 /// EmitSpecialLLVMGlobal - Check to see if the specified global is a
212 /// special global used by LLVM. If so, emit it and return true, otherwise
213 /// do nothing and return false.
214 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
215 // Ignore debug and non-emitted data.
216 if (GV->getSection() == "llvm.metadata") return true;
218 if (!GV->hasAppendingLinkage()) return false;
220 assert(GV->hasInitializer() && "Not a special LLVM global!");
222 if (GV->getName() == "llvm.used")
223 return true; // No need to emit this at all.
225 if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
226 SwitchToDataSection(StaticCtorsSection, 0);
228 EmitXXStructorList(GV->getInitializer());
232 if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) {
233 SwitchToDataSection(StaticDtorsSection, 0);
235 EmitXXStructorList(GV->getInitializer());
242 /// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the
243 /// function pointers, ignoring the init priority.
244 void AsmPrinter::EmitXXStructorList(Constant *List) {
245 // Should be an array of '{ int, void ()* }' structs. The first value is the
246 // init priority, which we ignore.
247 if (!isa<ConstantArray>(List)) return;
248 ConstantArray *InitList = cast<ConstantArray>(List);
249 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
250 if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){
251 if (CS->getNumOperands() != 2) return; // Not array of 2-element structs.
253 if (CS->getOperand(1)->isNullValue())
254 return; // Found a null terminator, exit printing.
255 // Emit the function pointer.
256 EmitGlobalConstant(CS->getOperand(1));
260 /// getPreferredAlignmentLog - Return the preferred alignment of the
261 /// specified global, returned in log form. This includes an explicitly
262 /// requested alignment (if the global has one).
263 unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
264 unsigned Alignment = TM.getTargetData()->getTypeAlignmentShift(GV->getType());
265 if (GV->getAlignment() > (1U << Alignment))
266 Alignment = Log2_32(GV->getAlignment());
268 if (GV->hasInitializer()) {
269 // Always round up alignment of global doubles to 8 bytes.
270 if (GV->getType()->getElementType() == Type::DoubleTy && Alignment < 3)
273 // If the global is not external, see if it is large. If so, give it a
275 if (TM.getTargetData()->getTypeSize(GV->getType()->getElementType()) > 128)
276 Alignment = 4; // 16-byte alignment.
282 // EmitAlignment - Emit an alignment directive to the specified power of two.
283 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
284 if (GV && GV->getAlignment())
285 NumBits = Log2_32(GV->getAlignment());
286 if (NumBits == 0) return; // No need to emit alignment.
287 if (AlignmentIsInBytes) NumBits = 1 << NumBits;
288 O << AlignDirective << NumBits << "\n";
291 /// EmitZeros - Emit a block of zeros.
293 void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
296 O << ZeroDirective << NumZeros;
297 if (ZeroDirectiveSuffix)
298 O << ZeroDirectiveSuffix;
301 for (; NumZeros; --NumZeros)
302 O << Data8bitsDirective << "0\n";
307 // Print out the specified constant, without a storage class. Only the
308 // constants valid in constant expressions can occur here.
309 void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
310 if (CV->isNullValue() || isa<UndefValue>(CV))
312 else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
313 assert(CB == ConstantBool::True);
315 } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
316 if (((CI->getValue() << 32) >> 32) == CI->getValue())
319 O << (uint64_t)CI->getValue();
320 else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
322 else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
323 // This is a constant address for a global variable or function. Use the
324 // name of the variable or function as the address value, possibly
325 // decorating it with GlobalVarAddrPrefix/Suffix or
326 // FunctionAddrPrefix/Suffix (these all default to "" )
327 if (isa<Function>(GV))
328 O << FunctionAddrPrefix << Mang->getValueName(GV) << FunctionAddrSuffix;
330 O << GlobalVarAddrPrefix << Mang->getValueName(GV) << GlobalVarAddrSuffix;
331 } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
332 const TargetData *TD = TM.getTargetData();
333 switch(CE->getOpcode()) {
334 case Instruction::GetElementPtr: {
335 // generate a symbolic expression for the byte address
336 const Constant *ptrVal = CE->getOperand(0);
337 std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
338 if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), idxVec)) {
341 EmitConstantValueOnly(ptrVal);
343 O << ") + " << Offset;
345 O << ") - " << -Offset;
347 EmitConstantValueOnly(ptrVal);
351 case Instruction::Cast: {
352 // Support only non-converting or widening casts for now, that is, ones
353 // that do not involve a change in value. This assertion is really gross,
354 // and may not even be a complete check.
355 Constant *Op = CE->getOperand(0);
356 const Type *OpTy = Op->getType(), *Ty = CE->getType();
358 // Remember, kids, pointers can be losslessly converted back and forth
359 // into 32-bit or wider integers, regardless of signedness. :-P
360 assert(((isa<PointerType>(OpTy)
361 && (Ty == Type::LongTy || Ty == Type::ULongTy
362 || Ty == Type::IntTy || Ty == Type::UIntTy))
363 || (isa<PointerType>(Ty)
364 && (OpTy == Type::LongTy || OpTy == Type::ULongTy
365 || OpTy == Type::IntTy || OpTy == Type::UIntTy))
366 || (((TD->getTypeSize(Ty) >= TD->getTypeSize(OpTy))
367 && OpTy->isLosslesslyConvertibleTo(Ty))))
368 && "FIXME: Don't yet support this kind of constant cast expr");
369 EmitConstantValueOnly(Op);
372 case Instruction::Add:
374 EmitConstantValueOnly(CE->getOperand(0));
376 EmitConstantValueOnly(CE->getOperand(1));
380 assert(0 && "Unsupported operator!");
383 assert(0 && "Unknown constant value!");
387 /// toOctal - Convert the low order bits of X into an octal digit.
389 static inline char toOctal(int X) {
393 /// printAsCString - Print the specified array as a C compatible string, only if
394 /// the predicate isString is true.
396 static void printAsCString(std::ostream &O, const ConstantArray *CVA,
398 assert(CVA->isString() && "Array is not string compatible!");
401 for (unsigned i = 0; i != LastElt; ++i) {
403 (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
407 } else if (C == '\\') {
409 } else if (isprint(C)) {
413 case '\b': O << "\\b"; break;
414 case '\f': O << "\\f"; break;
415 case '\n': O << "\\n"; break;
416 case '\r': O << "\\r"; break;
417 case '\t': O << "\\t"; break;
420 O << toOctal(C >> 6);
421 O << toOctal(C >> 3);
422 O << toOctal(C >> 0);
430 /// EmitString - Emit a zero-byte-terminated string constant.
432 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
433 unsigned NumElts = CVA->getNumOperands();
434 if (AscizDirective && NumElts &&
435 cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
437 printAsCString(O, CVA, NumElts-1);
440 printAsCString(O, CVA, NumElts);
445 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
447 void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
448 const TargetData *TD = TM.getTargetData();
450 if (CV->isNullValue() || isa<UndefValue>(CV)) {
451 EmitZeros(TD->getTypeSize(CV->getType()));
453 } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
454 if (CVA->isString()) {
456 } else { // Not a string. Print the values in successive locations
457 for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
458 EmitGlobalConstant(CVA->getOperand(i));
461 } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
462 // Print the fields in successive locations. Pad to align if needed!
463 const StructLayout *cvsLayout = TD->getStructLayout(CVS->getType());
464 uint64_t sizeSoFar = 0;
465 for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
466 const Constant* field = CVS->getOperand(i);
468 // Check if padding is needed and insert one or more 0s.
469 uint64_t fieldSize = TD->getTypeSize(field->getType());
470 uint64_t padSize = ((i == e-1? cvsLayout->StructSize
471 : cvsLayout->MemberOffsets[i+1])
472 - cvsLayout->MemberOffsets[i]) - fieldSize;
473 sizeSoFar += fieldSize + padSize;
475 // Now print the actual field value
476 EmitGlobalConstant(field);
478 // Insert the field padding unless it's zero bytes...
481 assert(sizeSoFar == cvsLayout->StructSize &&
482 "Layout of constant struct may be incorrect!");
484 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
485 // FP Constants are printed as integer constants to avoid losing
487 double Val = CFP->getValue();
488 if (CFP->getType() == Type::DoubleTy) {
489 if (Data64bitsDirective)
490 O << Data64bitsDirective << DoubleToBits(Val) << "\t" << CommentString
491 << " double value: " << Val << "\n";
492 else if (TD->isBigEndian()) {
493 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
494 << "\t" << CommentString << " double most significant word "
496 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
497 << "\t" << CommentString << " double least significant word "
500 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
501 << "\t" << CommentString << " double least significant word " << Val
503 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
504 << "\t" << CommentString << " double most significant word " << Val
509 O << Data32bitsDirective << FloatToBits(Val) << "\t" << CommentString
510 << " float " << Val << "\n";
513 } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
514 if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
515 uint64_t Val = CI->getRawValue();
517 if (Data64bitsDirective)
518 O << Data64bitsDirective << Val << "\n";
519 else if (TD->isBigEndian()) {
520 O << Data32bitsDirective << unsigned(Val >> 32)
521 << "\t" << CommentString << " Double-word most significant word "
523 O << Data32bitsDirective << unsigned(Val)
524 << "\t" << CommentString << " Double-word least significant word "
527 O << Data32bitsDirective << unsigned(Val)
528 << "\t" << CommentString << " Double-word least significant word "
530 O << Data32bitsDirective << unsigned(Val >> 32)
531 << "\t" << CommentString << " Double-word most significant word "
536 } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) {
537 const PackedType *PTy = CP->getType();
539 for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I)
540 EmitGlobalConstant(CP->getOperand(I));
545 const Type *type = CV->getType();
546 switch (type->getTypeID()) {
548 case Type::UByteTyID: case Type::SByteTyID:
549 O << Data8bitsDirective;
551 case Type::UShortTyID: case Type::ShortTyID:
552 O << Data16bitsDirective;
554 case Type::PointerTyID:
555 if (TD->getPointerSize() == 8) {
556 O << Data64bitsDirective;
559 //Fall through for pointer size == int size
560 case Type::UIntTyID: case Type::IntTyID:
561 O << Data32bitsDirective;
563 case Type::ULongTyID: case Type::LongTyID:
564 assert(Data64bitsDirective &&"Target cannot handle 64-bit constant exprs!");
565 O << Data64bitsDirective;
567 case Type::FloatTyID: case Type::DoubleTyID:
568 assert (0 && "Should have already output floating point constant.");
570 assert (0 && "Can't handle printing this type of thing");
573 EmitConstantValueOnly(CV);
577 /// printInlineAsm - This method formats and prints the specified machine
578 /// instruction that is an inline asm.
579 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
580 O << InlineAsmStart << "\n\t";
581 unsigned NumOperands = MI->getNumOperands();
583 // Count the number of register definitions.
584 unsigned NumDefs = 0;
585 for (; MI->getOperand(NumDefs).isDef(); ++NumDefs)
586 assert(NumDefs != NumOperands-1 && "No asm string?");
588 assert(MI->getOperand(NumDefs).isExternalSymbol() && "No asm string?");
590 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
591 const char *AsmStr = MI->getOperand(NumDefs).getSymbolName();
593 // The variant of the current asmprinter: FIXME: change.
594 int AsmPrinterVariant = 0;
596 int CurVariant = -1; // The number of the {.|.|.} region we are in.
597 const char *LastEmitted = AsmStr; // One past the last character emitted.
599 while (*LastEmitted) {
600 switch (*LastEmitted) {
602 // Not a special case, emit the string section literally.
603 const char *LiteralEnd = LastEmitted+1;
604 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
605 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
607 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
608 O.write(LastEmitted, LiteralEnd-LastEmitted);
609 LastEmitted = LiteralEnd;
613 ++LastEmitted; // Consume newline character.
614 O << "\n\t"; // Indent code with newline.
617 ++LastEmitted; // Consume '$' character.
618 if (*LastEmitted == '$') { // $$ -> $
619 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
621 ++LastEmitted; // Consume second '$' character.
625 bool HasCurlyBraces = false;
626 if (*LastEmitted == '{') { // ${variable}
627 ++LastEmitted; // Consume '{' character.
628 HasCurlyBraces = true;
631 const char *IDStart = LastEmitted;
633 long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
634 if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
635 std::cerr << "Bad $ operand number in inline asm string: '"
641 char Modifier[2] = { 0, 0 };
643 if (HasCurlyBraces) {
644 // If we have curly braces, check for a modifier character. This
645 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
646 if (*LastEmitted == ':') {
647 ++LastEmitted; // Consume ':' character.
648 if (*LastEmitted == 0) {
649 std::cerr << "Bad ${:} expression in inline asm string: '"
654 Modifier[0] = *LastEmitted;
655 ++LastEmitted; // Consume modifier character.
658 if (*LastEmitted != '}') {
659 std::cerr << "Bad ${} expression in inline asm string: '"
663 ++LastEmitted; // Consume '}' character.
666 if ((unsigned)Val >= NumOperands-1) {
667 std::cerr << "Invalid $ operand number in inline asm string: '"
672 // Okay, we finally have a value number. Ask the target to print this
674 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
677 // Scan to find the machine operand number for the operand.
679 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
680 OpNo += (OpFlags >> 3) + 1;
683 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
684 ++OpNo; // Skip over the ID number.
687 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
688 if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
689 Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
690 Modifier[0] ? Modifier : 0);
692 Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
693 Modifier[0] ? Modifier : 0);
696 std::cerr << "Invalid operand found in inline asm: '"
705 ++LastEmitted; // Consume '{' character.
706 if (CurVariant != -1) {
707 std::cerr << "Nested variants found in inline asm string: '"
711 CurVariant = 0; // We're in the first variant now.
714 ++LastEmitted; // consume '|' character.
715 if (CurVariant == -1) {
716 std::cerr << "Found '|' character outside of variant in inline asm "
717 << "string: '" << AsmStr << "'\n";
720 ++CurVariant; // We're in the next variant.
723 ++LastEmitted; // consume '}' character.
724 if (CurVariant == -1) {
725 std::cerr << "Found '}' character outside of variant in inline asm "
726 << "string: '" << AsmStr << "'\n";
733 O << "\n\t" << InlineAsmEnd << "\n";
736 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
737 /// instruction, using the specified assembler variant. Targets should
738 /// overried this to format as appropriate.
739 bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
740 unsigned AsmVariant, const char *ExtraCode) {
741 // Target doesn't support this yet!
745 bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
747 const char *ExtraCode) {
748 // Target doesn't support this yet!
752 /// printBasicBlockLabel - This method prints the label for the specified
753 /// MachineBasicBlock
754 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
756 bool printComment) const {
757 O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_"
762 O << '\t' << CommentString << MBB->getBasicBlock()->getName();