Skip to content

MC: Restructure MCFragment as a fixed part and a variable tail #148544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions llvm/include/llvm/MC/MCAsmBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@
namespace llvm {

class MCAlignFragment;
class MCDwarfCallFrameFragment;
class MCDwarfLineAddrFragment;
class MCFragment;
class MCLEBFragment;
class MCRelaxableFragment;
class MCSymbol;
class MCAssembler;
class MCContext;
Expand Down Expand Up @@ -157,8 +154,9 @@ class LLVM_ABI MCAsmBackend {

/// Target specific predicate for whether a given fixup requires the
/// associated instruction to be relaxed.
virtual bool fixupNeedsRelaxationAdvanced(const MCFixup &, const MCValue &,
uint64_t, bool Resolved) const;
virtual bool fixupNeedsRelaxationAdvanced(const MCFragment &, const MCFixup &,
const MCValue &, uint64_t,
bool Resolved) const;

/// Simple predicate for targets where !Resolved implies requiring relaxation
virtual bool fixupNeedsRelaxation(const MCFixup &Fixup,
Expand All @@ -179,18 +177,16 @@ class LLVM_ABI MCAsmBackend {
}

// Defined by linker relaxation targets.
virtual bool relaxDwarfLineAddr(MCDwarfLineAddrFragment &DF,
bool &WasRelaxed) const {
virtual bool relaxDwarfLineAddr(MCFragment &, bool &WasRelaxed) const {
return false;
}
virtual bool relaxDwarfCFA(MCDwarfCallFrameFragment &DF,
bool &WasRelaxed) const {
virtual bool relaxDwarfCFA(MCFragment &, bool &WasRelaxed) const {
return false;
}

// Defined by linker relaxation targets to possibly emit LEB128 relocations
// and set Value at the relocated location.
virtual std::pair<bool, bool> relaxLEB128(MCLEBFragment &LF,
virtual std::pair<bool, bool> relaxLEB128(MCFragment &,
int64_t &Value) const {
return std::make_pair(false, false);
}
Expand Down Expand Up @@ -228,7 +224,7 @@ class LLVM_ABI MCAsmBackend {

bool isDarwinCanonicalPersonality(const MCSymbol *Sym) const;

// Return STI for fragments of type MCRelaxableFragment and MCDataFragment
// Return STI for fragments of type MCRelaxableFragment and MCFragment
// with hasInstructions() == true.
static const MCSubtargetInfo *getSubtargetInfo(const MCFragment &F);
};
Expand Down
15 changes: 6 additions & 9 deletions llvm/include/llvm/MC/MCAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ namespace llvm {
class MCBoundaryAlignFragment;
class MCCVDefRangeFragment;
class MCCVInlineLineTableFragment;
class MCDwarfCallFrameFragment;
class MCDwarfLineAddrFragment;
class MCEncodedFragment;
class MCFragment;
class MCFixup;
class MCLEBFragment;
class MCPseudoProbeAddrFragment;
class MCRelaxableFragment;
class MCSymbolRefExpr;
class raw_ostream;
class MCAsmBackend;
Expand Down Expand Up @@ -102,7 +99,7 @@ class MCAssembler {

/// Check whether a fixup can be satisfied, or whether it needs to be relaxed
/// (increased in size, in order to hold its value correctly).
bool fixupNeedsRelaxation(const MCRelaxableFragment &, const MCFixup &) const;
bool fixupNeedsRelaxation(const MCFragment &, const MCFixup &) const;

void layoutSection(MCSection &Sec);
/// Perform one layout iteration and return the index of the first stable
Expand All @@ -111,11 +108,11 @@ class MCAssembler {

/// Perform relaxation on a single fragment.
bool relaxFragment(MCFragment &F);
bool relaxInstruction(MCRelaxableFragment &IF);
bool relaxLEB(MCLEBFragment &IF);
bool relaxInstruction(MCFragment &F);
bool relaxLEB(MCFragment &F);
bool relaxBoundaryAlign(MCBoundaryAlignFragment &BF);
bool relaxDwarfLineAddr(MCDwarfLineAddrFragment &DF);
bool relaxDwarfCallFrameFragment(MCDwarfCallFrameFragment &DF);
bool relaxDwarfLineAddr(MCFragment &F);
bool relaxDwarfCallFrameFragment(MCFragment &F);
bool relaxCVInlineLineTable(MCCVInlineLineTableFragment &DF);
bool relaxCVDefRange(MCCVDefRangeFragment &DF);
bool relaxFill(MCFillFragment &F);
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/MC/MCCodeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ namespace llvm {
class MCAssembler;
class MCCVDefRangeFragment;
class MCCVInlineLineTableFragment;
class MCDataFragment;
class MCFragment;
class MCSection;
class MCSymbol;
Expand Down Expand Up @@ -231,7 +230,7 @@ class CodeViewContext {
StringMap<unsigned> StringTable;

/// The fragment that ultimately holds our strings.
MCDataFragment *StrTabFragment = nullptr;
MCFragment *StrTabFragment = nullptr;
SmallVector<char, 0> StrTab = {'\0'};

/// Get a string table offset.
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/MC/MCContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ namespace llvm {

class CodeViewContext;
class MCAsmInfo;
class MCDataFragment;
class MCInst;
class MCLabel;
class MCObjectFileInfo;
Expand Down Expand Up @@ -334,7 +333,7 @@ class MCContext {
void reportCommon(SMLoc Loc,
std::function<void(SMDiagnostic &, const SourceMgr *)>);

MCDataFragment *allocInitialFragment(MCSection &Sec);
MCFragment *allocInitialFragment(MCSection &Sec);

MCSymbolTableEntry &getSymbolTableEntry(StringRef Name);

Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/MC/MCELFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace llvm {

class ELFObjectWriter;
class MCContext;
class MCDataFragment;
class MCFragment;
class MCObjectWriter;
class MCSection;
Expand Down Expand Up @@ -51,7 +50,7 @@ class MCELFStreamer : public MCObjectStreamer {
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment &F,
uint64_t Offset) override;
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Target) override;
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
Expand Down
10 changes: 5 additions & 5 deletions llvm/include/llvm/MC/MCObjectStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class MCObjectStreamer : public MCStreamer {
struct PendingMCFixup {
const MCSymbol *Sym;
MCFixup Fixup;
MCDataFragment *DF;
PendingMCFixup(const MCSymbol *McSym, MCDataFragment *F, MCFixup McFixup)
MCFragment *DF;
PendingMCFixup(const MCSymbol *McSym, MCFragment *F, MCFixup McFixup)
: Sym(McSym), Fixup(McFixup), DF(F) {}
};
SmallVector<PendingMCFixup, 2> PendingFixups;
Expand Down Expand Up @@ -92,10 +92,10 @@ class MCObjectStreamer : public MCStreamer {
}

/// Get a data fragment to write into, creating a new one if the current
/// fragment is not a data fragment.
/// fragment is not FT_Data.
/// Optionally a \p STI can be passed in so that a new fragment is created
/// if the Subtarget differs from the current fragment.
MCDataFragment *getOrCreateDataFragment(const MCSubtargetInfo* STI = nullptr);
MCFragment *getOrCreateDataFragment(const MCSubtargetInfo *STI = nullptr);

protected:
bool changeSectionImpl(MCSection *Section, uint32_t Subsection);
Expand All @@ -109,7 +109,7 @@ class MCObjectStreamer : public MCStreamer {
/// @{

void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment &F,
uint64_t Offset);
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
void emitConditionalAssignment(MCSymbol *Symbol,
Expand Down
Loading
Loading