Skip to content

MC: Remove bundle alignment mode #148781

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
merged 3 commits into from
Jul 16, 2025
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
23 changes: 0 additions & 23 deletions llvm/include/llvm/MC/MCAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ class MCAssembler {
// refactoring too.
mutable SmallPtrSet<const MCSymbol *, 32> ThumbFuncs;

/// The bundle alignment size currently set in the assembler.
///
/// By default it's 0, which means bundling is disabled.
unsigned BundleAlignSize = 0;

/// Evaluate a fixup to a relocatable expression and the value which should be
/// placed into the fixup.
///
Expand Down Expand Up @@ -143,8 +138,6 @@ class MCAssembler {
/// Compute the effective fragment size.
LLVM_ABI uint64_t computeFragmentSize(const MCFragment &F) const;

LLVM_ABI void layoutBundle(MCFragment *Prev, MCFragment *F) const;

// Get the offset of the given fragment inside its containing section.
uint64_t getFragmentOffset(const MCFragment &F) const { return F.Offset; }

Expand Down Expand Up @@ -203,16 +196,6 @@ class MCAssembler {
bool getRelaxAll() const { return RelaxAll; }
void setRelaxAll(bool Value) { RelaxAll = Value; }

bool isBundlingEnabled() const { return BundleAlignSize != 0; }

unsigned getBundleAlignSize() const { return BundleAlignSize; }

void setBundleAlignSize(unsigned Size) {
assert((Size == 0 || !(Size & (Size - 1))) &&
"Expect a power-of-two bundle align size");
BundleAlignSize = Size;
}

const_iterator begin() const { return Sections.begin(); }
const_iterator end() const { return Sections.end(); }

Expand All @@ -226,12 +209,6 @@ class MCAssembler {
LLVM_ABI bool registerSection(MCSection &Section);
LLVM_ABI bool registerSymbol(const MCSymbol &Symbol);

/// Write the necessary bundle padding to \p OS.
/// Expects a fragment \p F containing instructions and its size \p FSize.
LLVM_ABI void writeFragmentPadding(raw_ostream &OS,
const MCEncodedFragment &F,
uint64_t FSize) const;

LLVM_ABI void reportError(SMLoc L, const Twine &Msg) const;
// Record pending errors during layout iteration, as they may go away once the
// layout is finalized.
Expand Down
12 changes: 0 additions & 12 deletions llvm/include/llvm/MC/MCELFStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,15 @@ class MCELFStreamer : public MCObjectStreamer {
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
Align ByteAlignment) override;

void emitValueImpl(const MCExpr *Value, unsigned Size,
SMLoc Loc = SMLoc()) override;

void emitIdent(StringRef IdentString) override;

void emitValueToAlignment(Align, int64_t, uint8_t, unsigned) override;

void emitCGProfileEntry(const MCSymbolRefExpr *From,
const MCSymbolRefExpr *To, uint64_t Count) override;

// This is final. Override MCTargetStreamer::finish instead for
// target-specific code.
void finishImpl() final;

void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;

/// ELF object attributes section emission support
struct AttributeItem {
// This structure holds all attributes, accounting for their string /
Expand Down Expand Up @@ -151,9 +142,6 @@ class MCELFStreamer : public MCObjectStreamer {
}

private:
bool isBundleLocked() const;
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;

void finalizeCGProfileEntry(const MCSymbolRefExpr *&S, uint64_t Offset);
void finalizeCGProfile();

Expand Down
5 changes: 1 addition & 4 deletions llvm/include/llvm/MC/MCObjectStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class MCObjectStreamer : public MCStreamer {
DenseMap<const MCSymbol *, SmallVector<PendingAssignment, 1>>
pendingAssignments;

virtual void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &);
void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &);
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
void emitInstructionImpl(const MCInst &Inst, const MCSubtargetInfo &STI);
Expand Down Expand Up @@ -127,9 +127,6 @@ class MCObjectStreamer : public MCStreamer {
/// can change its size during relaxation.
void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &);

void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;
void emitBytes(StringRef Data) override;
void emitValueToAlignment(Align Alignment, int64_t Fill = 0,
uint8_t FillLen = 1,
Expand Down
45 changes: 0 additions & 45 deletions llvm/include/llvm/MC/MCSection.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ class LLVM_ABI MCSection {
SV_DXContainer,
};

/// Express the state of bundle locked groups while emitting code.
enum BundleLockStateType {
NotBundleLocked,
BundleLocked,
BundleLockedAlignToEnd
};

struct iterator {
MCFragment *F = nullptr;
iterator() = default;
Expand All @@ -94,16 +87,6 @@ class LLVM_ABI MCSection {
/// The section index in the assemblers section list.
unsigned Ordinal = 0;

/// Keeping track of bundle-locked state.
BundleLockStateType BundleLockState = NotBundleLocked;

/// Current nesting depth of bundle_lock directives.
unsigned BundleLockNestingDepth = 0;

/// We've seen a bundle_lock directive but not its first instruction
/// yet.
bool BundleGroupBeforeFirstInst : 1;

/// Whether this section has had instructions emitted into it.
bool HasInstructions : 1;

Expand Down Expand Up @@ -169,17 +152,6 @@ class LLVM_ABI MCSection {
unsigned getOrdinal() const { return Ordinal; }
void setOrdinal(unsigned Value) { Ordinal = Value; }

BundleLockStateType getBundleLockState() const { return BundleLockState; }
void setBundleLockState(BundleLockStateType NewState);
bool isBundleLocked() const { return BundleLockState != NotBundleLocked; }

bool isBundleGroupBeforeFirstInst() const {
return BundleGroupBeforeFirstInst;
}
void setBundleGroupBeforeFirstInst(bool IsFirst) {
BundleGroupBeforeFirstInst = IsFirst;
}

bool hasInstructions() const { return HasInstructions; }
void setHasInstructions(bool Value) { HasInstructions = Value; }

Expand Down Expand Up @@ -259,7 +231,6 @@ class MCFragment {
///
/// MCEncodedFragment
bool HasInstructions : 1;
bool AlignToBundleEnd : 1;
/// MCDataFragment
bool LinkerRelaxable : 1;
/// MCRelaxableFragment: x86-specific
Expand Down Expand Up @@ -297,7 +268,6 @@ class MCFragment {
/// Interface implemented by fragments that contain encoded instructions and/or
/// data.
class MCEncodedFragment : public MCFragment {
uint8_t BundlePadding = 0;
uint32_t ContentStart = 0;
uint32_t ContentEnd = 0;
uint32_t FixupStart = 0;
Expand Down Expand Up @@ -329,21 +299,6 @@ class MCEncodedFragment : public MCFragment {
}
}

/// 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; }
Expand Down
13 changes: 0 additions & 13 deletions llvm/include/llvm/MC/MCStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -1068,19 +1068,6 @@ class LLVM_ABI MCStreamer {
const MCPseudoProbeInlineStack &InlineStack,
MCSymbol *FnSym);

/// Set the bundle alignment mode from now on in the section.
/// The value 1 means turn the bundle alignment off.
virtual void emitBundleAlignMode(Align Alignment);

/// The following instructions are a bundle-locked group.
///
/// \param AlignToEnd - If true, the bundle-locked group will be aligned to
/// the end of a bundle.
virtual void emitBundleLock(bool AlignToEnd);

/// Ends a bundle-locked group.
virtual void emitBundleUnlock();

/// If this file is backed by a assembly streamer, this dumps the
/// specified string in the output .s file. This capability is indicated by
/// the hasRawTextSupport() predicate. By default this aborts.
Expand Down
21 changes: 0 additions & 21 deletions llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,10 +407,6 @@ class MCAsmStreamer final : public MCStreamer {
const MCPseudoProbeInlineStack &InlineStack,
MCSymbol *FnSym) override;

void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;

std::optional<std::pair<bool, std::string>>
emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr,
SMLoc Loc, const MCSubtargetInfo &STI) override;
Expand Down Expand Up @@ -2472,23 +2468,6 @@ void MCAsmStreamer::emitPseudoProbe(uint64_t Guid, uint64_t Index,
EmitEOL();
}

void MCAsmStreamer::emitBundleAlignMode(Align Alignment) {
OS << "\t.bundle_align_mode " << Log2(Alignment);
EmitEOL();
}

void MCAsmStreamer::emitBundleLock(bool AlignToEnd) {
OS << "\t.bundle_lock";
if (AlignToEnd)
OS << " align_to_end";
EmitEOL();
}

void MCAsmStreamer::emitBundleUnlock() {
OS << "\t.bundle_unlock";
EmitEOL();
}

std::optional<std::pair<bool, std::string>>
MCAsmStreamer::emitRelocDirective(const MCExpr &Offset, StringRef Name,
const MCExpr *Expr, SMLoc,
Expand Down
Loading
Loading