diff --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp b/clang/lib/Driver/ToolChains/Arch/Mips.cpp index 5a509dbb2bd319498224d40b632f754089531e09..9670c09bc0841930ef66be7be54dba02f73f81d3 100644 --- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp +++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp @@ -466,11 +466,6 @@ bool mips::isFP64ADefault(const llvm::Triple &Triple, StringRef CPUName) { bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName, StringRef ABIName, mips::FloatABI FloatABI) { - if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies && - Triple.getVendor() != llvm::Triple::MipsTechnologies && - !Triple.isAndroid()) - return false; - if (ABIName != "32") return false; diff --git a/clang/test/Driver/mips-as.c b/clang/test/Driver/mips-as.c index cd4808d14ec769228fc01e2ebf86ee64b87a5ff6..f075567119e3474b798e274357b9436f87c38565 100644 --- a/clang/test/Driver/mips-as.c +++ b/clang/test/Driver/mips-as.c @@ -196,7 +196,7 @@ // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-16 %s -// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mips16" +// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mips16" // // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -207,7 +207,7 @@ // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-MICRO %s -// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmicromips" +// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmicromips" // // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -218,7 +218,7 @@ // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-DSP %s -// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdsp" +// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdsp" // // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -229,7 +229,7 @@ // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-DSPR2 %s -// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mdspr2" +// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mdspr2" // // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ @@ -266,7 +266,7 @@ // RUN: %clang -target mips-linux-gnu -mno-msa -mmsa -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-MSA %s -// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mmsa" +// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" "-call_nonpic" "-EB" "-mfpxx" "-mmsa" // // RUN: %clang -target mips-linux-gnu -mmsa -mno-msa -### \ // RUN: -no-integrated-as -c %s 2>&1 \ diff --git a/clang/test/Driver/mips-integrated-as.s b/clang/test/Driver/mips-integrated-as.s index 46ce5b6871f4e95316dc4237eff75d91aa3d7713..e248ba7f77e9143704ed4667520c6b34e1df1e20 100644 --- a/clang/test/Driver/mips-integrated-as.s +++ b/clang/test/Driver/mips-integrated-as.s @@ -160,8 +160,8 @@ // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ // RUN: FileCheck -check-prefix=FPXX-DEFAULT %s // FPXX-DEFAULT: -cc1as -// FPXX-DEFAULT-NOT: "-target-feature" "+fpxx" -// FPXX-DEFAULT-NOT: "-target-feature" "+nooddspreg" +// FPXX-DEFAULT: "-target-feature" "+fpxx" +// FPXX-DEFAULT: "-target-feature" "+nooddspreg" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -mfp32 2>&1 | \ // RUN: FileCheck -check-prefix=FP32 %s @@ -182,7 +182,7 @@ // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \ // RUN: FileCheck -check-prefix=ODDSPREG-DEFAULT %s // ODDSPREG-DEFAULT: -cc1as -// ODDSPREG-DEFAULT-NOT: "-target-feature" "{{[+-]}}nooddspreg" +// ODDSPREG-DEFAULT: "-target-feature" "+nooddspreg" // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s -modd-spreg 2>&1 | \ // RUN: FileCheck -check-prefix=ODDSPREG-ON %s diff --git a/llvm-build/Makefile b/llvm-build/Makefile index c45575a8a9905e295ab5eb03963a11ce54595a5d..9df865b3df64fce8bd864a0f74812f3e0fbc208f 100644 --- a/llvm-build/Makefile +++ b/llvm-build/Makefile @@ -97,7 +97,7 @@ ifeq ($(ARCH),riscv64) CFLAGS = -march=rv64gc -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack else ifeq ($(ARCH),mips) -CFLAGS = -march=mips32r2 -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack +CFLAGS = -march=mips32r2 -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack -mnan=2008 -mfp64 else ifeq ($(ARCH),x86_64) CFLAGS = -march=x86-64 -O2 -Wall -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,relro,-z,now,-z,noexecstack diff --git a/llvm-build/build.py b/llvm-build/build.py index 9df15f4f4921aff5af0968514e50f493ddc4d205..9e5c6c5c3ca19135cd902925b25d8dc155f225fc 100755 --- a/llvm-build/build.py +++ b/llvm-build/build.py @@ -880,7 +880,7 @@ class LlvmLibs(BuildUtils): '-march=armv7-a -mcpu=cortex-a7 -mfloat-abi=hard -mfpu=neon-vfpv4', 'a7_hard_neon-vfpv4'), ('aarch64', self.open_ohos_triple('aarch64'), '', ''), ('riscv64', self.open_ohos_triple('riscv64'), '', ''), - ('mipsel', self.open_ohos_triple('mipsel'), '-march=mips32r2', ''), + ('mipsel', self.open_ohos_triple('mipsel'), '-march=mips32r2 -mnan=2008 -mfp64', ''), ('x86_64', self.open_ohos_triple('x86_64'), '', ''),] cc = os.path.join(llvm_install, 'bin', 'clang') diff --git a/llvm-build/build_musl.sh b/llvm-build/build_musl.sh index d6c3a0add8d5c7630cc59951bf3a9559937402c1..e82261dc3637582c96b2f375de63a56ca7940796 100755 --- a/llvm-build/build_musl.sh +++ b/llvm-build/build_musl.sh @@ -80,7 +80,7 @@ elif [ $TARGET_TRIPLE == "arm-linux-ohos" ]; then elif [ $TARGET_TRIPLE == "mipsel-linux-ohos" ]; then TARGET_USER="linux_user" TARGETS_PREFIX="mips" - CFLAGS_FOR_TARGET=("-march=mips32r2") + CFLAGS_FOR_TARGET=("-march=mips32r2 -mfp64 -mnan=2008") elif [ $TARGET_TRIPLE == "riscv64-linux-ohos" ]; then TARGET_USER="linux_user" TARGETS_PREFIX="riscv64" diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp index b460bc71b11f55f498e6c478617108ebf0f56395..e50ab949f32ab66cad25107a995c75bb554f8bbf 100644 --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -400,6 +400,14 @@ const char *MipsAsmPrinter::getCurrentABIString() const { void MipsAsmPrinter::emitFunctionEntryLabel() { MipsTargetStreamer &TS = getTargetStreamer(); + bool IsO32 = (static_cast(TM)).getABI().IsO32(); + + TS.updateABIInfo(*Subtarget); + if (Subtarget->isNaN2008()) + TS.emitDirectiveNaN2008(); + if ((IsO32 && (Subtarget->isABI_FPXX() || Subtarget->isFP64bit())) || + Subtarget->useSoftFloat()) + TS.emitDirectiveModuleFP(); // NaCl sandboxing requires that indirect call instructions are masked. // This means that function entry points should be bundle-aligned. diff --git a/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll b/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll new file mode 100644 index 0000000000000000000000000000000000000000..f05fc67e0b0f297582c0e40f56c1c3dad72ed9e8 --- /dev/null +++ b/llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll @@ -0,0 +1,13 @@ +; RUN: llc %s -o - | FileCheck %s + +target triple = "mipsel-unknown-linux-gnu" + +define dso_local void @test() #0 { + ret void +} + +attributes #0 = { "target-cpu"="mips32r2" "target-features"="+fp64,+mips32r2,+nan2008" } + + +; CHECK: .nan 2008 +; CHECK: .module fp=64