diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index c7ed73d0e95f7..c54db12379b71 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -791,7 +791,9 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM, setAllExpand(MVT::f32); if (!Subtarget->hasFP64()) setAllExpand(MVT::f64); - } + } else if (TM.Options.FloatABIType == FloatABI::Hard) + errs() << "The hard-float ABI can't be used for a target that " + "doesn't support floating-point (ignoring float-abi)\n"; if (Subtarget->hasFullFP16()) { addRegisterClass(MVT::f16, &ARM::HPRRegClass); diff --git a/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll b/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll new file mode 100644 index 0000000000000..dbbf2f3ef0909 --- /dev/null +++ b/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll @@ -0,0 +1,15 @@ +; RUN: llc -asm-verbose=false --mtriple=armv7-none-eabihf --mattr=+vfp3 < %s | FileCheck %s --check-prefix=CHECK-VFP +; RUN: llc -asm-verbose=false --mtriple=armv7-none-eabi --mattr=-fpregs < %s | FileCheck %s -check-prefix=CHECK-NOVFP +; RUN: llc -asm-verbose=false --mtriple=armv7-none-eabihf --mattr=-fpregs < %s 2>&1 | FileCheck %s -check-prefix=CHECK-ERROR -check-prefix=CHECK-NOVFP + +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32" + +; CHECK-VFP: vadd.f32 +; CHECK-ERROR: The hard-float ABI can't be used for a target that doesn't support floating-point (ignoring float-abi) +; CHECK-NOVFP: bl __aeabi_fadd +define float @test_fadd(float %a, float %b) #0 { + %r = fadd float %a, %b + ret float %r +} + +attributes #0 = { nounwind }