class MCInstrInfo;
class MCSection;
class MCStreamer;
+ class MCSubtargetInfo;
class MCSymbol;
class MDNode;
class DwarfDebug;
unsigned AsmVariant,
const char *ExtraCode, raw_ostream &OS);
+ /// Let the target do anything it needs to do after emitting inlineasm.
+ /// This callback can be used restore the original mode in case the
+ /// inlineasm contains directives to switch modes.
+ /// \p StartInfo - the original subtarget info before inline asm
+ /// \p EndInfo - the final subtarget info after parsing the inline asm,
+ /// or NULL if the value is unknown.
+ virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
+ MCSubtargetInfo *EndInfo) const;
+
private:
/// Private state for PrintSpecial()
// Assign a unique ID to this machine instruction.
// Allow a target to add behavior to the EmitLabel of MCStreamer.
virtual void emitLabel(MCSymbol *Symbol);
-
- /// Let the target do anything it needs to do after emitting inlineasm.
- /// This callback can be used restore the original mode in case the
- /// inlineasm contains directives to switch modes.
- /// \p StartInfo - the original subtarget info before inline asm
- /// \p EndInfo - the final subtarget info after parsing the inline asm,
- // or NULL if the value is unknown.
- virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
- MCSubtargetInfo *EndInfo) {}
};
// FIXME: declared here because it is used from
virtual void emitArch(unsigned Arch) = 0;
virtual void finishAttributeSection() = 0;
virtual void emitInst(uint32_t Inst, char Suffix = '\0') = 0;
- virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
- MCSubtargetInfo *EndInfo);
};
/// MCStreamer - Streaming machine code generation interface. This interface
/// indicated by the hasRawTextSupport() predicate. By default this aborts.
void EmitRawText(const Twine &String);
- /// EmitInlineAsmEnd - Used to perform any cleanup needed after emitting
- /// inline assembly. Provides the start and end subtarget info values.
- /// The end subtarget info may be NULL if it is not know, for example, when
- /// emitting the inline assembly as raw text.
- virtual void EmitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
- MCSubtargetInfo *EndInfo) {
- if (TargetStreamer)
- TargetStreamer->emitInlineAsmEnd(StartInfo, EndInfo);
- }
-
/// Flush - Causes any cached state to be written out.
virtual void Flush() {}
// system assembler does.
if (OutStreamer.hasRawTextSupport()) {
OutStreamer.EmitRawText(Str);
- OutStreamer.EmitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), 0);
+ emitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), 0);
return;
}
const_cast<MCSubtargetInfo*>(&TM.getSubtarget<MCSubtargetInfo>());
// Preserve a copy of the original STI because the parser may modify it.
- // The target can restore the original state in EmitInlineAsmEnd().
+ // The target can restore the original state in emitInlineAsmEnd().
MCSubtargetInfo STIOrig = *STI;
OwningPtr<MCTargetAsmParser>
// Don't implicitly switch to the text section before the asm.
int Res = Parser->Run(/*NoInitialTextSection*/ true,
/*NoFinalize*/ true);
- OutStreamer.EmitInlineAsmEnd(STIOrig, STI);
+ emitInlineAsmEnd(STIOrig, STI);
if (Res && !HasDiagHandler)
report_fatal_error("Error parsing inline asm\n");
}
return true;
}
+void AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
+ MCSubtargetInfo *EndInfo) const {}
return false;
}
+static bool isThumb(const MCSubtargetInfo& STI) {
+ return (STI.getFeatureBits() & ARM::ModeThumb) != 0;
+}
+
+void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
+ MCSubtargetInfo *EndInfo) const {
+ // If either end mode is unknown (EndInfo == NULL) or different than
+ // the start mode, then restore the start mode.
+ const bool WasThumb = isThumb(StartInfo);
+ if (EndInfo == NULL || WasThumb != isThumb(*EndInfo)) {
+ OutStreamer.EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
+ if (EndInfo)
+ EndInfo->ToggleFeature(ARM::ModeThumb);
+ }
+}
+
void ARMAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (Subtarget->isTargetMachO()) {
Reloc::Model RelocM = TM.getRelocationModel();
unsigned AsmVariant, const char *ExtraCode,
raw_ostream &O) LLVM_OVERRIDE;
+ virtual void emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
+ MCSubtargetInfo *EndInfo) const LLVM_OVERRIDE;
+
void EmitJumpTable(const MachineInstr *MI);
void EmitJump2Table(const MachineInstr *MI);
virtual void EmitInstruction(const MachineInstr *MI) LLVM_OVERRIDE;
return 0;
}
-static bool isThumb(const MCSubtargetInfo& STI) {
- return (STI.getFeatureBits() & ARM::ModeThumb) != 0;
-}
-
void ARMTargetStreamer::anchor() {}
-void ARMTargetStreamer::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
- MCSubtargetInfo *EndInfo) {
- // If either end mode is unknown (EndInfo == NULL) or different than
- // the start mode, then restore the start mode.
- const bool WasThumb = isThumb(StartInfo);
- if (EndInfo == NULL || WasThumb != isThumb(*EndInfo)) {
- assert(Streamer);
- Streamer->EmitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
- if (EndInfo)
- EndInfo->ToggleFeature(ARM::ModeThumb);
- }
-}
-
namespace {
class ARMELFStreamer;