[llvm] [SystemZ][z/OS] Emit alignment in HLASM syntax (PR #222121)

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 06:59:34 PDT 2026


================
@@ -310,30 +281,77 @@ void SystemZHLASMAsmStreamer::EmitComment() {
   CommentToEmit.clear();
 }
 
+void SystemZHLASMAsmStreamer::flushPendingAlignment() {
+  if (!PendingAlignSuffix)
+    return;
+  OS << " DS 0" << *PendingAlignSuffix;
+  EmitEOL();
+  PendingAlignSuffix.reset();
+}
+
 void SystemZHLASMAsmStreamer::emitValueToAlignment(Align Alignment,
                                                    int64_t Fill,
                                                    uint8_t FillLen,
                                                    unsigned MaxBytesToEmit) {
-  emitAlignmentDS(Alignment.value(), Fill, FillLen, MaxBytesToEmit);
+  unsigned int A = Log2(Alignment);
+  if (A > 12)
+    return getContext().reportError(SMLoc(), "Alignment > 4096 not supported");
+  if (FillLen > 1)
+    return getContext().reportError(SMLoc(), "Fill length > 1 not supported");
+  if (Fill == 0 && A < 5) {
+    // Simple form: defer so the next emitLabel() can absorb it (e.g. "foo DS
+    // 0H" instead of a standalone "DS 0H" followed by "foo DS 0B").
+    flushPendingAlignment();
+    static const char SUFFIX[5] = {'B', 'H', 'F', 'D', 'Q'};
+    PendingAlignSuffix = SUFFIX[A];
+  } else if (A) {
----------------
uweigand wrote:

As long as have `flushPendingAlignment`, don't we need it here too?

https://github.com/llvm/llvm-project/pull/222121


More information about the llvm-commits mailing list