[llvm] 04395be - MC: Merge MCFragment.h into MCSection.h
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 30 09:41:57 PDT 2025
Author: Fangrui Song
Date: 2025-06-30T09:41:53-07:00
New Revision: 04395be630781451682060548ea8b94abec2947e
URL: https://github.com/llvm/llvm-project/commit/04395be630781451682060548ea8b94abec2947e
DIFF: https://github.com/llvm/llvm-project/commit/04395be630781451682060548ea8b94abec2947e.diff
LOG: MC: Merge MCFragment.h into MCSection.h
... due to their close relationship. MCSection's inline functions (e.g.
iterator) access MCFragment, and we want MCFragment's inline functions
to access MCSection similarly (#146307).
Pull Request: https://github.com/llvm/llvm-project/pull/146315
Added:
Modified:
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/include/llvm/MC/MCSection.h
llvm/include/llvm/MC/MCStreamer.h
llvm/include/llvm/MC/MCSymbol.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCContext.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCFragment.cpp
llvm/lib/MC/MCMachOStreamer.cpp
llvm/lib/MC/MCObjectWriter.cpp
llvm/lib/MC/MCPseudoProbe.cpp
llvm/lib/MC/MCSection.cpp
llvm/lib/MC/MCSymbol.cpp
llvm/lib/MC/MCWasmStreamer.cpp
llvm/lib/MC/MCWinCOFFStreamer.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
Removed:
llvm/include/llvm/MC/MCFragment.h
################################################################################
diff --git a/llvm/include/llvm/MC/MCFragment.h b/llvm/include/llvm/MC/MCFragment.h
deleted file mode 100644
index 7bb090d0c57a1..0000000000000
--- a/llvm/include/llvm/MC/MCFragment.h
+++ /dev/null
@@ -1,577 +0,0 @@
-//===- MCFragment.h - Fragment type hierarchy -------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_MC_MCFRAGMENT_H
-#define LLVM_MC_MCFRAGMENT_H
-
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/SmallString.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/ilist_node.h"
-#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCInst.h"
-#include "llvm/Support/Alignment.h"
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/SMLoc.h"
-#include <cstdint>
-#include <utility>
-
-namespace llvm {
-
-class MCAssembler;
-class MCObjectStreamer;
-class MCSection;
-class MCSubtargetInfo;
-class MCSymbol;
-
-class MCFragment {
- friend class MCAssembler;
- friend class MCObjectStreamer;
- friend class MCSection;
-
-public:
- enum FragmentType : uint8_t {
- FT_Align,
- FT_Data,
- FT_Fill,
- FT_Nops,
- FT_Relaxable,
- FT_Org,
- FT_Dwarf,
- FT_DwarfFrame,
- FT_LEB,
- FT_BoundaryAlign,
- FT_SymbolId,
- FT_CVInlineLines,
- FT_CVDefRange,
- FT_PseudoProbe,
- };
-
-private:
- // The next fragment within the section.
- MCFragment *Next = nullptr;
-
- /// The data for the section this fragment is in.
- MCSection *Parent = nullptr;
-
- /// The offset of this fragment in its section.
- uint64_t Offset = 0;
-
- /// The layout order of this fragment.
- unsigned LayoutOrder = 0;
-
- FragmentType Kind;
-
-protected:
- /// Used by subclasses for better packing.
- ///
- /// MCEncodedFragment
- bool HasInstructions : 1;
- bool AlignToBundleEnd : 1;
- /// MCDataFragment
- bool LinkerRelaxable : 1;
- /// MCRelaxableFragment: x86-specific
- bool AllowAutoPadding : 1;
-
- LLVM_ABI MCFragment(FragmentType Kind, bool HasInstructions);
-
-public:
- MCFragment() = delete;
- MCFragment(const MCFragment &) = delete;
- MCFragment &operator=(const MCFragment &) = delete;
-
- /// Destroys the current fragment.
- ///
- /// This must be used instead of delete as MCFragment is non-virtual.
- /// This method will dispatch to the appropriate subclass.
- LLVM_ABI void destroy();
-
- MCFragment *getNext() const { return Next; }
-
- FragmentType getKind() const { return Kind; }
-
- MCSection *getParent() const { return Parent; }
- void setParent(MCSection *Value) { Parent = Value; }
-
- LLVM_ABI const MCSymbol *getAtom() const;
-
- unsigned getLayoutOrder() const { return LayoutOrder; }
- void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
-
- /// Does this fragment have instructions emitted into it? By default
- /// this is false, but specific fragment types may set it to true.
- bool hasInstructions() const { return HasInstructions; }
-
- LLVM_ABI void dump() const;
-};
-
-/// Interface implemented by fragments that contain encoded instructions and/or
-/// data.
-///
-class MCEncodedFragment : public MCFragment {
- uint8_t BundlePadding = 0;
-
-protected:
- MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions)
- : MCFragment(FType, HasInstructions) {}
-
- /// The MCSubtargetInfo in effect when the instruction was encoded.
- /// It must be non-null for instructions.
- const MCSubtargetInfo *STI = nullptr;
-
-public:
- static bool classof(const MCFragment *F) {
- MCFragment::FragmentType Kind = F->getKind();
- switch (Kind) {
- default:
- return false;
- case MCFragment::FT_Relaxable:
- case MCFragment::FT_Data:
- case MCFragment::FT_Dwarf:
- case MCFragment::FT_DwarfFrame:
- case MCFragment::FT_PseudoProbe:
- return true;
- }
- }
-
- /// Should this fragment be placed at the end of an aligned bundle?
- bool alignToBundleEnd() const { return AlignToBundleEnd; }
- void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
-
- /// 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.
- uint8_t getBundlePadding() const { return BundlePadding; }
-
- /// Set the padding size for this fragment. By default it's a no-op,
- /// and only some fragments have a meaningful implementation.
- void setBundlePadding(uint8_t N) { BundlePadding = N; }
-
- /// Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
- /// Guaranteed to be non-null if hasInstructions() == true
- const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
-
- /// Record that the fragment contains instructions with the MCSubtargetInfo in
- /// effect when the instruction was encoded.
- void setHasInstructions(const MCSubtargetInfo &STI) {
- HasInstructions = true;
- this->STI = &STI;
- }
-};
-
-/// Interface implemented by fragments that contain encoded instructions and/or
-/// data and also have fixups registered.
-///
-template <unsigned ContentsSize, unsigned FixupsSize>
-class MCEncodedFragmentWithFixups : public MCEncodedFragment {
- SmallVector<char, ContentsSize> Contents;
-
- /// The list of fixups in this fragment.
- SmallVector<MCFixup, FixupsSize> Fixups;
-
-protected:
- MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
- bool HasInstructions)
- : MCEncodedFragment(FType, HasInstructions) {}
-
-public:
- SmallVectorImpl<char> &getContents() { return Contents; }
- const SmallVectorImpl<char> &getContents() const { return Contents; }
-
- void appendContents(ArrayRef<char> C) { Contents.append(C.begin(), C.end()); }
- void appendContents(size_t Num, char Elt) { Contents.append(Num, Elt); }
- void setContents(ArrayRef<char> C) { Contents.assign(C.begin(), C.end()); }
-
- void addFixup(MCFixup Fixup) { Fixups.push_back(Fixup); }
- SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
- const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
-
- static bool classof(const MCFragment *F) {
- MCFragment::FragmentType Kind = F->getKind();
- return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data ||
- Kind == MCFragment::FT_CVDefRange || Kind == MCFragment::FT_Dwarf ||
- Kind == MCFragment::FT_DwarfFrame;
- }
-};
-
-/// Fragment for data and encoded instructions.
-///
-class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
-public:
- MCDataFragment() : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false) {}
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Data;
- }
-
- bool isLinkerRelaxable() const { return LinkerRelaxable; }
- void setLinkerRelaxable() { LinkerRelaxable = true; }
-};
-
-/// 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<8, 1> {
- /// The instruction this is a fragment for.
- MCInst Inst;
-
-public:
- MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI)
- : MCEncodedFragmentWithFixups(FT_Relaxable, true), Inst(Inst) {
- this->STI = &STI;
- }
-
- const MCInst &getInst() const { return Inst; }
- void setInst(const MCInst &Value) { Inst = Value; }
-
- bool getAllowAutoPadding() const { return AllowAutoPadding; }
- void setAllowAutoPadding(bool V) { AllowAutoPadding = V; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Relaxable;
- }
-};
-
-class MCAlignFragment : public MCFragment {
- /// The alignment to ensure, in bytes.
- Align Alignment;
-
- /// 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 to use for filling padding bytes.
- int64_t Value;
-
- /// The size of the integer (in bytes) of \p Value.
- unsigned ValueSize;
-
- /// The maximum number of bytes to emit; if the alignment
- /// cannot be satisfied in this width then this fragment is ignored.
- unsigned MaxBytesToEmit;
-
- /// When emitting Nops some subtargets have specific nop encodings.
- const MCSubtargetInfo *STI = nullptr;
-
-public:
- MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize,
- unsigned MaxBytesToEmit)
- : MCFragment(FT_Align, false), Alignment(Alignment), EmitNops(false),
- Value(Value), ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {}
-
- Align getAlignment() const { return Alignment; }
-
- int64_t getValue() const { return Value; }
-
- unsigned getValueSize() const { return ValueSize; }
-
- unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
-
- bool hasEmitNops() const { return EmitNops; }
- void setEmitNops(bool Value, const MCSubtargetInfo *STI) {
- EmitNops = Value;
- this->STI = STI;
- }
-
- const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Align;
- }
-};
-
-class MCFillFragment : public MCFragment {
- uint8_t ValueSize;
- /// Value to use for filling bytes.
- uint64_t Value;
- /// The number of bytes to insert.
- const MCExpr &NumValues;
- uint64_t Size = 0;
-
- /// Source location of the directive that this fragment was created for.
- SMLoc Loc;
-
-public:
- MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
- SMLoc Loc)
- : MCFragment(FT_Fill, false), ValueSize(VSize), Value(Value),
- NumValues(NumValues), Loc(Loc) {}
-
- uint64_t getValue() const { return Value; }
- uint8_t getValueSize() const { return ValueSize; }
- const MCExpr &getNumValues() const { return NumValues; }
- uint64_t getSize() const { return Size; }
- void setSize(uint64_t Value) { Size = Value; }
-
- SMLoc getLoc() const { return Loc; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Fill;
- }
-};
-
-class MCNopsFragment : public MCFragment {
- /// The number of bytes to insert.
- int64_t Size;
- /// Maximum number of bytes allowed in each NOP instruction.
- int64_t ControlledNopLength;
-
- /// Source location of the directive that this fragment was created for.
- SMLoc Loc;
-
- /// When emitting Nops some subtargets have specific nop encodings.
- const MCSubtargetInfo &STI;
-
-public:
- MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
- const MCSubtargetInfo &STI)
- : MCFragment(FT_Nops, false), Size(NumBytes),
- ControlledNopLength(ControlledNopLength), Loc(L), STI(STI) {}
-
- int64_t getNumBytes() const { return Size; }
- int64_t getControlledNopLength() const { return ControlledNopLength; }
-
- SMLoc getLoc() const { return Loc; }
-
- const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Nops;
- }
-};
-
-class MCOrgFragment : public MCFragment {
- /// Value to use for filling bytes.
- int8_t Value;
-
- /// The offset this fragment should start at.
- const MCExpr *Offset;
-
- /// Source location of the directive that this fragment was created for.
- SMLoc Loc;
-
-public:
- MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
- : MCFragment(FT_Org, false), Value(Value), Offset(&Offset), Loc(Loc) {}
-
- const MCExpr &getOffset() const { return *Offset; }
-
- uint8_t getValue() const { return Value; }
-
- SMLoc getLoc() const { return Loc; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Org;
- }
-};
-
-class MCLEBFragment final : public MCEncodedFragmentWithFixups<8, 0> {
- /// True if this is a sleb128, false if uleb128.
- bool IsSigned;
-
- /// The value this fragment should contain.
- const MCExpr *Value;
-
-public:
- MCLEBFragment(const MCExpr &Value, bool IsSigned)
- : MCEncodedFragmentWithFixups<8, 0>(FT_LEB, false), IsSigned(IsSigned),
- Value(&Value) {
- getContents().push_back(0);
- }
-
- const MCExpr &getValue() const { return *Value; }
- void setValue(const MCExpr *Expr) { Value = Expr; }
-
- bool isSigned() const { return IsSigned; }
-
- /// @}
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_LEB;
- }
-};
-
-class MCDwarfLineAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
- /// The value of the
diff erence between the two line numbers
- /// between two .loc dwarf directives.
- int64_t LineDelta;
-
- /// The expression for the
diff erence of the two symbols that
- /// make up the address delta between two .loc dwarf directives.
- const MCExpr *AddrDelta;
-
-public:
- MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta)
- : MCEncodedFragmentWithFixups<8, 1>(FT_Dwarf, false),
- LineDelta(LineDelta), AddrDelta(&AddrDelta) {}
-
- int64_t getLineDelta() const { return LineDelta; }
-
- const MCExpr &getAddrDelta() const { return *AddrDelta; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_Dwarf;
- }
-};
-
-class MCDwarfCallFrameFragment : public MCEncodedFragmentWithFixups<8, 1> {
- /// The expression for the
diff erence of the two symbols that
- /// make up the address delta between two .cfi_* dwarf directives.
- const MCExpr *AddrDelta;
-
-public:
- MCDwarfCallFrameFragment(const MCExpr &AddrDelta)
- : MCEncodedFragmentWithFixups<8, 1>(FT_DwarfFrame, false),
- AddrDelta(&AddrDelta) {}
-
- const MCExpr &getAddrDelta() const { return *AddrDelta; }
- void setAddrDelta(const MCExpr *E) { AddrDelta = E; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_DwarfFrame;
- }
-};
-
-/// Represents a symbol table index fragment.
-class MCSymbolIdFragment : public MCFragment {
- const MCSymbol *Sym;
-
-public:
- MCSymbolIdFragment(const MCSymbol *Sym)
- : MCFragment(FT_SymbolId, false), Sym(Sym) {}
-
- const MCSymbol *getSymbol() { return Sym; }
- const MCSymbol *getSymbol() const { return Sym; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_SymbolId;
- }
-};
-
-/// Fragment representing the binary annotations produced by the
-/// .cv_inline_linetable directive.
-class MCCVInlineLineTableFragment : public MCFragment {
- unsigned SiteFuncId;
- unsigned StartFileId;
- unsigned StartLineNum;
- const MCSymbol *FnStartSym;
- const MCSymbol *FnEndSym;
- SmallString<8> Contents;
-
- /// CodeViewContext has the real knowledge about this format, so let it access
- /// our members.
- friend class CodeViewContext;
-
-public:
- MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
- unsigned StartLineNum, const MCSymbol *FnStartSym,
- const MCSymbol *FnEndSym)
- : MCFragment(FT_CVInlineLines, false), SiteFuncId(SiteFuncId),
- StartFileId(StartFileId), StartLineNum(StartLineNum),
- FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
-
- const MCSymbol *getFnStartSym() const { return FnStartSym; }
- const MCSymbol *getFnEndSym() const { return FnEndSym; }
-
- SmallString<8> &getContents() { return Contents; }
- const SmallString<8> &getContents() const { return Contents; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_CVInlineLines;
- }
-};
-
-/// Fragment representing the .cv_def_range directive.
-class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
- SmallVector<std::pair<const MCSymbol *, const MCSymbol *>, 2> Ranges;
- SmallString<32> FixedSizePortion;
-
- /// CodeViewContext has the real knowledge about this format, so let it access
- /// our members.
- friend class CodeViewContext;
-
-public:
- MCCVDefRangeFragment(
- ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
- StringRef FixedSizePortion)
- : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false),
- Ranges(Ranges), FixedSizePortion(FixedSizePortion) {}
-
- ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> getRanges() const {
- return Ranges;
- }
-
- StringRef getFixedSizePortion() const { return FixedSizePortion.str(); }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_CVDefRange;
- }
-};
-
-/// Represents required padding such that a particular other set of fragments
-/// does not cross a particular power-of-two boundary. The other fragments must
-/// follow this one within the same section.
-class MCBoundaryAlignFragment : public MCFragment {
- /// The alignment requirement of the branch to be aligned.
- Align AlignBoundary;
- /// The last fragment in the set of fragments to be aligned.
- const MCFragment *LastFragment = nullptr;
- /// The size of the fragment. The size is lazily set during relaxation, and
- /// is not meaningful before that.
- uint64_t Size = 0;
-
- /// When emitting Nops some subtargets have specific nop encodings.
- const MCSubtargetInfo &STI;
-
-public:
- MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
- : MCFragment(FT_BoundaryAlign, false), AlignBoundary(AlignBoundary),
- STI(STI) {}
-
- uint64_t getSize() const { return Size; }
- void setSize(uint64_t Value) { Size = Value; }
-
- Align getAlignment() const { return AlignBoundary; }
- void setAlignment(Align Value) { AlignBoundary = Value; }
-
- const MCFragment *getLastFragment() const { return LastFragment; }
- void setLastFragment(const MCFragment *F) {
- assert(!F || getParent() == F->getParent());
- LastFragment = F;
- }
-
- const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_BoundaryAlign;
- }
-};
-
-class MCPseudoProbeAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
- /// The expression for the
diff erence of the two symbols that
- /// make up the address delta between two .pseudoprobe directives.
- const MCExpr *AddrDelta;
-
-public:
- MCPseudoProbeAddrFragment(const MCExpr *AddrDelta)
- : MCEncodedFragmentWithFixups<8, 1>(FT_PseudoProbe, false),
- AddrDelta(AddrDelta) {}
-
- const MCExpr &getAddrDelta() const { return *AddrDelta; }
-
- static bool classof(const MCFragment *F) {
- return F->getKind() == MCFragment::FT_PseudoProbe;
- }
-};
-} // end namespace llvm
-
-#endif // LLVM_MC_MCFRAGMENT_H
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index d516fd5b00dd9..3511c4c60fec9 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -12,7 +12,6 @@
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
diff --git a/llvm/include/llvm/MC/MCSection.h b/llvm/include/llvm/MC/MCSection.h
index a4e391dfb03ea..d85a5893496f3 100644
--- a/llvm/include/llvm/MC/MCSection.h
+++ b/llvm/include/llvm/MC/MCSection.h
@@ -13,9 +13,12 @@
#ifndef LLVM_MC_MCSECTION_H
#define LLVM_MC_MCSECTION_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/MC/MCFragment.h"
+#include "llvm/MC/MCFixup.h"
+#include "llvm/MC/MCInst.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/Compiler.h"
@@ -30,9 +33,99 @@ class MCContext;
class MCExpr;
class MCObjectStreamer;
class MCSymbol;
+class MCSection;
+class MCSubtargetInfo;
class raw_ostream;
class Triple;
+// Represents a contiguous piece of code or data within a section. Its size is
+// determined by MCAssembler::layout. All subclasses (except
+// MCRelaxableFragment, which stores a MCInst) must have trivial destructors.
+//
+// Declaration order: MCFragment, MCSection, then MCFragment's derived classes.
+// This allows MCSection's inline functions to access MCFragment members and
+// allows MCFragment's derived classes to access MCSection.
+class MCFragment {
+ friend class MCAssembler;
+ friend class MCObjectStreamer;
+ friend class MCSection;
+
+public:
+ enum FragmentType : uint8_t {
+ FT_Align,
+ FT_Data,
+ FT_Fill,
+ FT_Nops,
+ FT_Relaxable,
+ FT_Org,
+ FT_Dwarf,
+ FT_DwarfFrame,
+ FT_LEB,
+ FT_BoundaryAlign,
+ FT_SymbolId,
+ FT_CVInlineLines,
+ FT_CVDefRange,
+ FT_PseudoProbe,
+ };
+
+private:
+ // The next fragment within the section.
+ MCFragment *Next = nullptr;
+
+ /// The data for the section this fragment is in.
+ MCSection *Parent = nullptr;
+
+ /// The offset of this fragment in its section.
+ uint64_t Offset = 0;
+
+ /// The layout order of this fragment.
+ unsigned LayoutOrder = 0;
+
+ FragmentType Kind;
+
+protected:
+ /// Used by subclasses for better packing.
+ ///
+ /// MCEncodedFragment
+ bool HasInstructions : 1;
+ bool AlignToBundleEnd : 1;
+ /// MCDataFragment
+ bool LinkerRelaxable : 1;
+ /// MCRelaxableFragment: x86-specific
+ bool AllowAutoPadding : 1;
+
+ LLVM_ABI MCFragment(FragmentType Kind, bool HasInstructions);
+
+public:
+ MCFragment() = delete;
+ MCFragment(const MCFragment &) = delete;
+ MCFragment &operator=(const MCFragment &) = delete;
+
+ /// Destroys the current fragment.
+ ///
+ /// This must be used instead of delete as MCFragment is non-virtual.
+ /// This method will dispatch to the appropriate subclass.
+ LLVM_ABI void destroy();
+
+ MCFragment *getNext() const { return Next; }
+
+ FragmentType getKind() const { return Kind; }
+
+ MCSection *getParent() const { return Parent; }
+ void setParent(MCSection *Value) { Parent = Value; }
+
+ LLVM_ABI const MCSymbol *getAtom() const;
+
+ unsigned getLayoutOrder() const { return LayoutOrder; }
+ void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
+
+ /// Does this fragment have instructions emitted into it? By default
+ /// this is false, but specific fragment types may set it to true.
+ bool hasInstructions() const { return HasInstructions; }
+
+ LLVM_ABI void dump() const;
+};
+
/// Instances of this class represent a uniqued identifier for a section in the
/// current translation unit. The MCContext class uniques and creates these.
class LLVM_ABI MCSection {
@@ -201,6 +294,468 @@ class LLVM_ABI MCSection {
virtual StringRef getVirtualSectionKind() const;
};
+/// Interface implemented by fragments that contain encoded instructions and/or
+/// data.
+///
+class MCEncodedFragment : public MCFragment {
+ uint8_t BundlePadding = 0;
+
+protected:
+ MCEncodedFragment(MCFragment::FragmentType FType, bool HasInstructions)
+ : MCFragment(FType, HasInstructions) {}
+
+ /// The MCSubtargetInfo in effect when the instruction was encoded.
+ /// It must be non-null for instructions.
+ const MCSubtargetInfo *STI = nullptr;
+
+public:
+ static bool classof(const MCFragment *F) {
+ MCFragment::FragmentType Kind = F->getKind();
+ switch (Kind) {
+ default:
+ return false;
+ case MCFragment::FT_Relaxable:
+ case MCFragment::FT_Data:
+ case MCFragment::FT_Dwarf:
+ case MCFragment::FT_DwarfFrame:
+ case MCFragment::FT_PseudoProbe:
+ return true;
+ }
+ }
+
+ /// Should this fragment be placed at the end of an aligned bundle?
+ bool alignToBundleEnd() const { return AlignToBundleEnd; }
+ void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
+
+ /// 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.
+ uint8_t getBundlePadding() const { return BundlePadding; }
+
+ /// Set the padding size for this fragment. By default it's a no-op,
+ /// and only some fragments have a meaningful implementation.
+ void setBundlePadding(uint8_t N) { BundlePadding = N; }
+
+ /// Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
+ /// Guaranteed to be non-null if hasInstructions() == true
+ const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
+
+ /// Record that the fragment contains instructions with the MCSubtargetInfo in
+ /// effect when the instruction was encoded.
+ void setHasInstructions(const MCSubtargetInfo &STI) {
+ HasInstructions = true;
+ this->STI = &STI;
+ }
+};
+
+/// Interface implemented by fragments that contain encoded instructions and/or
+/// data and also have fixups registered.
+///
+template <unsigned ContentsSize, unsigned FixupsSize>
+class MCEncodedFragmentWithFixups : public MCEncodedFragment {
+ SmallVector<char, ContentsSize> Contents;
+
+ /// The list of fixups in this fragment.
+ SmallVector<MCFixup, FixupsSize> Fixups;
+
+protected:
+ MCEncodedFragmentWithFixups(MCFragment::FragmentType FType,
+ bool HasInstructions)
+ : MCEncodedFragment(FType, HasInstructions) {}
+
+public:
+ SmallVectorImpl<char> &getContents() { return Contents; }
+ const SmallVectorImpl<char> &getContents() const { return Contents; }
+
+ void appendContents(ArrayRef<char> C) { Contents.append(C.begin(), C.end()); }
+ void appendContents(size_t Num, char Elt) { Contents.append(Num, Elt); }
+ void setContents(ArrayRef<char> C) { Contents.assign(C.begin(), C.end()); }
+
+ void addFixup(MCFixup Fixup) { Fixups.push_back(Fixup); }
+ SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
+ const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
+
+ static bool classof(const MCFragment *F) {
+ MCFragment::FragmentType Kind = F->getKind();
+ return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data ||
+ Kind == MCFragment::FT_CVDefRange || Kind == MCFragment::FT_Dwarf ||
+ Kind == MCFragment::FT_DwarfFrame;
+ }
+};
+
+/// Fragment for data and encoded instructions.
+///
+class MCDataFragment : public MCEncodedFragmentWithFixups<32, 4> {
+public:
+ MCDataFragment() : MCEncodedFragmentWithFixups<32, 4>(FT_Data, false) {}
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Data;
+ }
+
+ bool isLinkerRelaxable() const { return LinkerRelaxable; }
+ void setLinkerRelaxable() { LinkerRelaxable = true; }
+};
+
+/// 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<8, 1> {
+ /// The instruction this is a fragment for.
+ MCInst Inst;
+
+public:
+ MCRelaxableFragment(const MCInst &Inst, const MCSubtargetInfo &STI)
+ : MCEncodedFragmentWithFixups(FT_Relaxable, true), Inst(Inst) {
+ this->STI = &STI;
+ }
+
+ const MCInst &getInst() const { return Inst; }
+ void setInst(const MCInst &Value) { Inst = Value; }
+
+ bool getAllowAutoPadding() const { return AllowAutoPadding; }
+ void setAllowAutoPadding(bool V) { AllowAutoPadding = V; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Relaxable;
+ }
+};
+
+class MCAlignFragment : public MCFragment {
+ /// The alignment to ensure, in bytes.
+ Align Alignment;
+
+ /// 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 to use for filling padding bytes.
+ int64_t Value;
+
+ /// The size of the integer (in bytes) of \p Value.
+ unsigned ValueSize;
+
+ /// The maximum number of bytes to emit; if the alignment
+ /// cannot be satisfied in this width then this fragment is ignored.
+ unsigned MaxBytesToEmit;
+
+ /// When emitting Nops some subtargets have specific nop encodings.
+ const MCSubtargetInfo *STI = nullptr;
+
+public:
+ MCAlignFragment(Align Alignment, int64_t Value, unsigned ValueSize,
+ unsigned MaxBytesToEmit)
+ : MCFragment(FT_Align, false), Alignment(Alignment), EmitNops(false),
+ Value(Value), ValueSize(ValueSize), MaxBytesToEmit(MaxBytesToEmit) {}
+
+ Align getAlignment() const { return Alignment; }
+
+ int64_t getValue() const { return Value; }
+
+ unsigned getValueSize() const { return ValueSize; }
+
+ unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
+
+ bool hasEmitNops() const { return EmitNops; }
+ void setEmitNops(bool Value, const MCSubtargetInfo *STI) {
+ EmitNops = Value;
+ this->STI = STI;
+ }
+
+ const MCSubtargetInfo *getSubtargetInfo() const { return STI; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Align;
+ }
+};
+
+class MCFillFragment : public MCFragment {
+ uint8_t ValueSize;
+ /// Value to use for filling bytes.
+ uint64_t Value;
+ /// The number of bytes to insert.
+ const MCExpr &NumValues;
+ uint64_t Size = 0;
+
+ /// Source location of the directive that this fragment was created for.
+ SMLoc Loc;
+
+public:
+ MCFillFragment(uint64_t Value, uint8_t VSize, const MCExpr &NumValues,
+ SMLoc Loc)
+ : MCFragment(FT_Fill, false), ValueSize(VSize), Value(Value),
+ NumValues(NumValues), Loc(Loc) {}
+
+ uint64_t getValue() const { return Value; }
+ uint8_t getValueSize() const { return ValueSize; }
+ const MCExpr &getNumValues() const { return NumValues; }
+ uint64_t getSize() const { return Size; }
+ void setSize(uint64_t Value) { Size = Value; }
+
+ SMLoc getLoc() const { return Loc; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Fill;
+ }
+};
+
+class MCNopsFragment : public MCFragment {
+ /// The number of bytes to insert.
+ int64_t Size;
+ /// Maximum number of bytes allowed in each NOP instruction.
+ int64_t ControlledNopLength;
+
+ /// Source location of the directive that this fragment was created for.
+ SMLoc Loc;
+
+ /// When emitting Nops some subtargets have specific nop encodings.
+ const MCSubtargetInfo &STI;
+
+public:
+ MCNopsFragment(int64_t NumBytes, int64_t ControlledNopLength, SMLoc L,
+ const MCSubtargetInfo &STI)
+ : MCFragment(FT_Nops, false), Size(NumBytes),
+ ControlledNopLength(ControlledNopLength), Loc(L), STI(STI) {}
+
+ int64_t getNumBytes() const { return Size; }
+ int64_t getControlledNopLength() const { return ControlledNopLength; }
+
+ SMLoc getLoc() const { return Loc; }
+
+ const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Nops;
+ }
+};
+
+class MCOrgFragment : public MCFragment {
+ /// Value to use for filling bytes.
+ int8_t Value;
+
+ /// The offset this fragment should start at.
+ const MCExpr *Offset;
+
+ /// Source location of the directive that this fragment was created for.
+ SMLoc Loc;
+
+public:
+ MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
+ : MCFragment(FT_Org, false), Value(Value), Offset(&Offset), Loc(Loc) {}
+
+ const MCExpr &getOffset() const { return *Offset; }
+
+ uint8_t getValue() const { return Value; }
+
+ SMLoc getLoc() const { return Loc; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Org;
+ }
+};
+
+class MCLEBFragment final : public MCEncodedFragmentWithFixups<8, 0> {
+ /// True if this is a sleb128, false if uleb128.
+ bool IsSigned;
+
+ /// The value this fragment should contain.
+ const MCExpr *Value;
+
+public:
+ MCLEBFragment(const MCExpr &Value, bool IsSigned)
+ : MCEncodedFragmentWithFixups<8, 0>(FT_LEB, false), IsSigned(IsSigned),
+ Value(&Value) {
+ getContents().push_back(0);
+ }
+
+ const MCExpr &getValue() const { return *Value; }
+ void setValue(const MCExpr *Expr) { Value = Expr; }
+
+ bool isSigned() const { return IsSigned; }
+
+ /// @}
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_LEB;
+ }
+};
+
+class MCDwarfLineAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
+ /// The value of the
diff erence between the two line numbers
+ /// between two .loc dwarf directives.
+ int64_t LineDelta;
+
+ /// The expression for the
diff erence of the two symbols that
+ /// make up the address delta between two .loc dwarf directives.
+ const MCExpr *AddrDelta;
+
+public:
+ MCDwarfLineAddrFragment(int64_t LineDelta, const MCExpr &AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_Dwarf, false),
+ LineDelta(LineDelta), AddrDelta(&AddrDelta) {}
+
+ int64_t getLineDelta() const { return LineDelta; }
+
+ const MCExpr &getAddrDelta() const { return *AddrDelta; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_Dwarf;
+ }
+};
+
+class MCDwarfCallFrameFragment : public MCEncodedFragmentWithFixups<8, 1> {
+ /// The expression for the
diff erence of the two symbols that
+ /// make up the address delta between two .cfi_* dwarf directives.
+ const MCExpr *AddrDelta;
+
+public:
+ MCDwarfCallFrameFragment(const MCExpr &AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_DwarfFrame, false),
+ AddrDelta(&AddrDelta) {}
+
+ const MCExpr &getAddrDelta() const { return *AddrDelta; }
+ void setAddrDelta(const MCExpr *E) { AddrDelta = E; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_DwarfFrame;
+ }
+};
+
+/// Represents a symbol table index fragment.
+class MCSymbolIdFragment : public MCFragment {
+ const MCSymbol *Sym;
+
+public:
+ MCSymbolIdFragment(const MCSymbol *Sym)
+ : MCFragment(FT_SymbolId, false), Sym(Sym) {}
+
+ const MCSymbol *getSymbol() { return Sym; }
+ const MCSymbol *getSymbol() const { return Sym; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_SymbolId;
+ }
+};
+
+/// Fragment representing the binary annotations produced by the
+/// .cv_inline_linetable directive.
+class MCCVInlineLineTableFragment : public MCFragment {
+ unsigned SiteFuncId;
+ unsigned StartFileId;
+ unsigned StartLineNum;
+ const MCSymbol *FnStartSym;
+ const MCSymbol *FnEndSym;
+ SmallString<8> Contents;
+
+ /// CodeViewContext has the real knowledge about this format, so let it access
+ /// our members.
+ friend class CodeViewContext;
+
+public:
+ MCCVInlineLineTableFragment(unsigned SiteFuncId, unsigned StartFileId,
+ unsigned StartLineNum, const MCSymbol *FnStartSym,
+ const MCSymbol *FnEndSym)
+ : MCFragment(FT_CVInlineLines, false), SiteFuncId(SiteFuncId),
+ StartFileId(StartFileId), StartLineNum(StartLineNum),
+ FnStartSym(FnStartSym), FnEndSym(FnEndSym) {}
+
+ const MCSymbol *getFnStartSym() const { return FnStartSym; }
+ const MCSymbol *getFnEndSym() const { return FnEndSym; }
+
+ SmallString<8> &getContents() { return Contents; }
+ const SmallString<8> &getContents() const { return Contents; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_CVInlineLines;
+ }
+};
+
+/// Fragment representing the .cv_def_range directive.
+class MCCVDefRangeFragment : public MCEncodedFragmentWithFixups<32, 4> {
+ SmallVector<std::pair<const MCSymbol *, const MCSymbol *>, 2> Ranges;
+ SmallString<32> FixedSizePortion;
+
+ /// CodeViewContext has the real knowledge about this format, so let it access
+ /// our members.
+ friend class CodeViewContext;
+
+public:
+ MCCVDefRangeFragment(
+ ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> Ranges,
+ StringRef FixedSizePortion)
+ : MCEncodedFragmentWithFixups<32, 4>(FT_CVDefRange, false),
+ Ranges(Ranges), FixedSizePortion(FixedSizePortion) {}
+
+ ArrayRef<std::pair<const MCSymbol *, const MCSymbol *>> getRanges() const {
+ return Ranges;
+ }
+
+ StringRef getFixedSizePortion() const { return FixedSizePortion.str(); }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_CVDefRange;
+ }
+};
+
+/// Represents required padding such that a particular other set of fragments
+/// does not cross a particular power-of-two boundary. The other fragments must
+/// follow this one within the same section.
+class MCBoundaryAlignFragment : public MCFragment {
+ /// The alignment requirement of the branch to be aligned.
+ Align AlignBoundary;
+ /// The last fragment in the set of fragments to be aligned.
+ const MCFragment *LastFragment = nullptr;
+ /// The size of the fragment. The size is lazily set during relaxation, and
+ /// is not meaningful before that.
+ uint64_t Size = 0;
+
+ /// When emitting Nops some subtargets have specific nop encodings.
+ const MCSubtargetInfo &STI;
+
+public:
+ MCBoundaryAlignFragment(Align AlignBoundary, const MCSubtargetInfo &STI)
+ : MCFragment(FT_BoundaryAlign, false), AlignBoundary(AlignBoundary),
+ STI(STI) {}
+
+ uint64_t getSize() const { return Size; }
+ void setSize(uint64_t Value) { Size = Value; }
+
+ Align getAlignment() const { return AlignBoundary; }
+ void setAlignment(Align Value) { AlignBoundary = Value; }
+
+ const MCFragment *getLastFragment() const { return LastFragment; }
+ void setLastFragment(const MCFragment *F) {
+ assert(!F || getParent() == F->getParent());
+ LastFragment = F;
+ }
+
+ const MCSubtargetInfo *getSubtargetInfo() const { return &STI; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_BoundaryAlign;
+ }
+};
+
+class MCPseudoProbeAddrFragment : public MCEncodedFragmentWithFixups<8, 1> {
+ /// The expression for the
diff erence of the two symbols that
+ /// make up the address delta between two .pseudoprobe directives.
+ const MCExpr *AddrDelta;
+
+public:
+ MCPseudoProbeAddrFragment(const MCExpr *AddrDelta)
+ : MCEncodedFragmentWithFixups<8, 1>(FT_PseudoProbe, false),
+ AddrDelta(AddrDelta) {}
+
+ const MCExpr &getAddrDelta() const { return *AddrDelta; }
+
+ static bool classof(const MCFragment *F) {
+ return F->getKind() == MCFragment::FT_PseudoProbe;
+ }
+};
+
} // end namespace llvm
#endif // LLVM_MC_MCSECTION_H
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index 8f2e137ea0c84..00bec1f582eab 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -19,9 +19,9 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCDwarf.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
#include "llvm/MC/MCPseudoProbe.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCWinEH.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Error.h"
@@ -45,11 +45,9 @@ class MCAsmBackend;
class MCAssembler;
class MCContext;
class MCExpr;
-class MCFragment;
class MCInst;
class MCInstPrinter;
class MCRegister;
-class MCSection;
class MCStreamer;
class MCSubtargetInfo;
class MCSymbol;
diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index b02bc111955ab..dc191f881921a 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -16,7 +16,7 @@
#include "llvm/ADT/StringMapEntry.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFragment.h"
+#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSymbolTableEntry.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index bd87b42ff61fd..816ec2507646d 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -28,7 +28,6 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionELF.h"
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index bd2242af23f7c..995a68e5548c8 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -22,7 +22,6 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 89644cfcce48f..b0d1cb41fac1c 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -21,7 +21,6 @@
#include "llvm/MC/MCCodeView.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCLabel.h"
#include "llvm/MC/MCSectionCOFF.h"
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 5a514f12ce549..1fecde4be03cc 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -21,7 +21,6 @@
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index d8db55c9a5f5d..7dd3b501757b7 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/MC/MCFragment.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/Twine.h"
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index e1d7f8c8f1572..a54dfb9cbaea1 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -18,7 +18,6 @@
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCLinkerOptimizationHint.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectFileInfo.h"
diff --git a/llvm/lib/MC/MCObjectWriter.cpp b/llvm/lib/MC/MCObjectWriter.cpp
index 86be52d57ef7a..7cbd0b489d9f6 100644
--- a/llvm/lib/MC/MCObjectWriter.cpp
+++ b/llvm/lib/MC/MCObjectWriter.cpp
@@ -10,7 +10,6 @@
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
namespace llvm {
diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp
index 8a9906df92975..f87d27f4adcc5 100644
--- a/llvm/lib/MC/MCPseudoProbe.cpp
+++ b/llvm/lib/MC/MCPseudoProbe.cpp
@@ -13,7 +13,6 @@
#include "llvm/MC/MCAssembler.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCSymbol.h"
diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp
index 9aad34e0d32ad..1b766d3fad8b1 100644
--- a/llvm/lib/MC/MCSection.cpp
+++ b/llvm/lib/MC/MCSection.cpp
@@ -10,7 +10,6 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp
index 5cba901d33d5e..baf1ff89c0188 100644
--- a/llvm/lib/MC/MCSymbol.cpp
+++ b/llvm/lib/MC/MCSymbol.cpp
@@ -11,7 +11,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index 0940fc01f6594..602d40df4cc3a 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -18,7 +18,6 @@
#include "llvm/MC/MCCodeEmitter.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionWasm.h"
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 3c7566b8ccd55..0c0866f9e36a4 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -22,7 +22,6 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectStreamer.h"
#include "llvm/MC/MCObjectWriter.h"
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 9377a74b377ea..2e671e0685c2e 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -16,7 +16,6 @@
#include "llvm/MC/MCDirectives.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixupKindInfo.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCObjectFileInfo.h"
#include "llvm/MC/MCObjectWriter.h"
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 2ed0aa3d20fc9..a822a80b0af42 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -22,7 +22,6 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionCOFF.h"
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
index 7d849d3cb3153..fdf7850e2c01e 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
@@ -17,7 +17,6 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCMachObjectWriter.h"
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCSectionMachO.h"
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 0784c0b1161fe..c61e405bd3a02 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -32,7 +32,6 @@
#include "llvm/MC/MCELFStreamer.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCFixup.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCObjectFileInfo.h"
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 8ed0aa8b832cf..952744b549811 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -14,7 +14,6 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCELFObjectWriter.h"
#include "llvm/MC/MCExpr.h"
-#include "llvm/MC/MCFragment.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCValue.h"
More information about the llvm-commits
mailing list