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 O << CurrentSection << "\tsegment 'CODE'\n";
85 if (GV && GV->hasSection())
86 NS = SwitchToSectionDirective + GV->getSection();
88 NS = std::string("\t")+NewSection;
90 if (CurrentSection != NS) {
92 if (!CurrentSection.empty())
93 O << CurrentSection << '\n';
98 /// SwitchToTextSection - Switch to the specified text section of the executable
99 /// if we are not already in it!
101 void AsmPrinter::SwitchToDataSection(const char *NewSection,
102 const GlobalValue *GV) {
105 // Microsoft ML/MASM has a fundamentally different approach to handling
109 if (GV && GV->hasSection())
110 NS = GV->getSection();
114 if (CurrentSection != NS) {
115 if (!CurrentSection.empty())
116 O << CurrentSection << "\tends\n\n";
118 O << CurrentSection << "\tsegment 'DATA'\n";
121 if (GV && GV->hasSection())
122 NS = SwitchToSectionDirective + GV->getSection();
124 NS = std::string("\t")+NewSection;
126 if (CurrentSection != NS) {
128 if (!CurrentSection.empty())
129 O << CurrentSection << '\n';
135 bool AsmPrinter::doInitialization(Module &M) {
136 Mang = new Mangler(M, GlobalPrefix);
138 if (!M.getModuleInlineAsm().empty())
139 O << CommentString << " Start of file scope inline assembly\n"
140 << M.getModuleInlineAsm()
141 << "\n" << CommentString << " End of file scope inline assembly\n";
143 SwitchToDataSection("", 0); // Reset back to no section.
145 if (MachineDebugInfo *DebugInfo = getAnalysisToUpdate<MachineDebugInfo>()) {
146 DebugInfo->AnalyzeModule(M);
152 bool AsmPrinter::doFinalization(Module &M) {
153 delete Mang; Mang = 0;
157 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
158 // What's my mangled name?
159 CurrentFnName = Mang->getValueName(MF.getFunction());
160 IncrementFunctionNumber();
163 /// EmitConstantPool - Print to the current output stream assembly
164 /// representations of the constants in the constant pool MCP. This is
165 /// used to print out constants which have been "spilled to memory" by
166 /// the code generator.
168 void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) {
169 const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants();
170 if (CP.empty()) return;
171 const TargetData *TD = TM.getTargetData();
173 SwitchToDataSection(ConstantPoolSection, 0);
174 EmitAlignment(MCP->getConstantPoolAlignment());
175 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
176 O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
177 << ":\t\t\t\t\t" << CommentString << " ";
178 WriteTypeSymbolic(O, CP[i].Val->getType(), 0) << '\n';
179 EmitGlobalConstant(CP[i].Val);
181 unsigned EntSize = TM.getTargetData()->getTypeSize(CP[i].Val->getType());
182 unsigned ValEnd = CP[i].Offset + EntSize;
183 // Emit inter-object padding for alignment.
184 EmitZeros(CP[i+1].Offset-ValEnd);
189 /// EmitJumpTableInfo - Print assembly representations of the jump tables used
190 /// by the current function to the current output stream.
192 void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) {
193 const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables();
194 if (JT.empty()) return;
195 const TargetData *TD = TM.getTargetData();
197 // FIXME: someday we need to handle PIC jump tables
198 assert((TM.getRelocationModel() == Reloc::Static ||
199 TM.getRelocationModel() == Reloc::DynamicNoPIC) &&
200 "Unhandled relocation model emitting jump table information!");
202 SwitchToDataSection(JumpTableSection, 0);
203 EmitAlignment(Log2_32(TD->getPointerAlignment()));
204 for (unsigned i = 0, e = JT.size(); i != e; ++i) {
205 O << PrivateGlobalPrefix << "JTI" << getFunctionNumber() << '_' << i
207 const std::vector<MachineBasicBlock*> &JTBBs = JT[i].MBBs;
208 for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
209 O << Data32bitsDirective << ' ';
210 printBasicBlockLabel(JTBBs[ii]);
216 /// EmitSpecialLLVMGlobal - Check to see if the specified global is a
217 /// special global used by LLVM. If so, emit it and return true, otherwise
218 /// do nothing and return false.
219 bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) {
220 // Ignore debug and non-emitted data.
221 if (GV->getSection() == "llvm.metadata") return true;
223 if (!GV->hasAppendingLinkage()) return false;
225 assert(GV->hasInitializer() && "Not a special LLVM global!");
227 if (GV->getName() == "llvm.used")
228 return true; // No need to emit this at all.
230 if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) {
231 SwitchToDataSection(StaticCtorsSection, 0);
233 EmitXXStructorList(GV->getInitializer());
237 if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) {
238 SwitchToDataSection(StaticDtorsSection, 0);
240 EmitXXStructorList(GV->getInitializer());
247 /// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the
248 /// function pointers, ignoring the init priority.
249 void AsmPrinter::EmitXXStructorList(Constant *List) {
250 // Should be an array of '{ int, void ()* }' structs. The first value is the
251 // init priority, which we ignore.
252 if (!isa<ConstantArray>(List)) return;
253 ConstantArray *InitList = cast<ConstantArray>(List);
254 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i)
255 if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){
256 if (CS->getNumOperands() != 2) return; // Not array of 2-element structs.
258 if (CS->getOperand(1)->isNullValue())
259 return; // Found a null terminator, exit printing.
260 // Emit the function pointer.
261 EmitGlobalConstant(CS->getOperand(1));
265 /// getPreferredAlignmentLog - Return the preferred alignment of the
266 /// specified global, returned in log form. This includes an explicitly
267 /// requested alignment (if the global has one).
268 unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const {
269 unsigned Alignment = TM.getTargetData()->getTypeAlignmentShift(GV->getType());
270 if (GV->getAlignment() > (1U << Alignment))
271 Alignment = Log2_32(GV->getAlignment());
273 if (GV->hasInitializer()) {
274 // Always round up alignment of global doubles to 8 bytes.
275 if (GV->getType()->getElementType() == Type::DoubleTy && Alignment < 3)
278 // If the global is not external, see if it is large. If so, give it a
280 if (TM.getTargetData()->getTypeSize(GV->getType()->getElementType()) > 128)
281 Alignment = 4; // 16-byte alignment.
287 // EmitAlignment - Emit an alignment directive to the specified power of two.
288 void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const {
289 if (GV && GV->getAlignment())
290 NumBits = Log2_32(GV->getAlignment());
291 if (NumBits == 0) return; // No need to emit alignment.
292 if (AlignmentIsInBytes) NumBits = 1 << NumBits;
293 O << AlignDirective << NumBits << "\n";
296 /// EmitZeros - Emit a block of zeros.
298 void AsmPrinter::EmitZeros(uint64_t NumZeros) const {
301 O << ZeroDirective << NumZeros;
302 if (ZeroDirectiveSuffix)
303 O << ZeroDirectiveSuffix;
306 for (; NumZeros; --NumZeros)
307 O << Data8bitsDirective << "0\n";
312 // Print out the specified constant, without a storage class. Only the
313 // constants valid in constant expressions can occur here.
314 void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
315 if (CV->isNullValue() || isa<UndefValue>(CV))
317 else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
318 assert(CB == ConstantBool::True);
320 } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV))
321 if (((CI->getValue() << 32) >> 32) == CI->getValue())
324 O << (uint64_t)CI->getValue();
325 else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV))
327 else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) {
328 // This is a constant address for a global variable or function. Use the
329 // name of the variable or function as the address value, possibly
330 // decorating it with GlobalVarAddrPrefix/Suffix or
331 // FunctionAddrPrefix/Suffix (these all default to "" )
332 if (isa<Function>(GV))
333 O << FunctionAddrPrefix << Mang->getValueName(GV) << FunctionAddrSuffix;
335 O << GlobalVarAddrPrefix << Mang->getValueName(GV) << GlobalVarAddrSuffix;
336 } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
337 const TargetData *TD = TM.getTargetData();
338 switch(CE->getOpcode()) {
339 case Instruction::GetElementPtr: {
340 // generate a symbolic expression for the byte address
341 const Constant *ptrVal = CE->getOperand(0);
342 std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end());
343 if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), idxVec)) {
346 EmitConstantValueOnly(ptrVal);
348 O << ") + " << Offset;
350 O << ") - " << -Offset;
352 EmitConstantValueOnly(ptrVal);
356 case Instruction::Cast: {
357 // Support only non-converting or widening casts for now, that is, ones
358 // that do not involve a change in value. This assertion is really gross,
359 // and may not even be a complete check.
360 Constant *Op = CE->getOperand(0);
361 const Type *OpTy = Op->getType(), *Ty = CE->getType();
363 // Remember, kids, pointers can be losslessly converted back and forth
364 // into 32-bit or wider integers, regardless of signedness. :-P
365 assert(((isa<PointerType>(OpTy)
366 && (Ty == Type::LongTy || Ty == Type::ULongTy
367 || Ty == Type::IntTy || Ty == Type::UIntTy))
368 || (isa<PointerType>(Ty)
369 && (OpTy == Type::LongTy || OpTy == Type::ULongTy
370 || OpTy == Type::IntTy || OpTy == Type::UIntTy))
371 || (((TD->getTypeSize(Ty) >= TD->getTypeSize(OpTy))
372 && OpTy->isLosslesslyConvertibleTo(Ty))))
373 && "FIXME: Don't yet support this kind of constant cast expr");
374 EmitConstantValueOnly(Op);
377 case Instruction::Add:
379 EmitConstantValueOnly(CE->getOperand(0));
381 EmitConstantValueOnly(CE->getOperand(1));
385 assert(0 && "Unsupported operator!");
388 assert(0 && "Unknown constant value!");
392 /// toOctal - Convert the low order bits of X into an octal digit.
394 static inline char toOctal(int X) {
398 /// printAsCString - Print the specified array as a C compatible string, only if
399 /// the predicate isString is true.
401 static void printAsCString(std::ostream &O, const ConstantArray *CVA,
403 assert(CVA->isString() && "Array is not string compatible!");
406 for (unsigned i = 0; i != LastElt; ++i) {
408 (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
412 } else if (C == '\\') {
414 } else if (isprint(C)) {
418 case '\b': O << "\\b"; break;
419 case '\f': O << "\\f"; break;
420 case '\n': O << "\\n"; break;
421 case '\r': O << "\\r"; break;
422 case '\t': O << "\\t"; break;
425 O << toOctal(C >> 6);
426 O << toOctal(C >> 3);
427 O << toOctal(C >> 0);
435 /// EmitString - Emit a zero-byte-terminated string constant.
437 void AsmPrinter::EmitString(const ConstantArray *CVA) const {
438 unsigned NumElts = CVA->getNumOperands();
439 if (AscizDirective && NumElts &&
440 cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) {
442 printAsCString(O, CVA, NumElts-1);
445 printAsCString(O, CVA, NumElts);
450 /// EmitGlobalConstant - Print a general LLVM constant to the .s file.
452 void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
453 const TargetData *TD = TM.getTargetData();
455 if (CV->isNullValue() || isa<UndefValue>(CV)) {
456 EmitZeros(TD->getTypeSize(CV->getType()));
458 } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
459 if (CVA->isString()) {
461 } else { // Not a string. Print the values in successive locations
462 for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
463 EmitGlobalConstant(CVA->getOperand(i));
466 } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
467 // Print the fields in successive locations. Pad to align if needed!
468 const StructLayout *cvsLayout = TD->getStructLayout(CVS->getType());
469 uint64_t sizeSoFar = 0;
470 for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) {
471 const Constant* field = CVS->getOperand(i);
473 // Check if padding is needed and insert one or more 0s.
474 uint64_t fieldSize = TD->getTypeSize(field->getType());
475 uint64_t padSize = ((i == e-1? cvsLayout->StructSize
476 : cvsLayout->MemberOffsets[i+1])
477 - cvsLayout->MemberOffsets[i]) - fieldSize;
478 sizeSoFar += fieldSize + padSize;
480 // Now print the actual field value
481 EmitGlobalConstant(field);
483 // Insert the field padding unless it's zero bytes...
486 assert(sizeSoFar == cvsLayout->StructSize &&
487 "Layout of constant struct may be incorrect!");
489 } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) {
490 // FP Constants are printed as integer constants to avoid losing
492 double Val = CFP->getValue();
493 if (CFP->getType() == Type::DoubleTy) {
494 if (Data64bitsDirective)
495 O << Data64bitsDirective << DoubleToBits(Val) << "\t" << CommentString
496 << " double value: " << Val << "\n";
497 else if (TD->isBigEndian()) {
498 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
499 << "\t" << CommentString << " double most significant word "
501 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
502 << "\t" << CommentString << " double least significant word "
505 O << Data32bitsDirective << unsigned(DoubleToBits(Val))
506 << "\t" << CommentString << " double least significant word " << Val
508 O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32)
509 << "\t" << CommentString << " double most significant word " << Val
514 O << Data32bitsDirective << FloatToBits(Val) << "\t" << CommentString
515 << " float " << Val << "\n";
518 } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
519 if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
520 uint64_t Val = CI->getRawValue();
522 if (Data64bitsDirective)
523 O << Data64bitsDirective << Val << "\n";
524 else if (TD->isBigEndian()) {
525 O << Data32bitsDirective << unsigned(Val >> 32)
526 << "\t" << CommentString << " Double-word most significant word "
528 O << Data32bitsDirective << unsigned(Val)
529 << "\t" << CommentString << " Double-word least significant word "
532 O << Data32bitsDirective << unsigned(Val)
533 << "\t" << CommentString << " Double-word least significant word "
535 O << Data32bitsDirective << unsigned(Val >> 32)
536 << "\t" << CommentString << " Double-word most significant word "
541 } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) {
542 const PackedType *PTy = CP->getType();
544 for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I)
545 EmitGlobalConstant(CP->getOperand(I));
550 const Type *type = CV->getType();
551 switch (type->getTypeID()) {
553 case Type::UByteTyID: case Type::SByteTyID:
554 O << Data8bitsDirective;
556 case Type::UShortTyID: case Type::ShortTyID:
557 O << Data16bitsDirective;
559 case Type::PointerTyID:
560 if (TD->getPointerSize() == 8) {
561 O << Data64bitsDirective;
564 //Fall through for pointer size == int size
565 case Type::UIntTyID: case Type::IntTyID:
566 O << Data32bitsDirective;
568 case Type::ULongTyID: case Type::LongTyID:
569 assert(Data64bitsDirective &&"Target cannot handle 64-bit constant exprs!");
570 O << Data64bitsDirective;
572 case Type::FloatTyID: case Type::DoubleTyID:
573 assert (0 && "Should have already output floating point constant.");
575 assert (0 && "Can't handle printing this type of thing");
578 EmitConstantValueOnly(CV);
582 /// printInlineAsm - This method formats and prints the specified machine
583 /// instruction that is an inline asm.
584 void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
585 O << InlineAsmStart << "\n\t";
586 unsigned NumOperands = MI->getNumOperands();
588 // Count the number of register definitions.
589 unsigned NumDefs = 0;
590 for (; MI->getOperand(NumDefs).isDef(); ++NumDefs)
591 assert(NumDefs != NumOperands-1 && "No asm string?");
593 assert(MI->getOperand(NumDefs).isExternalSymbol() && "No asm string?");
595 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
596 const char *AsmStr = MI->getOperand(NumDefs).getSymbolName();
598 // The variant of the current asmprinter: FIXME: change.
599 int AsmPrinterVariant = 0;
601 int CurVariant = -1; // The number of the {.|.|.} region we are in.
602 const char *LastEmitted = AsmStr; // One past the last character emitted.
604 while (*LastEmitted) {
605 switch (*LastEmitted) {
607 // Not a special case, emit the string section literally.
608 const char *LiteralEnd = LastEmitted+1;
609 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
610 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
612 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
613 O.write(LastEmitted, LiteralEnd-LastEmitted);
614 LastEmitted = LiteralEnd;
618 ++LastEmitted; // Consume newline character.
619 O << "\n\t"; // Indent code with newline.
622 ++LastEmitted; // Consume '$' character.
623 if (*LastEmitted == '$') { // $$ -> $
624 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
626 ++LastEmitted; // Consume second '$' character.
630 bool HasCurlyBraces = false;
631 if (*LastEmitted == '{') { // ${variable}
632 ++LastEmitted; // Consume '{' character.
633 HasCurlyBraces = true;
636 const char *IDStart = LastEmitted;
638 long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
639 if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
640 std::cerr << "Bad $ operand number in inline asm string: '"
646 char Modifier[2] = { 0, 0 };
648 if (HasCurlyBraces) {
649 // If we have curly braces, check for a modifier character. This
650 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
651 if (*LastEmitted == ':') {
652 ++LastEmitted; // Consume ':' character.
653 if (*LastEmitted == 0) {
654 std::cerr << "Bad ${:} expression in inline asm string: '"
659 Modifier[0] = *LastEmitted;
660 ++LastEmitted; // Consume modifier character.
663 if (*LastEmitted != '}') {
664 std::cerr << "Bad ${} expression in inline asm string: '"
668 ++LastEmitted; // Consume '}' character.
671 if ((unsigned)Val >= NumOperands-1) {
672 std::cerr << "Invalid $ operand number in inline asm string: '"
677 // Okay, we finally have a value number. Ask the target to print this
679 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
682 // Scan to find the machine operand number for the operand.
684 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
685 OpNo += (OpFlags >> 3) + 1;
688 unsigned OpFlags = MI->getOperand(OpNo).getImmedValue();
689 ++OpNo; // Skip over the ID number.
692 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
693 if ((OpFlags & 7) == 4 /*ADDR MODE*/) {
694 Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
695 Modifier[0] ? Modifier : 0);
697 Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
698 Modifier[0] ? Modifier : 0);
701 std::cerr << "Invalid operand found in inline asm: '"
710 ++LastEmitted; // Consume '{' character.
711 if (CurVariant != -1) {
712 std::cerr << "Nested variants found in inline asm string: '"
716 CurVariant = 0; // We're in the first variant now.
719 ++LastEmitted; // consume '|' character.
720 if (CurVariant == -1) {
721 std::cerr << "Found '|' character outside of variant in inline asm "
722 << "string: '" << AsmStr << "'\n";
725 ++CurVariant; // We're in the next variant.
728 ++LastEmitted; // consume '}' character.
729 if (CurVariant == -1) {
730 std::cerr << "Found '}' character outside of variant in inline asm "
731 << "string: '" << AsmStr << "'\n";
738 O << "\n\t" << InlineAsmEnd << "\n";
741 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
742 /// instruction, using the specified assembler variant. Targets should
743 /// overried this to format as appropriate.
744 bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
745 unsigned AsmVariant, const char *ExtraCode) {
746 // Target doesn't support this yet!
750 bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
752 const char *ExtraCode) {
753 // Target doesn't support this yet!
757 /// printBasicBlockLabel - This method prints the label for the specified
758 /// MachineBasicBlock
759 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
761 bool printComment) const {
762 O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_"
767 O << '\t' << CommentString << MBB->getBasicBlock()->getName();