Skip to content

Commit 25b6e82

Browse files
committed
Merging r354882:
------------------------------------------------------------------------ r354882 | atanasyan | 2019-02-26 06:45:17 -0800 (Tue, 26 Feb 2019) | 4 lines [mips] Emit `.module softfloat` directive This change fixes crash on an assertion in case of using `soft float` ABI for mips32r6 target. ------------------------------------------------------------------------ llvm-svn: 358934
1 parent 257c010 commit 25b6e82

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

llvm/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,11 @@ void MipsTargetAsmStreamer::emitDirectiveCpreturn(unsigned SaveLocation,
700700
}
701701

702702
void MipsTargetAsmStreamer::emitDirectiveModuleFP() {
703-
OS << "\t.module\tfp=";
704-
OS << ABIFlagsSection.getFpABIString(ABIFlagsSection.getFpABI()) << "\n";
703+
MipsABIFlagsSection::FpABIKind FpABI = ABIFlagsSection.getFpABI();
704+
if (FpABI == MipsABIFlagsSection::FpABIKind::SOFT)
705+
OS << "\t.module\tsoftfloat\n";
706+
else
707+
OS << "\t.module\tfp=" << ABIFlagsSection.getFpABIString(FpABI) << "\n";
705708
}
706709

707710
void MipsTargetAsmStreamer::emitDirectiveSetFp(

llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ void MipsAsmPrinter::EmitStartOfAsmFile(Module &M) {
813813
// We should always emit a '.module fp=...' but binutils 2.24 does not accept
814814
// it. We therefore emit it when it contradicts the ABI defaults (-mfpxx or
815815
// -mfp64) and omit it otherwise.
816-
if (ABI.IsO32() && (STI.isABI_FPXX() || STI.isFP64bit()))
816+
if ((ABI.IsO32() && (STI.isABI_FPXX() || STI.isFP64bit())) ||
817+
STI.useSoftFloat())
817818
TS.emitDirectiveModuleFP();
818819

819820
// We should always emit a '.module [no]oddspreg' but binutils 2.24 does not

llvm/test/CodeGen/Mips/abiflags32.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 %s -o - | FileCheck %s
22
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 -mattr=fp64 %s -o - | FileCheck -check-prefix=CHECK-64 %s
33
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips64 -target-abi n32 %s -o - | FileCheck -check-prefix=CHECK-64n %s
4+
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32 \
5+
; RUN: -mattr=soft-float %s -o - | FileCheck -check-prefix=SOFT %s
6+
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips32r6 \
7+
; RUN: -mattr=soft-float %s -o - | FileCheck -check-prefix=SOFT %s
8+
; RUN: llc -filetype=asm -mtriple mipsel-unknown-linux -mcpu=mips64 \
9+
; RUN: -mattr=soft-float -target-abi n64 %s -o - | FileCheck -check-prefix=SOFT %s
410

511
; CHECK: .nan legacy
612
; We don't emit '.module fp=32' for compatibility with binutils 2.24 which
@@ -15,3 +21,5 @@
1521
; We don't emit '.module fp=64' for compatibility with binutils 2.24 which
1622
; doesn't accept .module.
1723
; CHECK-64n-NOT: .module fp=64
24+
25+
; SOFT: .module softfloat

0 commit comments

Comments
 (0)