mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[AIX] Don't use a zero fill with a second parameter
Summary: 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. Reviewers: stevewan, sfertile, DiggerLin, jasonliu, Xiangling_L Reviewed By: jasonliu Subscribers: Xiangling_L, wuzish, nemanjai, hiraditya, kbarton, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D73554
This commit is contained in:
parent
53b445b98d
commit
68d4581cd4
@ -171,12 +171,17 @@ protected:
|
||||
|
||||
//===--- Data Emission Directives -------------------------------------===//
|
||||
|
||||
/// This should be set to the directive used to get some number of zero bytes
|
||||
/// emitted to the current section. Common cases are "\t.zero\t" and
|
||||
/// "\t.space\t". If this is set to null, the Data*bitsDirective's will be
|
||||
/// used to emit zero bytes. Defaults to "\t.zero\t"
|
||||
/// This should be set to the directive used to get some number of zero (and
|
||||
/// non-zero if supported by the directive) bytes emitted to the current
|
||||
/// section. Common cases are "\t.zero\t" and "\t.space\t". 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. If this is set to false, the Data*bitsDirective's will be
|
||||
/// used to emit these bytes. 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 +548,9 @@ public:
|
||||
}
|
||||
|
||||
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; }
|
||||
|
@ -1098,16 +1098,27 @@ void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
|
||||
void MCAsmStreamer::emitFill(const MCExpr &NumBytes, uint64_t FillValue,
|
||||
SMLoc Loc) {
|
||||
int64_t IntNumBytes;
|
||||
if (NumBytes.evaluateAsAbsolute(IntNumBytes) && IntNumBytes == 0)
|
||||
const 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 {
|
||||
if (!IsAbsolute)
|
||||
report_fatal_error(
|
||||
"Cannot emit non-absolute expression lengths of fill.");
|
||||
for (int i = 0; i < IntNumBytes; ++i) {
|
||||
OS << MAI->getData8bitsDirective() << (int)FillValue;
|
||||
EmitEOL();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -60,5 +60,6 @@ PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
|
||||
assert(!IsLittleEndian && "Little-endian XCOFF not supported.");
|
||||
CodePointerSize = CalleeSaveStackSlotSize = Is64Bit ? 8 : 4;
|
||||
ZeroDirective = "\t.space\t";
|
||||
ZeroDirectiveSupportsNonZeroValue = false;
|
||||
SymbolsHaveSMC = true;
|
||||
}
|
||||
|
10
test/CodeGen/PowerPC/aix-nonzero-zerofill.ll
Normal file
10
test/CodeGen/PowerPC/aix-nonzero-zerofill.ll
Normal file
@ -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
|
||||
|
||||
@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
|
Loading…
x
Reference in New Issue
Block a user