[PATCH] D73554: [AIX] Don't use a zero fill with a second parameter

David Tenty via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 09:10:08 PST 2020


daltenty updated this revision to Diff 241484.
daltenty added a comment.

- Use IntNumBytes to get the length of fill


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73554/new/

https://reviews.llvm.org/D73554

Files:
  llvm/include/llvm/MC/MCAsmInfo.h
  llvm/lib/MC/MCAsmStreamer.cpp
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
  llvm/test/CodeGen/PowerPC/aix-nonzero-zerofill.ll


Index: llvm/test/CodeGen/PowerPC/aix-nonzero-zerofill.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/aix-nonzero-zerofill.ll
@@ -0,0 +1,10 @@
+; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s
+; RUN: llc -verify-machineinstrs -O0 -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s
+
+ at a = constant [4 x i8] c"\02\02\02\02", align 1
+
+; CHECK-NOT:  .space  4,2
+; CHECK:      .byte   2
+; CHECK-NEXT: .byte   2
+; CHECK-NEXT: .byte   2
+; CHECK-NEXT: .byte   2
Index: llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
+++ llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp
@@ -60,5 +60,6 @@
   assert(!IsLittleEndian && "Little-endian XCOFF not supported.");
   CodePointerSize = CalleeSaveStackSlotSize = Is64Bit ? 8 : 4;
   ZeroDirective = "\t.space\t";
+  ZeroDirectiveSupportsNonZeroValue = false;
   SymbolsHaveSMC = true;
 }
Index: llvm/lib/MC/MCAsmStreamer.cpp
===================================================================
--- llvm/lib/MC/MCAsmStreamer.cpp
+++ llvm/lib/MC/MCAsmStreamer.cpp
@@ -1098,16 +1098,27 @@
 void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
                              SMLoc Loc) {
   int64_t IntNumBytes;
-  if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
+  bool IsAbsolute = NumBytes.evaluateAsAbsolute(IntNumBytes);
+  if (IsAbsolute && IntNumBytes == 0)
     return;
 
   if (const char *ZeroDirective = MAI->getZeroDirective()) {
-    // FIXME: Emit location directives
-    OS << ZeroDirective;
-    NumBytes.print(OS, MAI);
-    if (FillValue != 0)
-      OS << ',' << (int)FillValue;
-    EmitEOL();
+    if (MAI->doesZeroDirectiveSupportNonZeroValue() || FillValue == 0) {
+      // FIXME: Emit location directives
+      OS << ZeroDirective;
+      NumBytes.print(OS, MAI);
+      if (FillValue != 0)
+        OS << ',' << (int)FillValue;
+      EmitEOL();
+    } else {
+      assert(IsAbsolute &&
+             "Cannot emit non-absolute expression lengths of fill.");
+      for (int i = 0; i < IntNumBytes; i++) {
+        OS << "\t.byte\t";
+        OS << (int)FillValue;
+        EmitEOL();
+      }
+    }
     return;
   }
 
Index: llvm/include/llvm/MC/MCAsmInfo.h
===================================================================
--- llvm/include/llvm/MC/MCAsmInfo.h
+++ llvm/include/llvm/MC/MCAsmInfo.h
@@ -177,6 +177,10 @@
   /// used to emit zero bytes.  Defaults to "\t.zero\t"
   const char *ZeroDirective;
 
+  /// This should be set to true if the zero directive supports a value to emit
+  /// other than zero. Defaults to true.
+  bool ZeroDirectiveSupportsNonZeroValue = true;
+
   /// This directive allows emission of an ascii string with the standard C
   /// escape characters embedded into it.  If a target doesn't support this, it
   /// can be set to null. Defaults to "\t.ascii\t"
@@ -543,6 +547,9 @@
   }
 
   const char *getZeroDirective() const { return ZeroDirective; }
+  bool doesZeroDirectiveSupportNonZeroValue() const {
+    return ZeroDirectiveSupportsNonZeroValue;
+  }
   const char *getAsciiDirective() const { return AsciiDirective; }
   const char *getAscizDirective() const { return AscizDirective; }
   bool getAlignmentIsInBytes() const { return AlignmentIsInBytes; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73554.241484.patch
Type: text/x-patch
Size: 3470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200130/f7c0b90c/attachment.bin>


More information about the llvm-commits mailing list