diff options
author | David Peixotto <dpeixott@codeaurora.org> | 2014-02-04 17:22:40 +0000 |
---|---|---|
committer | David Peixotto <dpeixott@codeaurora.org> | 2014-02-04 17:22:40 +0000 |
commit | b92cca222898d87bbc764fa22e805adb04ef7f13 (patch) | |
tree | f094e401b602d87e38489c8cb984437ce983fb4f /include | |
parent | 7d9ed1cac54f5ed4274ae2735bd06e1017a83a9b (diff) | |
download | llvm-b92cca222898d87bbc764fa22e805adb04ef7f13.tar.gz llvm-b92cca222898d87bbc764fa22e805adb04ef7f13.tar.bz2 llvm-b92cca222898d87bbc764fa22e805adb04ef7f13.tar.xz |
Fix PR18345: ldr= pseudo instruction produces incorrect code when using in inline assembly
This patch fixes the ldr-pseudo implementation to work when used in
inline assembly. The fix is to move arm assembler constant pools
from the ARMAsmParser class to the ARMTargetStreamer class.
Previously we kept the assembler generated constant pools in the
ARMAsmParser object. This does not work for inline assembly because
a new parser object is created for each blob of inline assembly.
This patch moves the constant pools to the ARMTargetStreamer class
so that the constant pool will remain alive for the entire code
generation process.
An ARMTargetStreamer class is now required for the arm backend.
There was no existing implementation for MachO, only Asm and ELF.
Instead of creating an empty MachO subclass, we decided to make the
ARMTargetStreamer a non-abstract class and provide default
(llvm_unreachable) implementations for the non constant-pool related
methods.
Differential Revision: http://llvm-reviews.chandlerc.com/D2638
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/MC/MCStreamer.h | 63 | ||||
-rw-r--r-- | include/llvm/MC/MCTargetAsmParser.h | 5 |
2 files changed, 39 insertions, 29 deletions
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 3228aa7bb9..2a677c5678 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -39,6 +39,7 @@ class StringRef; class Twine; class raw_ostream; class formatted_raw_ostream; +class AssemblerConstantPools; typedef std::pair<const MCSection *, const MCExpr *> MCSectionSubPair; @@ -83,37 +84,51 @@ public: // FIXME: declared here because it is used from // lib/CodeGen/AsmPrinter/ARMException.cpp. class ARMTargetStreamer : public MCTargetStreamer { - virtual void anchor(); public: ARMTargetStreamer(MCStreamer &S); - - virtual void emitFnStart() = 0; - virtual void emitFnEnd() = 0; - virtual void emitCantUnwind() = 0; - virtual void emitPersonality(const MCSymbol *Personality) = 0; - virtual void emitPersonalityIndex(unsigned Index) = 0; - virtual void emitHandlerData() = 0; + ~ARMTargetStreamer(); + + virtual void emitFnStart(); + virtual void emitFnEnd(); + virtual void emitCantUnwind(); + virtual void emitPersonality(const MCSymbol *Personality); + virtual void emitPersonalityIndex(unsigned Index); + virtual void emitHandlerData(); virtual void emitSetFP(unsigned FpReg, unsigned SpReg, - int64_t Offset = 0) = 0; - virtual void emitMovSP(unsigned Reg, int64_t Offset = 0) = 0; - virtual void emitPad(int64_t Offset) = 0; + int64_t Offset = 0); + virtual void emitMovSP(unsigned Reg, int64_t Offset = 0); + virtual void emitPad(int64_t Offset); virtual void emitRegSave(const SmallVectorImpl<unsigned> &RegList, - bool isVector) = 0; + bool isVector); virtual void emitUnwindRaw(int64_t StackOffset, - const SmallVectorImpl<uint8_t> &Opcodes) = 0; + const SmallVectorImpl<uint8_t> &Opcodes); - virtual void switchVendor(StringRef Vendor) = 0; - virtual void emitAttribute(unsigned Attribute, unsigned Value) = 0; - virtual void emitTextAttribute(unsigned Attribute, StringRef String) = 0; + virtual void switchVendor(StringRef Vendor); + virtual void emitAttribute(unsigned Attribute, unsigned Value); + virtual void emitTextAttribute(unsigned Attribute, StringRef String); virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, - StringRef StringValue = "") = 0; - virtual void emitFPU(unsigned FPU) = 0; - virtual void emitArch(unsigned Arch) = 0; - virtual void emitObjectArch(unsigned Arch) = 0; - virtual void finishAttributeSection() = 0; - virtual void emitInst(uint32_t Inst, char Suffix = '\0') = 0; - - virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) = 0; + StringRef StringValue = ""); + virtual void emitFPU(unsigned FPU); + virtual void emitArch(unsigned Arch); + virtual void emitObjectArch(unsigned Arch); + virtual void finishAttributeSection(); + virtual void emitInst(uint32_t Inst, char Suffix = '\0'); + + virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE); + + virtual void finish(); + + /// Callback used to implement the ldr= pseudo. + /// Add a new entry to the constant pool for the current section and return an + /// MCExpr that can be used to refer to the constant pool location. + const MCExpr *addConstantPoolEntry(const MCExpr *); + + /// Callback used to implemnt the .ltorg directive. + /// Emit contents of constant pool for the current section. + void emitCurrentConstantPool(); + +private: + OwningPtr<AssemblerConstantPools> ConstantPools; }; /// MCStreamer - Streaming machine code generation interface. This interface diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index c5fb30ef99..0073136015 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -182,11 +182,6 @@ public: return 0; } - /// Allow a target to perform any actions after the parse completes - /// successfully. For example, to write out constant pools for ldr pseudo on - /// ARM. - virtual void finishParse() {}; - virtual void onLabelParsed(MCSymbol *Symbol) { }; }; |