diff options
Diffstat (limited to 'include/llvm/MC')
42 files changed, 231 insertions, 214 deletions
diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h index 2bfad2d355b8..07bba904788a 100644 --- a/include/llvm/MC/MCAsmBackend.h +++ b/include/llvm/MC/MCAsmBackend.h @@ -138,6 +138,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 9bb0fa63c523..f72959a5c5a0 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -39,7 +39,7 @@ enum class EncodingType { X86, /// Windows x86, uses no CFI, just EH tables MIPS = Alpha, }; -} +} // namespace WinEH enum class ExceptionHandling { None, /// No exception support @@ -555,6 +555,6 @@ public: bool shouldUseLogicalShr() const { return UseLogicalShr; } }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCAsmInfoCOFF.h b/include/llvm/MC/MCAsmInfoCOFF.h index 56444f3c7cf5..24f03e4c9bad 100644 --- a/include/llvm/MC/MCAsmInfoCOFF.h +++ b/include/llvm/MC/MCAsmInfoCOFF.h @@ -30,7 +30,7 @@ namespace llvm { protected: explicit MCAsmInfoGNUCOFF(); }; -} +} // namespace llvm #endif // LLVM_MC_MCASMINFOCOFF_H diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index a6178c214d47..0642af837e7e 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -49,7 +49,7 @@ class MCFragment : public ilist_node<MCFragment> { void operator=(const MCFragment &) = delete; public: - enum FragmentType { + enum FragmentType : uint8_t { FT_Align, FT_Data, FT_CompactEncodedInst, @@ -65,6 +65,18 @@ public: private: FragmentType Kind; +protected: + bool HasInstructions; + +private: + /// \brief Should this fragment be aligned to the end of a bundle? + bool AlignToBundleEnd; + + uint8_t BundlePadding; + + /// LayoutOrder - The layout order of this fragment. + unsigned LayoutOrder; + /// The data for the section this fragment is in. MCSection *Parent; @@ -81,18 +93,25 @@ private: /// initialized. uint64_t Offset; - /// LayoutOrder - The layout order of this fragment. - unsigned LayoutOrder; - /// @} protected: - MCFragment(FragmentType Kind, MCSection *Parent = nullptr); + MCFragment(FragmentType Kind, bool HasInstructions, + uint8_t BundlePadding, MCSection *Parent = nullptr); -public: - // Only for sentinel. + ~MCFragment(); +private: + + // This is a friend so that the sentinal can be created. + friend struct ilist_sentinel_traits<MCFragment>; MCFragment(); - virtual ~MCFragment(); + +public: + /// Destroys the current fragment. + /// + /// This must be used instead of delete as MCFragment is non-virtual. + /// This method will dispatch to the appropriate subclass. + void destroy(); FragmentType getKind() const { return Kind; } @@ -107,22 +126,22 @@ public: /// \brief Does this fragment have instructions emitted into it? By default /// this is false, but specific fragment types may set it to true. - virtual bool hasInstructions() const { return false; } + bool hasInstructions() const { return HasInstructions; } /// \brief Should this fragment be placed at the end of an aligned bundle? - virtual bool alignToBundleEnd() const { return false; } - virtual void setAlignToBundleEnd(bool V) {} + bool alignToBundleEnd() const { return AlignToBundleEnd; } + void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; } /// \brief Get the padding size that must be inserted before this fragment. /// Used for bundling. By default, no padding is inserted. /// Note that padding size is restricted to 8 bits. This is an optimization /// to reduce the amount of space used for each fragment. In practice, larger /// padding should never be required. - virtual uint8_t getBundlePadding() const { return 0; } + uint8_t getBundlePadding() const { return BundlePadding; } /// \brief Set the padding size for this fragment. By default it's a no-op, /// and only some fragments have a meaningful implementation. - virtual void setBundlePadding(uint8_t N) {} + void setBundlePadding(uint8_t N) { BundlePadding = N; } void dump(); }; @@ -131,22 +150,12 @@ public: /// data. /// class MCEncodedFragment : public MCFragment { - virtual void anchor(); - - uint8_t BundlePadding; +protected: + MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions, + MCSection *Sec) + : MCFragment(FType, HasInstructions, 0, Sec) {} public: - MCEncodedFragment(MCFragment::FragmentType FType, MCSection *Sec = nullptr) - : MCFragment(FType, Sec), BundlePadding(0) {} - ~MCEncodedFragment() override; - - virtual SmallVectorImpl<char> &getContents() = 0; - virtual const SmallVectorImpl<char> &getContents() const = 0; - - uint8_t getBundlePadding() const override { return BundlePadding; } - - void setBundlePadding(uint8_t N) override { BundlePadding = N; } - static bool classof(const MCFragment *F) { MCFragment::FragmentType Kind = F->getKind(); switch (Kind) { @@ -161,28 +170,52 @@ public: }; /// Interface implemented by fragments that contain encoded instructions and/or -/// data and also have fixups registered. +/// data. /// -class MCEncodedFragmentWithFixups : public MCEncodedFragment { - void anchor() override; +template<unsigned ContentsSize> +class MCEncodedFragmentWithContents : public MCEncodedFragment { + SmallVector<char, ContentsSize> Contents; + +protected: + MCEncodedFragmentWithContents(MCFragment::FragmentType FType, + bool HasInstructions, + MCSection *Sec) + : MCEncodedFragment(FType, HasInstructions, Sec) {} public: - MCEncodedFragmentWithFixups(MCFragment::FragmentType FType, - MCSection *Sec = nullptr) - : MCEncodedFragment(FType, Sec) {} + SmallVectorImpl<char> &getContents() { return Contents; } + const SmallVectorImpl<char> &getContents() const { return Contents; } +}; - ~MCEncodedFragmentWithFixups() override; +/// Interface implemented by fragments that contain encoded instructions and/or +/// data and also have fixups registered. +/// +template<unsigned ContentsSize, unsigned FixupsSize> +class MCEncodedFragmentWithFixups : + public MCEncodedFragmentWithContents<ContentsSize> { + /// Fixups - The list of fixups in this fragment. + SmallVector<MCFixup, FixupsSize> Fixups; + +protected: + MCEncodedFragmentWithFixups(MCFragment::FragmentType FType, + bool HasInstructions, + MCSection *Sec) + : MCEncodedFragmentWithContents<ContentsSize>(FType, HasInstructions, + Sec) {} + +public: typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator; typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator; - virtual SmallVectorImpl<MCFixup> &getFixups() = 0; - virtual const SmallVectorImpl<MCFixup> &getFixups() const = 0; + SmallVectorImpl<MCFixup> &getFixups() { return Fixups; } + const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; } - virtual fixup_iterator fixup_begin() = 0; - virtual const_fixup_iterator fixup_begin() const = 0; - virtual fixup_iterator fixup_end() = 0; - virtual const_fixup_iterator fixup_end() const = 0; + fixup_iterator fixup_begin() { return Fixups.begin(); } + const_fixup_iterator fixup_begin() const { return Fixups.begin(); } + + fixup_iterator fixup_end() { return Fixups.end(); } + const_fixup_iterator fixup_end() const { return Fixups.end(); } static bool classof(const MCFragment *F) { MCFragment::FragmentType Kind = F->getKind(); @@ -192,43 +225,12 @@ public: /// Fragment for data and encoded instructions. /// -class MCDataFragment : public MCEncodedFragmentWithFixups { - void anchor() override; - - /// \brief Does this fragment contain encoded instructions anywhere in it? - bool HasInstructions; - - /// \brief Should this fragment be aligned to the end of a bundle? - bool AlignToBundleEnd; - - SmallVector<char, 32> Contents; - - /// Fixups - The list of fixups in this fragment. - SmallVector<MCFixup, 4> Fixups; - +class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> { public: MCDataFragment(MCSection *Sec = nullptr) - : MCEncodedFragmentWithFixups(FT_Data, Sec), HasInstructions(false), - AlignToBundleEnd(false) {} - - SmallVectorImpl<char> &getContents() override { return Contents; } - const SmallVectorImpl<char> &getContents() const override { return Contents; } - - SmallVectorImpl<MCFixup> &getFixups() override { return Fixups; } - - const SmallVectorImpl<MCFixup> &getFixups() const override { return Fixups; } + : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false, Sec) {} - bool hasInstructions() const override { return HasInstructions; } - virtual void setHasInstructions(bool V) { HasInstructions = V; } - - bool alignToBundleEnd() const override { return AlignToBundleEnd; } - void setAlignToBundleEnd(bool V) override { AlignToBundleEnd = V; } - - fixup_iterator fixup_begin() override { return Fixups.begin(); } - const_fixup_iterator fixup_begin() const override { return Fixups.begin(); } - - fixup_iterator fixup_end() override { return Fixups.end(); } - const_fixup_iterator fixup_end() const override { return Fixups.end(); } + void setHasInstructions(bool V) { HasInstructions = V; } static bool classof(const MCFragment *F) { return F->getKind() == MCFragment::FT_Data; @@ -240,27 +242,12 @@ public: /// it can be used instead of MCDataFragment and lead to lower memory /// consumption. /// -class MCCompactEncodedInstFragment : public MCEncodedFragment { - void anchor() override; - - /// \brief Should this fragment be aligned to the end of a bundle? - bool AlignToBundleEnd; - - SmallVector<char, 4> Contents; - +class MCCompactEncodedInstFragment : public MCEncodedFragmentWithContents<4> { public: MCCompactEncodedInstFragment(MCSection *Sec = nullptr) - : MCEncodedFragment(FT_CompactEncodedInst, Sec), AlignToBundleEnd(false) { + : MCEncodedFragmentWithContents(FT_CompactEncodedInst, true, Sec) { } - bool hasInstructions() const override { return true; } - - SmallVectorImpl<char> &getContents() override { return Contents; } - const SmallVectorImpl<char> &getContents() const override { return Contents; } - - bool alignToBundleEnd() const override { return AlignToBundleEnd; } - void setAlignToBundleEnd(bool V) override { AlignToBundleEnd = V; } - static bool classof(const MCFragment *F) { return F->getKind() == MCFragment::FT_CompactEncodedInst; } @@ -269,8 +256,7 @@ public: /// A relaxable fragment holds on to its MCInst, since it may need to be /// relaxed during the assembler layout and relaxation stage. /// -class MCRelaxableFragment : public MCEncodedFragmentWithFixups { - void anchor() override; +class MCRelaxableFragment : public MCEncodedFragmentWithFixups<8, 1> { /// Inst - The instruction this is a fragment for. MCInst Inst; @@ -280,48 +266,32 @@ class MCRelaxableFragment : public MCEncodedFragmentWithFixups { /// in the assembler are not seen here. const MCSubtargetInfo STI; - /// Contents - Binary data for the currently encoded instruction. - SmallVector<char, 8> Contents; - - /// Fixups - The list of fixups in this fragment. - SmallVector<MCFixup, 1> Fixups; - public: MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI, MCSection *Sec = nullptr) - : MCEncodedFragmentWithFixups(FT_Relaxable, Sec), Inst(Inst), STI(STI) {} - - SmallVectorImpl<char> &getContents() override { return Contents; } - const SmallVectorImpl<char> &getContents() const override { return Contents; } + : MCEncodedFragmentWithFixups(FT_Relaxable, true, Sec), + Inst(Inst), STI(STI) {} const MCInst &getInst() const { return Inst; } void setInst(const MCInst &Value) { Inst = Value; } const MCSubtargetInfo &getSubtargetInfo() { return STI; } - SmallVectorImpl<MCFixup> &getFixups() override { return Fixups; } - - const SmallVectorImpl<MCFixup> &getFixups() const override { return Fixups; } - - bool hasInstructions() const override { return true; } - - fixup_iterator fixup_begin() override { return Fixups.begin(); } - const_fixup_iterator fixup_begin() const override { return Fixups.begin(); } - - fixup_iterator fixup_end() override { return Fixups.end(); } - const_fixup_iterator fixup_end() const override { return Fixups.end(); } - static bool classof(const MCFragment *F) { return F->getKind() == MCFragment::FT_Relaxable; } }; class MCAlignFragment : public MCFragment { - virtual void anchor(); /// Alignment - The alignment to ensure, in bytes. unsigned Alignment; + /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead + /// of using the provided value. The exact interpretation of this flag is + /// target dependent. + bool EmitNops : 1; + /// Value - Value to use for filling padding bytes. int64_t Value; @@ -332,16 +302,12 @@ class MCAlignFragment : public MCFragment { /// cannot be satisfied in this width then this fragment is ignored. unsigned MaxBytesToEmit; - /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead - /// of using the provided value. The exact interpretation of this flag is - /// target dependent. - bool EmitNops : 1; - public: MCAlignFragment(unsigned Alignment, int64_t Value, unsigned ValueSize, unsigned MaxBytesToEmit, MCSection *Sec = nullptr) - : MCFragment(FT_Align, Sec), Alignment(Alignment), Value(Value), - ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit), EmitNops(false) {} + : MCFragment(FT_Align, false, 0, Sec), Alignment(Alignment), + EmitNops(false), Value(Value), + ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {} /// \name Accessors /// @{ @@ -365,7 +331,6 @@ public: }; class MCFillFragment : public MCFragment { - virtual void anchor(); /// Value - Value to use for filling bytes. int64_t Value; @@ -380,7 +345,7 @@ class MCFillFragment : public MCFragment { public: MCFillFragment(int64_t Value, unsigned ValueSize, uint64_t Size, MCSection *Sec = nullptr) - : MCFragment(FT_Fill, Sec), Value(Value), ValueSize(ValueSize), + : MCFragment(FT_Fill, false, 0, Sec), Value(Value), ValueSize(ValueSize), Size(Size) { assert((!ValueSize || (Size % ValueSize) == 0) && "Fill size must be a multiple of the value size!"); @@ -403,7 +368,6 @@ public: }; class MCOrgFragment : public MCFragment { - virtual void anchor(); /// Offset - The offset this fragment should start at. const MCExpr *Offset; @@ -413,7 +377,7 @@ class MCOrgFragment : public MCFragment { public: MCOrgFragment(const MCExpr &Offset, int8_t Value, MCSection *Sec = nullptr) - : MCFragment(FT_Org, Sec), Offset(&Offset), Value(Value) {} + : MCFragment(FT_Org, false, 0, Sec), Offset(&Offset), Value(Value) {} /// \name Accessors /// @{ @@ -430,7 +394,6 @@ public: }; class MCLEBFragment : public MCFragment { - virtual void anchor(); /// Value - The value this fragment should contain. const MCExpr *Value; @@ -442,7 +405,7 @@ class MCLEBFragment : public MCFragment { public: MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSection *Sec = nullptr) - : MCFragment(FT_LEB, Sec), Value(&Value_), IsSigned(IsSigned_) { + : MCFragment(FT_LEB, false, 0, Sec), Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); } @@ -464,7 +427,6 @@ public: }; class MCDwarfLineAddrFragment : public MCFragment { - virtual void anchor(); /// LineDelta - the value of the difference between the two line numbers /// between two .loc dwarf directives. @@ -479,7 +441,8 @@ class MCDwarfLineAddrFragment : public MCFragment { public: MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta, MCSection *Sec = nullptr) - : MCFragment(FT_Dwarf, Sec), LineDelta(LineDelta), AddrDelta(&AddrDelta) { + : MCFragment(FT_Dwarf, false, 0, Sec), LineDelta(LineDelta), + AddrDelta(&AddrDelta) { Contents.push_back(0); } @@ -501,7 +464,6 @@ public: }; class MCDwarfCallFrameFragment : public MCFragment { - virtual void anchor(); /// AddrDelta - The expression for the difference of the two symbols that /// make up the address delta between two .cfi_* dwarf directives. @@ -511,7 +473,7 @@ class MCDwarfCallFrameFragment : public MCFragment { public: MCDwarfCallFrameFragment(const MCExpr &AddrDelta, MCSection *Sec = nullptr) - : MCFragment(FT_DwarfFrame, Sec), AddrDelta(&AddrDelta) { + : MCFragment(FT_DwarfFrame, false, 0, Sec), AddrDelta(&AddrDelta) { Contents.push_back(0); } @@ -531,13 +493,11 @@ public: }; class MCSafeSEHFragment : public MCFragment { - virtual void anchor(); - const MCSymbol *Sym; public: MCSafeSEHFragment(const MCSymbol *Sym, MCSection *Sec = nullptr) - : MCFragment(FT_SafeSEH, Sec), Sym(Sym) {} + : MCFragment(FT_SafeSEH, false, 0, Sec), Sym(Sym) {} /// \name Accessors /// @{ @@ -621,8 +581,6 @@ private: SymbolDataListType Symbols; - DenseSet<const MCSymbol *> LocalsUsedInReloc; - std::vector<IndirectSymbolData> IndirectSymbols; std::vector<DataRegionData> DataRegions; @@ -713,9 +671,6 @@ private: MCFragment &F, const MCFixup &Fixup); public: - void addLocalUsedInReloc(const MCSymbol &Sym); - bool isLocalUsedInReloc(const MCSymbol &Sym) const; - /// Compute the effective fragment size assuming it is laid out at the given /// \p SectionAddress and \p FragmentOffset. uint64_t computeFragmentSize(const MCAsmLayout &Layout, diff --git a/include/llvm/MC/MCCodeEmitter.h b/include/llvm/MC/MCCodeEmitter.h index b6c19150c12a..b4445d10c337 100644 --- a/include/llvm/MC/MCCodeEmitter.h +++ b/include/llvm/MC/MCCodeEmitter.h @@ -41,6 +41,6 @@ public: const MCSubtargetInfo &STI) const = 0; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 1790905a1245..52017fda189b 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -207,7 +207,7 @@ namespace llvm { bool AutoReset; MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name, - bool IsTemporary); + bool CanBeUnnamed); MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix, bool IsTemporary); @@ -249,9 +249,10 @@ namespace llvm { /// Create and return a new assembler temporary symbol with a unique but /// unspecified name. - MCSymbol *createTempSymbol(); + MCSymbol *createTempSymbol(bool CanBeUnnamed = true); - MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix); + MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix, + bool CanBeUnnamed = true); /// Create the definition of a directional local symbol for numbered label /// (used for "1:" definitions). diff --git a/include/llvm/MC/MCELFObjectWriter.h b/include/llvm/MC/MCELFObjectWriter.h index 01f694d3b756..855013a9cbbe 100644 --- a/include/llvm/MC/MCELFObjectWriter.h +++ b/include/llvm/MC/MCELFObjectWriter.h @@ -132,6 +132,6 @@ public: MCObjectWriter *createELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 241db0dc9cde..a5b257f5958b 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -93,7 +93,7 @@ private: void fixSymbolsInTLSFixups(const MCExpr *expr); /// \brief Merge the content of the fragment \p EF into the fragment \p DF. - void mergeFragment(MCDataFragment *, MCEncodedFragmentWithFixups *); + void mergeFragment(MCDataFragment *, MCDataFragment *); bool SeenIdent; diff --git a/include/llvm/MC/MCExternalSymbolizer.h b/include/llvm/MC/MCExternalSymbolizer.h index 2c7d23707c95..a88b32e215e8 100644 --- a/include/llvm/MC/MCExternalSymbolizer.h +++ b/include/llvm/MC/MCExternalSymbolizer.h @@ -53,6 +53,6 @@ public: uint64_t Address) override; }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCFixedLenDisassembler.h b/include/llvm/MC/MCFixedLenDisassembler.h index ad99943df2c3..9fbdf9c22fba 100644 --- a/include/llvm/MC/MCFixedLenDisassembler.h +++ b/include/llvm/MC/MCFixedLenDisassembler.h @@ -26,7 +26,7 @@ enum DecoderOps { OPC_Fail // OPC_Fail() }; -} // namespace MCDecode +} // namespace MCD } // namespace llvm #endif diff --git a/include/llvm/MC/MCFixup.h b/include/llvm/MC/MCFixup.h index 8ab477c401a1..c09f55a8ffc4 100644 --- a/include/llvm/MC/MCFixup.h +++ b/include/llvm/MC/MCFixup.h @@ -108,6 +108,6 @@ public: SMLoc getLoc() const { return Loc; } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCFixupKindInfo.h b/include/llvm/MC/MCFixupKindInfo.h index 58183bd778e6..b779781f49bd 100644 --- a/include/llvm/MC/MCFixupKindInfo.h +++ b/include/llvm/MC/MCFixupKindInfo.h @@ -38,6 +38,6 @@ struct MCFixupKindInfo { unsigned Flags; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCInstrAnalysis.h b/include/llvm/MC/MCInstrAnalysis.h index 8f5159e9e1c8..a0a68106bc80 100644 --- a/include/llvm/MC/MCInstrAnalysis.h +++ b/include/llvm/MC/MCInstrAnalysis.h @@ -66,6 +66,6 @@ public: uint64_t &Target) const; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCInstrDesc.h b/include/llvm/MC/MCInstrDesc.h index 3209a2ce0408..fe67e4407672 100644 --- a/include/llvm/MC/MCInstrDesc.h +++ b/include/llvm/MC/MCInstrDesc.h @@ -49,7 +49,7 @@ enum OperandType { OPERAND_PCREL = 4, OPERAND_FIRST_TARGET = 5 }; -} +} // namespace MCOI /// \brief This holds information about one operand of a machine instruction, /// indicating the register class for register operands, etc. @@ -128,7 +128,7 @@ enum Flag { InsertSubreg, Convergent }; -} +} // namespace MCID /// \brief Describe properties that are true of each instruction in the target /// description file. This captures information about side effects, register diff --git a/include/llvm/MC/MCInstrInfo.h b/include/llvm/MC/MCInstrInfo.h index 70c86587b08c..d75c4cad1f1a 100644 --- a/include/llvm/MC/MCInstrInfo.h +++ b/include/llvm/MC/MCInstrInfo.h @@ -54,6 +54,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCInstrItineraries.h b/include/llvm/MC/MCInstrItineraries.h index 161705de7c4e..a58bd7b4d396 100644 --- a/include/llvm/MC/MCInstrItineraries.h +++ b/include/llvm/MC/MCInstrItineraries.h @@ -234,6 +234,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h index 175d73e72c10..10b7905a82de 100644 --- a/include/llvm/MC/MCMachObjectWriter.h +++ b/include/llvm/MC/MCMachObjectWriter.h @@ -264,6 +264,6 @@ MCObjectWriter *createMachObjectWriter(MCMachObjectTargetWriter *MOTW, raw_pwrite_stream &OS, bool IsLittleEndian); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h index 0515f1cd738d..99e3f92bfe26 100644 --- a/include/llvm/MC/MCObjectFileInfo.h +++ b/include/llvm/MC/MCObjectFileInfo.h @@ -20,7 +20,6 @@ namespace llvm { class MCContext; class MCSection; -class StringRef; class MCObjectFileInfo { protected: @@ -139,6 +138,9 @@ protected: /// StackMap section. MCSection *StackMapSection; + /// FaultMap section. + MCSection *FaultMapSection; + /// EH frame section. /// /// It is initialized on demand so it can be overwritten (with uniquing). @@ -185,8 +187,12 @@ protected: MCSection *SXDataSection; public: - void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM, - MCContext &ctx); + void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM, + CodeModel::Model CM, MCContext &ctx); + LLVM_ATTRIBUTE_DEPRECATED( + void InitMCObjectFileInfo(StringRef TT, Reloc::Model RM, + CodeModel::Model CM, MCContext &ctx), + "StringRef GNU Triple argument replaced by a llvm::Triple object"); bool getSupportsWeakOmittedEHFrame() const { return SupportsWeakOmittedEHFrame; @@ -262,6 +268,7 @@ public: MCSection *getTLSBSSSection() const { return TLSBSSSection; } MCSection *getStackMapSection() const { return StackMapSection; } + MCSection *getFaultMapSection() const { return FaultMapSection; } // ELF specific sections. MCSection *getDataRelSection() const { return DataRelSection; } diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index 462b3b484c58..ce1fc80f2cf2 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -135,8 +135,7 @@ public: /// data fragment. Otherwise, do nothing and return \c false. /// /// \pre Offset of \c Hi is greater than the offset \c Lo. - /// \return true on success. - bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, + void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, unsigned Size) override; bool mayHaveInstructions(MCSection &Sec) const override; diff --git a/include/llvm/MC/MCObjectWriter.h b/include/llvm/MC/MCObjectWriter.h index 2211673efc31..ca7fba547dc3 100644 --- a/include/llvm/MC/MCObjectWriter.h +++ b/include/llvm/MC/MCObjectWriter.h @@ -188,6 +188,6 @@ public: /// @} }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h index 71f15b37c331..0bf8aa6d899a 100644 --- a/include/llvm/MC/MCParser/MCAsmLexer.h +++ b/include/llvm/MC/MCParser/MCAsmLexer.h @@ -190,6 +190,6 @@ public: void setAllowAtInIdentifier(bool v) { AllowAtInIdentifier = v; } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index 0538b9457f9e..c840958fa91e 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -203,6 +203,6 @@ public: MCAsmParser *createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, const MCAsmInfo &); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h index 077fd21e073c..46f716e68e67 100644 --- a/include/llvm/MC/MCParser/MCAsmParserExtension.h +++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h @@ -84,6 +84,6 @@ public: /// @} }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCRegisterInfo.h b/include/llvm/MC/MCRegisterInfo.h index 8e25ee18e08d..7a41abcbf728 100644 --- a/include/llvm/MC/MCRegisterInfo.h +++ b/include/llvm/MC/MCRegisterInfo.h @@ -686,6 +686,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCRelocationInfo.h b/include/llvm/MC/MCRelocationInfo.h index 40e0217b8d83..8fc5c9f53a46 100644 --- a/include/llvm/MC/MCRelocationInfo.h +++ b/include/llvm/MC/MCRelocationInfo.h @@ -50,6 +50,6 @@ public: unsigned VariantKind); }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSchedule.h b/include/llvm/MC/MCSchedule.h index 1adfedd2638a..635eab99be6a 100644 --- a/include/llvm/MC/MCSchedule.h +++ b/include/llvm/MC/MCSchedule.h @@ -245,6 +245,6 @@ struct MCSchedModel { } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSection.h b/include/llvm/MC/MCSection.h index 5f6e8ec1d506..2d0d4dfc5913 100644 --- a/include/llvm/MC/MCSection.h +++ b/include/llvm/MC/MCSection.h @@ -31,6 +31,18 @@ class MCSection; class MCSymbol; class raw_ostream; +template<> +struct ilist_node_traits<MCFragment> { + MCFragment *createNode(const MCFragment &V); + static void deleteNode(MCFragment *V); + + void addNodeToList(MCFragment *) {} + void removeNodeFromList(MCFragment *) {} + void transferNodesFromList(ilist_node_traits & /*SrcTraits*/, + ilist_iterator<MCFragment> /*first*/, + ilist_iterator<MCFragment> /*last*/) {} +}; + /// Instances of this class represent a uniqued identifier for a section in the /// current translation unit. The MCContext class uniques and creates these. class MCSection { diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 628fb768856e..50d8d314ef4e 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -85,6 +85,9 @@ public: // Allow a target to add behavior to the emitAssignment of MCStreamer. virtual void emitAssignment(MCSymbol *Symbol, const MCExpr *Value); + virtual void prettyPrintAsm(MCInstPrinter &InstPrinter, raw_ostream &OS, + const MCInst &Inst, const MCSubtargetInfo &STI); + virtual void finish(); }; @@ -636,14 +639,11 @@ public: unsigned Isa, unsigned Discriminator, StringRef FileName); - /// Emit the absolute difference between two symbols if possible. + /// Emit the absolute difference between two symbols. /// /// \pre Offset of \c Hi is greater than the offset \c Lo. - /// \return true on success. - virtual bool emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, - unsigned Size) { - return false; - } + virtual void emitAbsoluteSymbolDiff(const MCSymbol *Hi, const MCSymbol *Lo, + unsigned Size); virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID); virtual void EmitCFISections(bool EH, bool Debug); diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h index ee5d56334a2f..0a23306fa694 100644 --- a/include/llvm/MC/MCSubtargetInfo.h +++ b/include/llvm/MC/MCSubtargetInfo.h @@ -27,7 +27,7 @@ class StringRef; /// MCSubtargetInfo - Generic base class for all target subtargets. /// class MCSubtargetInfo { - std::string TargetTriple; // Target triple + Triple TargetTriple; // Target triple std::string CPU; // CPU being targeted. ArrayRef<SubtargetFeatureKV> ProcFeatures; // Processor feature list ArrayRef<SubtargetFeatureKV> ProcDesc; // Processor descriptions @@ -45,20 +45,17 @@ class MCSubtargetInfo { FeatureBitset FeatureBits; // Feature bits for current CPU + FS public: - void InitMCSubtargetInfo(StringRef TT, StringRef CPU, StringRef FS, + void InitMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS, ArrayRef<SubtargetFeatureKV> PF, ArrayRef<SubtargetFeatureKV> PD, const SubtargetInfoKV *ProcSched, const MCWriteProcResEntry *WPR, const MCWriteLatencyEntry *WL, - const MCReadAdvanceEntry *RA, - const InstrStage *IS, + const MCReadAdvanceEntry *RA, const InstrStage *IS, const unsigned *OC, const unsigned *FP); /// getTargetTriple - Return the target triple string. - StringRef getTargetTriple() const { - return TargetTriple; - } + const Triple &getTargetTriple() const { return TargetTriple; } /// getCPU - Return the CPU string. StringRef getCPU() const { @@ -163,6 +160,6 @@ public: } }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSymbol.h b/include/llvm/MC/MCSymbol.h index 078f3d77e55c..0acf6e50ba48 100644 --- a/include/llvm/MC/MCSymbol.h +++ b/include/llvm/MC/MCSymbol.h @@ -17,7 +17,6 @@ #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/StringMap.h" #include "llvm/MC/MCAssembler.h" -#include "llvm/MC/MCExpr.h" #include "llvm/Support/Compiler.h" namespace llvm { @@ -52,10 +51,6 @@ protected: // FIXME: Use a PointerInt wrapper for this? static MCSection *AbsolutePseudoSection; - /// Name - The name of the symbol. The referred-to string data is actually - /// held by the StringMap that lives in MCContext. - const StringMapEntry<bool> *Name; - /// If a symbol has a Fragment, the section is implied, so we only need /// one pointer. /// FIXME: We might be able to simplify this by having the asm streamer create @@ -91,10 +86,18 @@ protected: /// This symbol is private extern. mutable unsigned IsPrivateExtern : 1; + /// True if this symbol is named. + /// A named symbol will have a pointer to the name allocated in the bytes + /// immediately prior to the MCSymbol. + unsigned HasName : 1; + /// LLVM RTTI discriminator. This is actually a SymbolKind enumerator, but is /// unsigned to avoid sign extension and achieve better bitpacking with MSVC. unsigned Kind : 2; + /// True if we have created a relocation that uses this symbol. + mutable unsigned IsUsedInReloc : 1; + /// Index field, for use by the object file implementation. mutable uint32_t Index = 0; @@ -118,15 +121,43 @@ protected: protected: // MCContext creates and uniques these. friend class MCExpr; friend class MCContext; + + /// \brief The name for a symbol. + /// MCSymbol contains a uint64_t so is probably aligned to 8. On a 32-bit + /// system, the name is a pointer so isn't going to satisfy the 8 byte + /// alignment of uint64_t. Account for that here. + typedef union { + const StringMapEntry<bool> *NameEntry; + uint64_t AlignmentPadding; + } NameEntryStorageTy; + MCSymbol(SymbolKind Kind, const StringMapEntry<bool> *Name, bool isTemporary) - : Name(Name), Value(nullptr), IsTemporary(isTemporary), - IsRedefinable(false), IsUsed(false), IsRegistered(false), - IsExternal(false), IsPrivateExtern(false), - Kind(Kind) { + : Value(nullptr), IsTemporary(isTemporary), IsRedefinable(false), + IsUsed(false), IsRegistered(false), IsExternal(false), + IsPrivateExtern(false), HasName(!!Name), Kind(Kind), + IsUsedInReloc(false) { Offset = 0; + if (Name) + getNameEntryPtr() = Name; } + // Provide custom new/delete as we will only allocate space for a name + // if we need one. + void *operator new(size_t s, const StringMapEntry<bool> *Name, + MCContext &Ctx); + private: + + void operator delete(void *); + /// \brief Placement delete - required by std, but never called. + void operator delete(void*, unsigned) { + llvm_unreachable("Constructor throws?"); + } + /// \brief Placement delete - required by std, but never called. + void operator delete(void*, unsigned, bool) { + llvm_unreachable("Constructor throws?"); + } + MCSymbol(const MCSymbol &) = delete; void operator=(const MCSymbol &) = delete; MCSection *getSectionPtr() const { @@ -139,13 +170,31 @@ private: return Section = Value->findAssociatedSection(); } + /// \brief Get a reference to the name field. Requires that we have a name + const StringMapEntry<bool> *&getNameEntryPtr() { + assert(HasName && "Name is required"); + NameEntryStorageTy *Name = reinterpret_cast<NameEntryStorageTy *>(this); + return (*(Name - 1)).NameEntry; + } + const StringMapEntry<bool> *&getNameEntryPtr() const { + return const_cast<MCSymbol*>(this)->getNameEntryPtr(); + } + public: /// getName - Get the symbol name. - StringRef getName() const { return Name ? Name->first() : ""; } + StringRef getName() const { + if (!HasName) + return StringRef(); + + return getNameEntryPtr()->first(); + } bool isRegistered() const { return IsRegistered; } void setIsRegistered(bool Value) const { IsRegistered = Value; } + void setUsedInReloc() const { IsUsedInReloc = true; } + bool isUsedInReloc() const { return IsUsedInReloc; } + /// \name Accessors /// @{ diff --git a/include/llvm/MC/MCSymbolCOFF.h b/include/llvm/MC/MCSymbolCOFF.h index 2172c67981c0..3b853f788c8d 100644 --- a/include/llvm/MC/MCSymbolCOFF.h +++ b/include/llvm/MC/MCSymbolCOFF.h @@ -59,6 +59,6 @@ public: static bool classof(const MCSymbol *S) { return S->isCOFF(); } }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSymbolELF.h b/include/llvm/MC/MCSymbolELF.h index 0cc11156b5cd..b0ce3fe158c4 100644 --- a/include/llvm/MC/MCSymbolELF.h +++ b/include/llvm/MC/MCSymbolELF.h @@ -38,9 +38,6 @@ public: bool isBindingSet() const; - void setUsedInReloc() const; - bool isUsedInReloc() const; - void setIsWeakrefUsedInReloc() const; bool isWeakrefUsedInReloc() const; @@ -52,6 +49,6 @@ public: private: void setIsBindingSet() const; }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSymbolMachO.h b/include/llvm/MC/MCSymbolMachO.h index 166ae9e755a1..a16208088b99 100644 --- a/include/llvm/MC/MCSymbolMachO.h +++ b/include/llvm/MC/MCSymbolMachO.h @@ -118,6 +118,6 @@ public: static bool classof(const MCSymbol *S) { return S->isMachO(); } }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCSymbolizer.h b/include/llvm/MC/MCSymbolizer.h index 2ef17673f091..41c1b0d897f9 100644 --- a/include/llvm/MC/MCSymbolizer.h +++ b/include/llvm/MC/MCSymbolizer.h @@ -80,6 +80,6 @@ public: uint64_t Address) = 0; }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index 36db3914f017..4ee53adee599 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -201,6 +201,6 @@ public: virtual void onLabelParsed(MCSymbol *Symbol) { }; }; -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCWin64EH.h b/include/llvm/MC/MCWin64EH.h index 0e81a191cd2c..f2211d73f60a 100644 --- a/include/llvm/MC/MCWin64EH.h +++ b/include/llvm/MC/MCWin64EH.h @@ -57,7 +57,7 @@ public: void Emit(MCStreamer &Streamer) const override; void EmitUnwindInfo(MCStreamer &Streamer, WinEH::FrameInfo *FI) const override; }; -} +} // namespace Win64EH } // end namespace llvm #endif diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h index e2e95c7df710..edf87f5f9cf9 100644 --- a/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -42,6 +42,6 @@ class raw_pwrite_stream; /// \returns The constructed object writer. MCObjectWriter *createWinCOFFObjectWriter(MCWinCOFFObjectTargetWriter *MOTW, raw_pwrite_stream &OS); -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/MCWinCOFFStreamer.h b/include/llvm/MC/MCWinCOFFStreamer.h index 6fbc754f1125..fcca838bbf17 100644 --- a/include/llvm/MC/MCWinCOFFStreamer.h +++ b/include/llvm/MC/MCWinCOFFStreamer.h @@ -75,7 +75,7 @@ protected: private: LLVM_ATTRIBUTE_NORETURN void FatalError(const Twine &Msg) const; }; -} +} // namespace llvm #endif diff --git a/include/llvm/MC/MCWinEH.h b/include/llvm/MC/MCWinEH.h index 723d7a397c49..d22791e239d5 100644 --- a/include/llvm/MC/MCWinEH.h +++ b/include/llvm/MC/MCWinEH.h @@ -78,7 +78,7 @@ public: virtual void Emit(MCStreamer &Streamer) const = 0; virtual void EmitUnwindInfo(MCStreamer &Streamer, FrameInfo *FI) const = 0; }; -} -} +} // namespace WinEH +} // namespace llvm #endif diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h index 2a18615eff62..1c421821ce9d 100644 --- a/include/llvm/MC/MachineLocation.h +++ b/include/llvm/MC/MachineLocation.h @@ -78,6 +78,6 @@ inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) { return !(LHS == RHS); } -} // End llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/StringTableBuilder.h b/include/llvm/MC/StringTableBuilder.h index 897d449254ea..700a8a6e340d 100644 --- a/include/llvm/MC/StringTableBuilder.h +++ b/include/llvm/MC/StringTableBuilder.h @@ -62,6 +62,6 @@ private: } }; -} // end llvm namespace +} // namespace llvm #endif diff --git a/include/llvm/MC/YAML.h b/include/llvm/MC/YAML.h index 383cdc6785fa..ae8329829a59 100644 --- a/include/llvm/MC/YAML.h +++ b/include/llvm/MC/YAML.h @@ -89,6 +89,6 @@ template <> struct ScalarTraits<BinaryRef> { static StringRef input(StringRef, void *, BinaryRef &); static bool mustQuote(StringRef S) { return needsQuotes(S); } }; -} -} +} // namespace yaml +} // namespace llvm #endif |