From a7c18ee8c4a0b0540963c2fe0b7b0a688de9c636 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Thu, 19 Jul 2018 12:44:51 +0000 Subject: [PATCH] ARM: switch armv7em MachO triple to hard-float defaults and libcalls. We were emitting incorrect calls to libm functions that LLVM had decided it knew about because the default is soft-float. Recommitted without breaking ELF this time. llvm-svn: 337450 --- llvm/lib/Target/ARM/ARMTargetMachine.h | 2 ++ llvm/test/CodeGen/ARM/darwin-eabi.ll | 2 +- llvm/test/CodeGen/ARM/macho-embedded-float.ll | 37 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/ARM/macho-embedded-float.ll diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.h b/llvm/lib/Target/ARM/ARMTargetMachine.h index 811fd5b..2c791998 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.h +++ b/llvm/lib/Target/ARM/ARMTargetMachine.h @@ -66,6 +66,8 @@ public: return TargetTriple.getEnvironment() == Triple::GNUEABIHF || TargetTriple.getEnvironment() == Triple::MuslEABIHF || TargetTriple.getEnvironment() == Triple::EABIHF || + (TargetTriple.isOSBinFormatMachO() && + TargetTriple.getSubArch() == Triple::ARMSubArch_v7em) || TargetTriple.isOSWindows() || TargetABI == ARMBaseTargetMachine::ARM_ABI_AAPCS16; } diff --git a/llvm/test/CodeGen/ARM/darwin-eabi.ll b/llvm/test/CodeGen/ARM/darwin-eabi.ll index 5301c0b..5329f389 100644 --- a/llvm/test/CodeGen/ARM/darwin-eabi.ll +++ b/llvm/test/CodeGen/ARM/darwin-eabi.ll @@ -20,5 +20,5 @@ define double @double_op(double %lhs, double %rhs) { ; CHECK-M3: bl ___adddf3 ; CHECK-M4-LABEL: double_op: -; CHECK-M4: {{(blx|b.w)}} ___adddf3 +; CHECK-M4: {{(bl|blx|b.w)}} ___adddf3 } diff --git a/llvm/test/CodeGen/ARM/macho-embedded-float.ll b/llvm/test/CodeGen/ARM/macho-embedded-float.ll new file mode 100644 index 0000000..c66324c --- /dev/null +++ b/llvm/test/CodeGen/ARM/macho-embedded-float.ll @@ -0,0 +1,37 @@ +; RUN: llc -mtriple=thumbv7em-none-macho %s -o - -mcpu=cortex-m4 | FileCheck --check-prefix=CHECK-HARD %s +; RUN: llc -mtriple=thumbv7m-none-macho %s -o - -mcpu=cortex-m4 | FileCheck --check-prefix=CHECK-SOFT %s +; RUN: llc -mtriple=thumbv7em-linux-gnueabi %s -o - -mcpu=cortex-m4 | FileCheck --check-prefix=CHECK-SOFT %s + +define float @test_default_cc(float %a, float %b) { +; CHECK-HARD-LABEL: test_default_cc: +; CHECK-HARD-NOT: vmov +; CHECK-HARD: vadd.f32 s0, s0, s1 +; CHECK-HARD-NOT: vmov + +; CHECK-SOFT-LABEL: test_default_cc: +; CHECK-SOFT-DAG: vmov [[A:s[0-9]+]], r0 +; CHECK-SOFT-DAG: vmov [[B:s[0-9]+]], r1 +; CHECK-SOFT: vadd.f32 [[RES:s[0-9]+]], [[A]], [[B]] +; CEHCK-SOFT: vmov r0, [[RES]] + + %res = fadd float %a, %b + ret float %res +} + + +define arm_aapcs_vfpcc float @test_libcall(float %in) { +; CHECK-HARD-LABEL: test_libcall: +; CHECK-HARD-NOT: vmov +; CHECK-HARD: b.w _sinf + +; CHECK-SOFT-LABEL: test_libcall: +; CHECK-SOFT: vmov r0, s0 +; CHECK-SOFT: bl {{_?}}sinf +; CHECK-SOFT: vmov s0, r0 + + %res = call float @llvm.sin.f32(float %in) + ret float %res +} + + +declare float @llvm.sin.f32(float) -- 2.7.4