diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h --- a/llvm/include/llvm/MC/MCELFStreamer.h +++ b/llvm/include/llvm/MC/MCELFStreamer.h @@ -83,7 +83,7 @@ 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 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -148,7 +148,7 @@ /// 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 --- a/llvm/include/llvm/MC/MCStreamer.h +++ b/llvm/include/llvm/MC/MCStreamer.h @@ -1110,9 +1110,8 @@ 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 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -381,7 +381,7 @@ 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 @@ 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 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -635,12 +635,12 @@ } } -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 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -480,7 +480,7 @@ "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 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -4808,9 +4808,7 @@ "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(AlignSizePow2)); + getStreamer().emitBundleAlignMode(Align(AlignSizePow2)); return false; } diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp --- a/llvm/lib/MC/MCStreamer.cpp +++ b/llvm/lib/MC/MCStreamer.cpp @@ -1227,7 +1227,7 @@ 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 --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsNaClELFStreamer.cpp @@ -270,7 +270,7 @@ 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; }