mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-29 22:52:18 +00:00
Move emitInlineAsmEnd to the AsmPrinter interface.
There is no inline asm in a .s file. Therefore, there should be no logic to handle it in the streamer. Inline asm only exists in bitcode files, so the logic can live in the (long misnamed) AsmPrinter class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200011 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
98fd6f18aa
commit
b0d78d0192
@ -45,6 +45,7 @@ namespace llvm {
|
||||
class MCInstrInfo;
|
||||
class MCSection;
|
||||
class MCStreamer;
|
||||
class MCSubtargetInfo;
|
||||
class MCSymbol;
|
||||
class MDNode;
|
||||
class DwarfDebug;
|
||||
@ -461,6 +462,15 @@ namespace llvm {
|
||||
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.
|
||||
|
@ -75,15 +75,6 @@ public:
|
||||
|
||||
// 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
|
||||
@ -114,8 +105,6 @@ public:
|
||||
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
|
||||
@ -689,16 +678,6 @@ public:
|
||||
/// 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() {}
|
||||
|
||||
|
@ -84,7 +84,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
|
||||
// system assembler does.
|
||||
if (OutStreamer.hasRawTextSupport()) {
|
||||
OutStreamer.EmitRawText(Str);
|
||||
OutStreamer.EmitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), 0);
|
||||
emitInlineAsmEnd(TM.getSubtarget<MCSubtargetInfo>(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
|
||||
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>
|
||||
@ -138,7 +138,7 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode,
|
||||
// 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");
|
||||
}
|
||||
@ -549,3 +549,5 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
|
||||
MCSubtargetInfo *EndInfo) const {}
|
||||
|
@ -438,6 +438,22 @@ bool ARMAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
|
||||
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();
|
||||
|
@ -63,6 +63,9 @@ public:
|
||||
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;
|
||||
|
@ -104,25 +104,8 @@ static unsigned GetArchDefaultCPUArch(unsigned ID) {
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user