blob: c6166e2365a5811d766f9bb01e8584c09119689b [file] [log] [blame]
Chris Lattner7e1a8f82010-04-04 19:09:29 +00001//===-- AsmPrinterInlineAsm.cpp - AsmPrinter Inline Asm Handling ----------===//
Chris Lattner736e31d2010-04-04 18:34:07 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner7e1a8f82010-04-04 19:09:29 +000010// This file implements the inline assembler pieces of the AsmPrinter class.
Chris Lattner736e31d2010-04-04 18:34:07 +000011//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "asm-printer"
Chris Lattner736e31d2010-04-04 18:34:07 +000015#include "llvm/CodeGen/AsmPrinter.h"
Chris Lattnercf9a4152010-04-07 05:38:05 +000016#include "llvm/Constants.h"
Chris Lattner7e1a8f82010-04-04 19:09:29 +000017#include "llvm/InlineAsm.h"
Chris Lattner6eb78062010-04-06 00:55:39 +000018#include "llvm/LLVMContext.h"
19#include "llvm/Module.h"
Chris Lattner736e31d2010-04-04 18:34:07 +000020#include "llvm/CodeGen/MachineBasicBlock.h"
Chris Lattner6eb78062010-04-06 00:55:39 +000021#include "llvm/CodeGen/MachineModuleInfo.h"
Chris Lattner736e31d2010-04-04 18:34:07 +000022#include "llvm/MC/MCAsmInfo.h"
23#include "llvm/MC/MCStreamer.h"
24#include "llvm/MC/MCSymbol.h"
Chris Lattneraf632c92010-04-05 23:11:24 +000025#include "llvm/Target/TargetAsmParser.h"
26#include "llvm/Target/TargetMachine.h"
27#include "llvm/Target/TargetRegistry.h"
28#include "llvm/ADT/OwningPtr.h"
Chris Lattner736e31d2010-04-04 18:34:07 +000029#include "llvm/ADT/SmallString.h"
30#include "llvm/ADT/Twine.h"
31#include "llvm/Support/ErrorHandling.h"
Chris Lattneraf632c92010-04-05 23:11:24 +000032#include "llvm/Support/MemoryBuffer.h"
33#include "llvm/Support/SourceMgr.h"
Chris Lattner736e31d2010-04-04 18:34:07 +000034#include "llvm/Support/raw_ostream.h"
Chris Lattner736e31d2010-04-04 18:34:07 +000035using namespace llvm;
36
Chris Lattner6e30c6a2010-11-17 08:03:32 +000037namespace {
38 struct SrcMgrDiagInfo {
39 const MDNode *LocInfo;
Chris Lattner4afa1282010-11-17 08:13:01 +000040 LLVMContext::InlineAsmDiagHandlerTy DiagHandler;
Chris Lattner6e30c6a2010-11-17 08:03:32 +000041 void *DiagContext;
42 };
43}
44
45/// SrcMgrDiagHandler - This callback is invoked when the SourceMgr for an
46/// inline asm has an error in it. diagInfo is a pointer to the SrcMgrDiagInfo
47/// struct above.
Chris Lattner4afa1282010-11-17 08:13:01 +000048static void SrcMgrDiagHandler(const SMDiagnostic &Diag, void *diagInfo) {
Chris Lattner6e30c6a2010-11-17 08:03:32 +000049 SrcMgrDiagInfo *DiagInfo = static_cast<SrcMgrDiagInfo *>(diagInfo);
50 assert(DiagInfo && "Diagnostic context not passed down?");
51
Chris Lattnerce1b9ad2010-11-17 08:20:42 +000052 // If the inline asm had metadata associated with it, pull out a location
53 // cookie corresponding to which line the error occurred on.
Chris Lattner6e30c6a2010-11-17 08:03:32 +000054 unsigned LocCookie = 0;
Chris Lattnerce1b9ad2010-11-17 08:20:42 +000055 if (const MDNode *LocInfo = DiagInfo->LocInfo) {
56 unsigned ErrorLine = Diag.getLineNo()-1;
57 if (ErrorLine >= LocInfo->getNumOperands())
58 ErrorLine = 0;
59
60 if (LocInfo->getNumOperands() != 0)
61 if (const ConstantInt *CI =
62 dyn_cast<ConstantInt>(LocInfo->getOperand(ErrorLine)))
Chris Lattner6e30c6a2010-11-17 08:03:32 +000063 LocCookie = CI->getZExtValue();
Chris Lattnerce1b9ad2010-11-17 08:20:42 +000064 }
Chris Lattner6e30c6a2010-11-17 08:03:32 +000065
Chris Lattner4afa1282010-11-17 08:13:01 +000066 DiagInfo->DiagHandler(Diag, DiagInfo->DiagContext, LocCookie);
Chris Lattner6e30c6a2010-11-17 08:03:32 +000067}
68
Chris Lattner736e31d2010-04-04 18:34:07 +000069/// EmitInlineAsm - Emit a blob of inline asm to the output streamer.
Chris Lattnera38941d2010-11-17 07:53:40 +000070void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode) const {
Chris Lattner736e31d2010-04-04 18:34:07 +000071 assert(!Str.empty() && "Can't emit empty inline asm block");
Jim Grosbach2b2de242010-10-01 23:29:12 +000072
Chris Lattneraf632c92010-04-05 23:11:24 +000073 // Remember if the buffer is nul terminated or not so we can avoid a copy.
74 bool isNullTerminated = Str.back() == 0;
75 if (isNullTerminated)
76 Str = Str.substr(0, Str.size()-1);
Jim Grosbach2b2de242010-10-01 23:29:12 +000077
Chris Lattner736e31d2010-04-04 18:34:07 +000078 // If the output streamer is actually a .s file, just emit the blob textually.
79 // This is useful in case the asm parser doesn't handle something but the
80 // system assembler does.
81 if (OutStreamer.hasRawTextSupport()) {
82 OutStreamer.EmitRawText(Str);
83 return;
84 }
Jim Grosbach2b2de242010-10-01 23:29:12 +000085
Chris Lattneraf632c92010-04-05 23:11:24 +000086 SourceMgr SrcMgr;
Chris Lattner6e30c6a2010-11-17 08:03:32 +000087 SrcMgrDiagInfo DiagInfo;
Jim Grosbach2b2de242010-10-01 23:29:12 +000088
Chris Lattner6eb78062010-04-06 00:55:39 +000089 // If the current LLVMContext has an inline asm handler, set it in SourceMgr.
90 LLVMContext &LLVMCtx = MMI->getModule()->getContext();
91 bool HasDiagHandler = false;
Chris Lattner4afa1282010-11-17 08:13:01 +000092 if (LLVMCtx.getInlineAsmDiagnosticHandler() != 0) {
Chris Lattner6e30c6a2010-11-17 08:03:32 +000093 // If the source manager has an issue, we arrange for SrcMgrDiagHandler
94 // to be invoked, getting DiagInfo passed into it.
95 DiagInfo.LocInfo = LocMDNode;
Chris Lattner4afa1282010-11-17 08:13:01 +000096 DiagInfo.DiagHandler = LLVMCtx.getInlineAsmDiagnosticHandler();
Chris Lattner6e30c6a2010-11-17 08:03:32 +000097 DiagInfo.DiagContext = LLVMCtx.getInlineAsmDiagnosticContext();
98 SrcMgr.setDiagHandler(SrcMgrDiagHandler, &DiagInfo);
Chris Lattner6eb78062010-04-06 00:55:39 +000099 HasDiagHandler = true;
100 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000101
Chris Lattneraf632c92010-04-05 23:11:24 +0000102 MemoryBuffer *Buffer;
103 if (isNullTerminated)
104 Buffer = MemoryBuffer::getMemBuffer(Str, "<inline asm>");
105 else
106 Buffer = MemoryBuffer::getMemBufferCopy(Str, "<inline asm>");
107
108 // Tell SrcMgr about this buffer, it takes ownership of the buffer.
109 SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
Jim Grosbach2b2de242010-10-01 23:29:12 +0000110
Daniel Dunbar9fbb37e2010-07-18 18:31:33 +0000111 OwningPtr<MCAsmParser> Parser(createMCAsmParser(TM.getTarget(), SrcMgr,
112 OutContext, OutStreamer,
113 *MAI));
Daniel Dunbard73ada72010-07-19 00:33:49 +0000114 OwningPtr<TargetAsmParser> TAP(TM.getTarget().createAsmParser(*Parser, TM));
Chris Lattneraf632c92010-04-05 23:11:24 +0000115 if (!TAP)
Chris Lattner75361b62010-04-07 22:58:41 +0000116 report_fatal_error("Inline asm not supported by this streamer because"
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000117 " we don't have an asm parser for this target\n");
Daniel Dunbar9fbb37e2010-07-18 18:31:33 +0000118 Parser->setTargetParser(*TAP.get());
Chris Lattneraf632c92010-04-05 23:11:24 +0000119
120 // Don't implicitly switch to the text section before the asm.
Daniel Dunbar9fbb37e2010-07-18 18:31:33 +0000121 int Res = Parser->Run(/*NoInitialTextSection*/ true,
122 /*NoFinalize*/ true);
Chris Lattner6eb78062010-04-06 00:55:39 +0000123 if (Res && !HasDiagHandler)
Chris Lattner75361b62010-04-07 22:58:41 +0000124 report_fatal_error("Error parsing inline asm\n");
Chris Lattner736e31d2010-04-04 18:34:07 +0000125}
126
127
128/// EmitInlineAsm - This method formats and emits the specified machine
129/// instruction that is an inline asm.
130void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const {
131 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms");
Jim Grosbach2b2de242010-10-01 23:29:12 +0000132
Chris Lattner736e31d2010-04-04 18:34:07 +0000133 unsigned NumOperands = MI->getNumOperands();
Jim Grosbach2b2de242010-10-01 23:29:12 +0000134
Chris Lattner736e31d2010-04-04 18:34:07 +0000135 // Count the number of register definitions to find the asm string.
136 unsigned NumDefs = 0;
137 for (; MI->getOperand(NumDefs).isReg() && MI->getOperand(NumDefs).isDef();
138 ++NumDefs)
Chris Lattnercf9a4152010-04-07 05:38:05 +0000139 assert(NumDefs != NumOperands-2 && "No asm string?");
Jim Grosbach2b2de242010-10-01 23:29:12 +0000140
Chris Lattner736e31d2010-04-04 18:34:07 +0000141 assert(MI->getOperand(NumDefs).isSymbol() && "No asm string?");
142
143 // Disassemble the AsmStr, printing out the literal pieces, the operands, etc.
144 const char *AsmStr = MI->getOperand(NumDefs).getSymbolName();
145
146 // If this asmstr is empty, just print the #APP/#NOAPP markers.
147 // These are useful to see where empty asm's wound up.
148 if (AsmStr[0] == 0) {
Chris Lattner4c842dd2010-04-05 22:42:30 +0000149 // Don't emit the comments if writing to a .o file.
Chris Lattner736e31d2010-04-04 18:34:07 +0000150 if (!OutStreamer.hasRawTextSupport()) return;
151
152 OutStreamer.EmitRawText(Twine("\t")+MAI->getCommentString()+
153 MAI->getInlineAsmStart());
154 OutStreamer.EmitRawText(Twine("\t")+MAI->getCommentString()+
155 MAI->getInlineAsmEnd());
156 return;
157 }
158
159 // Emit the #APP start marker. This has to happen even if verbose-asm isn't
160 // enabled, so we use EmitRawText.
161 if (OutStreamer.hasRawTextSupport())
162 OutStreamer.EmitRawText(Twine("\t")+MAI->getCommentString()+
163 MAI->getInlineAsmStart());
164
Chris Lattnercf9a4152010-04-07 05:38:05 +0000165 // Get the !srcloc metadata node if we have it, and decode the loc cookie from
166 // it.
167 unsigned LocCookie = 0;
Chris Lattnera38941d2010-11-17 07:53:40 +0000168 const MDNode *LocMD = 0;
Chris Lattnerd0024fe2010-04-08 18:20:52 +0000169 for (unsigned i = MI->getNumOperands(); i != 0; --i) {
Chris Lattnera38941d2010-11-17 07:53:40 +0000170 if (MI->getOperand(i-1).isMetadata() &&
171 (LocMD = MI->getOperand(i-1).getMetadata()) &&
172 LocMD->getNumOperands() != 0) {
173 if (const ConstantInt *CI = dyn_cast<ConstantInt>(LocMD->getOperand(0))) {
174 LocCookie = CI->getZExtValue();
175 break;
176 }
177 }
Chris Lattnercf9a4152010-04-07 05:38:05 +0000178 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000179
Chris Lattner736e31d2010-04-04 18:34:07 +0000180 // Emit the inline asm to a temporary string so we can emit it through
181 // EmitInlineAsm.
182 SmallString<256> StringData;
183 raw_svector_ostream OS(StringData);
Jim Grosbach2b2de242010-10-01 23:29:12 +0000184
Chris Lattner736e31d2010-04-04 18:34:07 +0000185 OS << '\t';
186
187 // The variant of the current asmprinter.
188 int AsmPrinterVariant = MAI->getAssemblerDialect();
189
190 int CurVariant = -1; // The number of the {.|.|.} region we are in.
191 const char *LastEmitted = AsmStr; // One past the last character emitted.
Jim Grosbach2b2de242010-10-01 23:29:12 +0000192
Chris Lattner736e31d2010-04-04 18:34:07 +0000193 while (*LastEmitted) {
194 switch (*LastEmitted) {
195 default: {
196 // Not a special case, emit the string section literally.
197 const char *LiteralEnd = LastEmitted+1;
198 while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' &&
199 *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n')
200 ++LiteralEnd;
201 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
202 OS.write(LastEmitted, LiteralEnd-LastEmitted);
203 LastEmitted = LiteralEnd;
204 break;
205 }
206 case '\n':
207 ++LastEmitted; // Consume newline character.
Chris Lattner4c842dd2010-04-05 22:42:30 +0000208 OS << '\n'; // Indent code with newline.
Chris Lattner736e31d2010-04-04 18:34:07 +0000209 break;
210 case '$': {
211 ++LastEmitted; // Consume '$' character.
212 bool Done = true;
213
214 // Handle escapes.
215 switch (*LastEmitted) {
216 default: Done = false; break;
217 case '$': // $$ -> $
218 if (CurVariant == -1 || CurVariant == AsmPrinterVariant)
219 OS << '$';
220 ++LastEmitted; // Consume second '$' character.
221 break;
222 case '(': // $( -> same as GCC's { character.
223 ++LastEmitted; // Consume '(' character.
Chris Lattnerfee455e2010-04-07 05:27:36 +0000224 if (CurVariant != -1)
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000225 report_fatal_error("Nested variants found in inline asm string: '" +
226 Twine(AsmStr) + "'");
Chris Lattner736e31d2010-04-04 18:34:07 +0000227 CurVariant = 0; // We're in the first variant now.
228 break;
229 case '|':
230 ++LastEmitted; // consume '|' character.
231 if (CurVariant == -1)
232 OS << '|'; // this is gcc's behavior for | outside a variant
233 else
234 ++CurVariant; // We're in the next variant.
235 break;
236 case ')': // $) -> same as GCC's } char.
237 ++LastEmitted; // consume ')' character.
238 if (CurVariant == -1)
239 OS << '}'; // this is gcc's behavior for } outside a variant
Jim Grosbach2b2de242010-10-01 23:29:12 +0000240 else
Chris Lattner736e31d2010-04-04 18:34:07 +0000241 CurVariant = -1;
242 break;
243 }
244 if (Done) break;
Jim Grosbach2b2de242010-10-01 23:29:12 +0000245
Chris Lattner736e31d2010-04-04 18:34:07 +0000246 bool HasCurlyBraces = false;
247 if (*LastEmitted == '{') { // ${variable}
248 ++LastEmitted; // Consume '{' character.
249 HasCurlyBraces = true;
250 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000251
Chris Lattner736e31d2010-04-04 18:34:07 +0000252 // If we have ${:foo}, then this is not a real operand reference, it is a
253 // "magic" string reference, just like in .td files. Arrange to call
254 // PrintSpecial.
255 if (HasCurlyBraces && *LastEmitted == ':') {
256 ++LastEmitted;
257 const char *StrStart = LastEmitted;
258 const char *StrEnd = strchr(StrStart, '}');
259 if (StrEnd == 0)
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000260 report_fatal_error("Unterminated ${:foo} operand in inline asm"
261 " string: '" + Twine(AsmStr) + "'");
Jim Grosbach2b2de242010-10-01 23:29:12 +0000262
Chris Lattner736e31d2010-04-04 18:34:07 +0000263 std::string Val(StrStart, StrEnd);
264 PrintSpecial(MI, OS, Val.c_str());
265 LastEmitted = StrEnd+1;
266 break;
267 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000268
Chris Lattner736e31d2010-04-04 18:34:07 +0000269 const char *IDStart = LastEmitted;
Chris Lattner65eeaad2010-04-04 18:42:18 +0000270 const char *IDEnd = IDStart;
Jim Grosbach2b2de242010-10-01 23:29:12 +0000271 while (*IDEnd >= '0' && *IDEnd <= '9') ++IDEnd;
272
Chris Lattner65eeaad2010-04-04 18:42:18 +0000273 unsigned Val;
274 if (StringRef(IDStart, IDEnd-IDStart).getAsInteger(10, Val))
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000275 report_fatal_error("Bad $ operand number in inline asm string: '" +
276 Twine(AsmStr) + "'");
Chris Lattner736e31d2010-04-04 18:34:07 +0000277 LastEmitted = IDEnd;
Jim Grosbach2b2de242010-10-01 23:29:12 +0000278
Chris Lattner736e31d2010-04-04 18:34:07 +0000279 char Modifier[2] = { 0, 0 };
Jim Grosbach2b2de242010-10-01 23:29:12 +0000280
Chris Lattner736e31d2010-04-04 18:34:07 +0000281 if (HasCurlyBraces) {
282 // If we have curly braces, check for a modifier character. This
283 // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm.
284 if (*LastEmitted == ':') {
285 ++LastEmitted; // Consume ':' character.
Chris Lattner4c842dd2010-04-05 22:42:30 +0000286 if (*LastEmitted == 0)
Chris Lattner75361b62010-04-07 22:58:41 +0000287 report_fatal_error("Bad ${:} expression in inline asm string: '" +
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000288 Twine(AsmStr) + "'");
Jim Grosbach2b2de242010-10-01 23:29:12 +0000289
Chris Lattner736e31d2010-04-04 18:34:07 +0000290 Modifier[0] = *LastEmitted;
291 ++LastEmitted; // Consume modifier character.
292 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000293
Chris Lattner4c842dd2010-04-05 22:42:30 +0000294 if (*LastEmitted != '}')
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000295 report_fatal_error("Bad ${} expression in inline asm string: '" +
296 Twine(AsmStr) + "'");
Chris Lattner736e31d2010-04-04 18:34:07 +0000297 ++LastEmitted; // Consume '}' character.
298 }
Jim Grosbach2b2de242010-10-01 23:29:12 +0000299
Chris Lattner4c842dd2010-04-05 22:42:30 +0000300 if (Val >= NumOperands-1)
Benjamin Kramer1bd73352010-04-08 10:44:28 +0000301 report_fatal_error("Invalid $ operand number in inline asm string: '" +
302 Twine(AsmStr) + "'");
Jim Grosbach2b2de242010-10-01 23:29:12 +0000303
Chris Lattner736e31d2010-04-04 18:34:07 +0000304 // Okay, we finally have a value number. Ask the target to print this
305 // operand!
306 if (CurVariant == -1 || CurVariant == AsmPrinterVariant) {
Evan Chengc36b7062011-01-07 23:50:32 +0000307 unsigned OpNo = InlineAsm::MIOp_FirstOperand;
Chris Lattner736e31d2010-04-04 18:34:07 +0000308
309 bool Error = false;
310
311 // Scan to find the machine operand number for the operand.
312 for (; Val; --Val) {
313 if (OpNo >= MI->getNumOperands()) break;
314 unsigned OpFlags = MI->getOperand(OpNo).getImm();
315 OpNo += InlineAsm::getNumOperandRegisters(OpFlags) + 1;
316 }
317
318 if (OpNo >= MI->getNumOperands()) {
319 Error = true;
320 } else {
321 unsigned OpFlags = MI->getOperand(OpNo).getImm();
322 ++OpNo; // Skip over the ID number.
323
324 if (Modifier[0] == 'l') // labels are target independent
325 // FIXME: What if the operand isn't an MBB, report error?
326 OS << *MI->getOperand(OpNo).getMBB()->getSymbol();
327 else {
328 AsmPrinter *AP = const_cast<AsmPrinter*>(this);
Chris Lattnerfee455e2010-04-07 05:27:36 +0000329 if (InlineAsm::isMemKind(OpFlags)) {
Chris Lattner736e31d2010-04-04 18:34:07 +0000330 Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant,
331 Modifier[0] ? Modifier : 0,
332 OS);
333 } else {
334 Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant,
335 Modifier[0] ? Modifier : 0, OS);
336 }
337 }
338 }
339 if (Error) {
340 std::string msg;
341 raw_string_ostream Msg(msg);
Chris Lattner38686bd2010-04-07 23:40:44 +0000342 Msg << "invalid operand in inline asm: '" << AsmStr << "'";
343 MMI->getModule()->getContext().emitError(LocCookie, Msg.str());
Chris Lattner736e31d2010-04-04 18:34:07 +0000344 }
345 }
346 break;
347 }
348 }
349 }
Chris Lattneraf632c92010-04-05 23:11:24 +0000350 OS << '\n' << (char)0; // null terminate string.
Chris Lattnera38941d2010-11-17 07:53:40 +0000351 EmitInlineAsm(OS.str(), LocMD);
Jim Grosbach2b2de242010-10-01 23:29:12 +0000352
Chris Lattner736e31d2010-04-04 18:34:07 +0000353 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't
354 // enabled, so we use EmitRawText.
355 if (OutStreamer.hasRawTextSupport())
356 OutStreamer.EmitRawText(Twine("\t")+MAI->getCommentString()+
357 MAI->getInlineAsmEnd());
358}
359
360
361/// PrintSpecial - Print information related to the specified machine instr
362/// that is independent of the operand, and may be independent of the instr
363/// itself. This can be useful for portably encoding the comment character
364/// or other bits of target-specific knowledge into the asmstrings. The
365/// syntax used is ${:comment}. Targets can override this to add support
366/// for their own strange codes.
367void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS,
368 const char *Code) const {
369 if (!strcmp(Code, "private")) {
370 OS << MAI->getPrivateGlobalPrefix();
371 } else if (!strcmp(Code, "comment")) {
372 OS << MAI->getCommentString();
373 } else if (!strcmp(Code, "uid")) {
374 // Comparing the address of MI isn't sufficient, because machineinstrs may
375 // be allocated to the same address across functions.
Jim Grosbach2b2de242010-10-01 23:29:12 +0000376
Chris Lattner736e31d2010-04-04 18:34:07 +0000377 // If this is a new LastFn instruction, bump the counter.
378 if (LastMI != MI || LastFn != getFunctionNumber()) {
379 ++Counter;
380 LastMI = MI;
381 LastFn = getFunctionNumber();
382 }
383 OS << Counter;
384 } else {
385 std::string msg;
386 raw_string_ostream Msg(msg);
387 Msg << "Unknown special formatter '" << Code
388 << "' for machine instr: " << *MI;
Chris Lattner75361b62010-04-07 22:58:41 +0000389 report_fatal_error(Msg.str());
Jim Grosbach2b2de242010-10-01 23:29:12 +0000390 }
Chris Lattner736e31d2010-04-04 18:34:07 +0000391}
392
393/// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
394/// instruction, using the specified assembler variant. Targets should
395/// override this to format as appropriate.
396bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
397 unsigned AsmVariant, const char *ExtraCode,
398 raw_ostream &O) {
399 // Target doesn't support this yet!
400 return true;
401}
402
403bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
404 unsigned AsmVariant,
405 const char *ExtraCode, raw_ostream &O) {
406 // Target doesn't support this yet!
407 return true;
408}
409