| OLD | NEW |
| 1 //===-- AsmPrinterInlineAsm.cpp - AsmPrinter Inline Asm Handling ----------===// | 1 //===-- AsmPrinterInlineAsm.cpp - AsmPrinter Inline Asm Handling ----------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This file implements the inline assembler pieces of the AsmPrinter class. | 10 // This file implements the inline assembler pieces of the AsmPrinter class. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 dyn_cast<ConstantInt>(LocInfo->getOperand(ErrorLine))) | 67 dyn_cast<ConstantInt>(LocInfo->getOperand(ErrorLine))) |
| 68 LocCookie = CI->getZExtValue(); | 68 LocCookie = CI->getZExtValue(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 DiagInfo->DiagHandler(Diag, DiagInfo->DiagContext, LocCookie); | 71 DiagInfo->DiagHandler(Diag, DiagInfo->DiagContext, LocCookie); |
| 72 } | 72 } |
| 73 | 73 |
| 74 /// EmitInlineAsm - Emit a blob of inline asm to the output streamer. | 74 /// EmitInlineAsm - Emit a blob of inline asm to the output streamer. |
| 75 void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, | 75 void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, |
| 76 InlineAsm::AsmDialect Dialect) const { | 76 InlineAsm::AsmDialect Dialect) const { |
| 77 #if defined(__native_client__) |
| 78 // Prune the generic AsmParser bits from the in-browser translator. |
| 79 // This is normally used to parse inline asm (see createMCAsmParser below). |
| 80 return; |
| 81 #else |
| 77 assert(!Str.empty() && "Can't emit empty inline asm block"); | 82 assert(!Str.empty() && "Can't emit empty inline asm block"); |
| 78 | 83 |
| 79 // Remember if the buffer is nul terminated or not so we can avoid a copy. | 84 // Remember if the buffer is nul terminated or not so we can avoid a copy. |
| 80 bool isNullTerminated = Str.back() == 0; | 85 bool isNullTerminated = Str.back() == 0; |
| 81 if (isNullTerminated) | 86 if (isNullTerminated) |
| 82 Str = Str.substr(0, Str.size()-1); | 87 Str = Str.substr(0, Str.size()-1); |
| 83 | 88 |
| 84 // If the output streamer does not have mature MC support or the integrated | 89 // If the output streamer does not have mature MC support or the integrated |
| 85 // assembler has been disabled, just emit the blob textually. | 90 // assembler has been disabled, just emit the blob textually. |
| 86 // Otherwise parse the asm and emit it via MC support. | 91 // Otherwise parse the asm and emit it via MC support. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); | 156 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); |
| 152 TAP->SetFrameRegister(TRI->getFrameRegister(*MF)); | 157 TAP->SetFrameRegister(TRI->getFrameRegister(*MF)); |
| 153 } | 158 } |
| 154 | 159 |
| 155 // Don't implicitly switch to the text section before the asm. | 160 // Don't implicitly switch to the text section before the asm. |
| 156 int Res = Parser->Run(/*NoInitialTextSection*/ true, | 161 int Res = Parser->Run(/*NoInitialTextSection*/ true, |
| 157 /*NoFinalize*/ true); | 162 /*NoFinalize*/ true); |
| 158 emitInlineAsmEnd(STIOrig, STI.get()); | 163 emitInlineAsmEnd(STIOrig, STI.get()); |
| 159 if (Res && !HasDiagHandler) | 164 if (Res && !HasDiagHandler) |
| 160 report_fatal_error("Error parsing inline asm\n"); | 165 report_fatal_error("Error parsing inline asm\n"); |
| 166 #endif // defined(__native_client__) |
| 161 } | 167 } |
| 162 | 168 |
| 163 static void EmitMSInlineAsmStr(const char *AsmStr, const MachineInstr *MI, | 169 static void EmitMSInlineAsmStr(const char *AsmStr, const MachineInstr *MI, |
| 164 MachineModuleInfo *MMI, int InlineAsmVariant, | 170 MachineModuleInfo *MMI, int InlineAsmVariant, |
| 165 AsmPrinter *AP, unsigned LocCookie, | 171 AsmPrinter *AP, unsigned LocCookie, |
| 166 raw_ostream &OS) { | 172 raw_ostream &OS) { |
| 167 // Switch to the inline assembly variant. | 173 // Switch to the inline assembly variant. |
| 168 OS << "\t.intel_syntax\n\t"; | 174 OS << "\t.intel_syntax\n\t"; |
| 169 | 175 |
| 170 const char *LastEmitted = AsmStr; // One past the last character emitted. | 176 const char *LastEmitted = AsmStr; // One past the last character emitted. |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 break; | 433 break; |
| 428 } | 434 } |
| 429 } | 435 } |
| 430 } | 436 } |
| 431 OS << '\n' << (char)0; // null terminate string. | 437 OS << '\n' << (char)0; // null terminate string. |
| 432 } | 438 } |
| 433 | 439 |
| 434 /// EmitInlineAsm - This method formats and emits the specified machine | 440 /// EmitInlineAsm - This method formats and emits the specified machine |
| 435 /// instruction that is an inline asm. | 441 /// instruction that is an inline asm. |
| 436 void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { | 442 void AsmPrinter::EmitInlineAsm(const MachineInstr *MI) const { |
| 443 #if defined(__native__client__) |
| 444 // See above LOCALMOD for pruning generic AsmParsing. |
| 445 return; |
| 446 #else |
| 437 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms"); | 447 assert(MI->isInlineAsm() && "printInlineAsm only works on inline asms"); |
| 438 | 448 |
| 439 // Count the number of register definitions to find the asm string. | 449 // Count the number of register definitions to find the asm string. |
| 440 unsigned NumDefs = 0; | 450 unsigned NumDefs = 0; |
| 441 for (; MI->getOperand(NumDefs).isReg() && MI->getOperand(NumDefs).isDef(); | 451 for (; MI->getOperand(NumDefs).isReg() && MI->getOperand(NumDefs).isDef(); |
| 442 ++NumDefs) | 452 ++NumDefs) |
| 443 assert(NumDefs != MI->getNumOperands()-2 && "No asm string?"); | 453 assert(NumDefs != MI->getNumOperands()-2 && "No asm string?"); |
| 444 | 454 |
| 445 assert(MI->getOperand(NumDefs).isSymbol() && "No asm string?"); | 455 assert(MI->getOperand(NumDefs).isSymbol() && "No asm string?"); |
| 446 | 456 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 EmitGCCInlineAsmStr(AsmStr, MI, MMI, InlineAsmVariant, AsmPrinterVariant, | 497 EmitGCCInlineAsmStr(AsmStr, MI, MMI, InlineAsmVariant, AsmPrinterVariant, |
| 488 AP, LocCookie, OS); | 498 AP, LocCookie, OS); |
| 489 else | 499 else |
| 490 EmitMSInlineAsmStr(AsmStr, MI, MMI, InlineAsmVariant, AP, LocCookie, OS); | 500 EmitMSInlineAsmStr(AsmStr, MI, MMI, InlineAsmVariant, AP, LocCookie, OS); |
| 491 | 501 |
| 492 EmitInlineAsm(OS.str(), LocMD, MI->getInlineAsmDialect()); | 502 EmitInlineAsm(OS.str(), LocMD, MI->getInlineAsmDialect()); |
| 493 | 503 |
| 494 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't | 504 // Emit the #NOAPP end marker. This has to happen even if verbose-asm isn't |
| 495 // enabled, so we use emitRawComment. | 505 // enabled, so we use emitRawComment. |
| 496 OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); | 506 OutStreamer.emitRawComment(MAI->getInlineAsmEnd()); |
| 507 #endif // __native_client__ |
| 497 } | 508 } |
| 498 | 509 |
| 499 | 510 |
| 500 /// PrintSpecial - Print information related to the specified machine instr | 511 /// PrintSpecial - Print information related to the specified machine instr |
| 501 /// that is independent of the operand, and may be independent of the instr | 512 /// that is independent of the operand, and may be independent of the instr |
| 502 /// itself. This can be useful for portably encoding the comment character | 513 /// itself. This can be useful for portably encoding the comment character |
| 503 /// or other bits of target-specific knowledge into the asmstrings. The | 514 /// or other bits of target-specific knowledge into the asmstrings. The |
| 504 /// syntax used is ${:comment}. Targets can override this to add support | 515 /// syntax used is ${:comment}. Targets can override this to add support |
| 505 /// for their own strange codes. | 516 /// for their own strange codes. |
| 506 void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS, | 517 void AsmPrinter::PrintSpecial(const MachineInstr *MI, raw_ostream &OS, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 | 572 |
| 562 bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, | 573 bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, |
| 563 unsigned AsmVariant, | 574 unsigned AsmVariant, |
| 564 const char *ExtraCode, raw_ostream &O) { | 575 const char *ExtraCode, raw_ostream &O) { |
| 565 // Target doesn't support this yet! | 576 // Target doesn't support this yet! |
| 566 return true; | 577 return true; |
| 567 } | 578 } |
| 568 | 579 |
| 569 void AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, | 580 void AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo, |
| 570 const MCSubtargetInfo *EndInfo) const {} | 581 const MCSubtargetInfo *EndInfo) const {} |
| OLD | NEW |