[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
Tue Jan 28 07:27:00 PST 2020
daltenty created this revision.
Herald added subscribers: llvm-commits, jsji, kbarton, hiraditya, nemanjai.
Herald added a project: LLVM.
daltenty updated this revision to Diff 240879.
daltenty added a comment.
Herald added a subscriber: wuzish.
- Remove include addition
The AIX assembler .space directive can't take a second non-zero argument to fill
with. But LLVM emitFill currently assumes it can. We add a flag to the AsmInfo
to check if non-zero fill is supported, and if we can't zerofill non-zero values
we just splat the .byte directives.
Repository:
rG LLVM Github Monorepo
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,6 @@
+; 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
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
@@ -1102,12 +1102,24 @@
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->getZeroDirectiveSupportsNonZeroValue() || FillValue == 0) {
+ // FIXME: Emit location directives
+ OS << ZeroDirective;
+ NumBytes.print(OS, MAI);
+ if (FillValue != 0)
+ OS << ',' << (int)FillValue;
+ EmitEOL();
+ } else {
+ assert(isa<MCConstantExpr>(NumBytes) && "Cannot emit non-constant "
+ "expression lengths of "
+ "fill.");
+ for (int i = 0; i < cast<MCConstantExpr>(NumBytes).getValue(); i++) {
+ OS << "\t.byte\t";
+ NumBytes.print(OS, MAI);
+ 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 getZeroDirectiveSupportsNonZeroValue() 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.240879.patch
Type: text/x-patch
Size: 3227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200128/d4848c36/attachment.bin>
More information about the llvm-commits
mailing list