[llvm] 99089b4 - [Alignment][NFC] Use Align in MCStreamer::emitBundleAlignMode
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 24 06:35:15 PST 2022
Author: Guillaume Chatelet
Date: 2022-11-24T14:35:01Z
New Revision: 99089b490d2de240ffe908fa56744ed6ba0e249c
URL: https://github.com/llvm/llvm-project/commit/99089b490d2de240ffe908fa56744ed6ba0e249c
DIFF: https://github.com/llvm/llvm-project/commit/99089b490d2de240ffe908fa56744ed6ba0e249c.diff
LOG: [Alignment][NFC] Use Align in MCStreamer::emitBundleAlignMode
Summary:
Reviewers: courbet
Subscribers:
Added:
Modified:
llvm/include/llvm/MC/MCELFStreamer.h
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/include/llvm/MC/MCStreamer.h
llvm/lib/MC/MCAsmStreamer.cpp
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCStreamer.cpp
llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index eac807aad908..86327d76e0c5 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -83,7 +83,7 @@ class MCELFStreamer : public MCObjectStreamer {
void finishImpl() override;
- void emitBundleAlignMode(unsigned AlignPow2) override;
+ void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index 6536c81d4aac..efccf89a4503 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -148,7 +148,7 @@ class MCObjectStreamer : public MCStreamer {
/// can change its size during relaxation.
virtual void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &);
- void emitBundleAlignMode(unsigned AlignPow2) override;
+ void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;
void emitBytes(StringRef Data) override;
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index a9d7a5ea3263..2e4ddd001c71 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -1110,9 +1110,8 @@ class MCStreamer {
MCSymbol *FnSym);
/// Set the bundle alignment mode from now on in the section.
- /// The argument is the power of 2 to which the alignment is set. The
- /// value 0 means turn the bundle alignment off.
- virtual void emitBundleAlignMode(unsigned AlignPow2);
+ /// The value 1 means turn the bundle alignment off.
+ virtual void emitBundleAlignMode(Align Alignment);
/// The following instructions are a bundle-locked group.
///
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 2a94655d528a..9483dd53ff5c 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -381,7 +381,7 @@ class MCAsmStreamer final : public MCStreamer {
uint64_t Attr,
const MCPseudoProbeInlineStack &InlineStack, MCSymbol *FnSym) override;
- void emitBundleAlignMode(unsigned AlignPow2) override;
+ void emitBundleAlignMode(Align Alignment) override;
void emitBundleLock(bool AlignToEnd) override;
void emitBundleUnlock() override;
@@ -2353,8 +2353,8 @@ void MCAsmStreamer::emitPseudoProbe(
EmitEOL();
}
-void MCAsmStreamer::emitBundleAlignMode(unsigned AlignPow2) {
- OS << "\t.bundle_align_mode " << AlignPow2;
+void MCAsmStreamer::emitBundleAlignMode(Align Alignment) {
+ OS << "\t.bundle_align_mode " << Log2(Alignment);
EmitEOL();
}
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index e5b46a63e7e1..6b9f59094011 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -635,12 +635,12 @@ void MCELFStreamer::emitInstToData(const MCInst &Inst,
}
}
-void MCELFStreamer::emitBundleAlignMode(unsigned AlignPow2) {
- assert(AlignPow2 <= 30 && "Invalid bundle alignment");
+void MCELFStreamer::emitBundleAlignMode(Align Alignment) {
+ assert(Log2(Alignment) <= 30 && "Invalid bundle alignment");
MCAssembler &Assembler = getAssembler();
- if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 ||
- Assembler.getBundleAlignSize() == 1U << AlignPow2))
- Assembler.setBundleAlignSize(1U << AlignPow2);
+ if (Alignment > 1 && (Assembler.getBundleAlignSize() == 0 ||
+ Assembler.getBundleAlignSize() == Alignment.value()))
+ Assembler.setBundleAlignSize(Alignment.value());
else
report_fatal_error(".bundle_align_mode cannot be changed once set");
}
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index c99f127e4cc7..701f0c5dc309 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -480,7 +480,7 @@ static const char *const BundlingNotImplementedMsg =
"Aligned bundling is not implemented for this object format";
#endif
-void MCObjectStreamer::emitBundleAlignMode(unsigned AlignPow2) {
+void MCObjectStreamer::emitBundleAlignMode(Align Alignment) {
llvm_unreachable(BundlingNotImplementedMsg);
}
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index ce90c21a66ae..8866e9c7ce20 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -4808,9 +4808,7 @@ bool AsmParser::parseDirectiveBundleAlignMode() {
"invalid bundle alignment size (expected between 0 and 30)"))
return true;
- // Because of AlignSizePow2's verified range we can safely truncate it to
- // unsigned.
- getStreamer().emitBundleAlignMode(static_cast<unsigned>(AlignSizePow2));
+ getStreamer().emitBundleAlignMode(Align(1ULL << AlignSizePow2));
return false;
}
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index fbfef943ec3a..4405cda402d5 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -1227,7 +1227,7 @@ void MCStreamer::emitCodeAlignment(unsigned ByteAlignment,
unsigned MaxBytesToEmit) {}
void MCStreamer::emitValueToOffset(const MCExpr *Offset, unsigned char Value,
SMLoc Loc) {}
-void MCStreamer::emitBundleAlignMode(unsigned AlignPow2) {}
+void MCStreamer::emitBundleAlignMode(Align Alignment) {}
void MCStreamer::emitBundleLock(bool AlignToEnd) {}
void MCStreamer::finishImpl() {}
void MCStreamer::emitBundleUnlock() {}
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp
index eade2d9bd745..4ba0ae91e2f6 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp
@@ -270,7 +270,7 @@ MCELFStreamer *createMipsNaClELFStreamer(MCContext &Context,
S->getAssembler().setRelaxAll(true);
// Set bundle-alignment as required by the NaCl ABI for the target.
- S->emitBundleAlignMode(Log2(MIPS_NACL_BUNDLE_ALIGN));
+ S->emitBundleAlignMode(MIPS_NACL_BUNDLE_ALIGN);
return S;
}
More information about the llvm-commits
mailing list