[llvm] [X86] Reimplement bundle alignment mode (PR #175830)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 14 19:22:27 PDT 2026
================
@@ -316,6 +334,82 @@ void MCELFStreamer::emitIdent(StringRef IdentString) {
popSection();
}
+void MCELFStreamer::emitBundleAlignMode(Align Alignment) {
+ if (Log2(Alignment) > 30)
+ getContext().reportError(getStartTokLoc(),
+ ".bundle_align_mode alignment must be <= 30");
+ MCAssembler &Assembler = getAssembler();
+ setAllowAutoPadding(true);
+
+ if (Alignment > 1 && (Assembler.getBundleAlignSize() == 0 ||
+ Assembler.getBundleAlignSize() == Alignment.value()))
+ Assembler.setBundleAlignSize(Alignment.value());
+ else
+ getContext().reportError(getStartTokLoc(),
+ ".bundle_align_mode cannot be changed once set");
+}
+
+void MCELFStreamer::emitBundleLock(bool AlignToEnd,
+ const MCSubtargetInfo &STI) {
+ MCSection &Sec = *getCurrentSectionOnly();
+ auto &Asm = getAssembler();
+
+ if (!Asm.isBundlingEnabled()) {
+ getContext().reportError(
+ getStartTokLoc(), ".bundle_lock forbidden when bundling is disabled");
+ return;
+ }
+
+ if (Sec.isBundleLocked()) {
+ getContext().reportError(getStartTokLoc(),
+ "nested .bundle_lock is not allowed");
+ return;
+ }
+ Sec.setIsBundleLocked(true);
+
+ auto AlignBoundary = Asm.getBundleAlignSize();
+ BundleBA =
+ newSpecialFragment<MCBoundaryAlignFragment>(Align(AlignBoundary), STI);
+ BundleBA->setAlignToEnd(AlignToEnd);
+}
+
+void MCELFStreamer::emitBundleUnlock(const MCSubtargetInfo &STI) {
+ MCSection &Sec = *getCurrentSectionOnly();
+
+ if (!getAssembler().isBundlingEnabled()) {
+ getContext().reportError(
+ getStartTokLoc(), ".bundle_unlock forbidden when bundling is disabled");
----------------
MaskRay wrote:
Untested. The lock-side equivalent is covered by `lock-without-mode.s`, but this unlock-side error has no test. Add a `.bundle_unlock` with no preceding `.bundle_align_mode` to `bundle-errors.s`.
https://github.com/llvm/llvm-project/pull/175830
More information about the llvm-commits
mailing list