[ARM][Driver] Warn if -mhard-float is incompatible
authorMichael Platings <michael.platings@arm.com>
Mon, 22 May 2023 13:48:00 +0000 (14:48 +0100)
committerMichael Platings <michael.platings@arm.com>
Tue, 6 Jun 2023 10:39:19 +0000 (11:39 +0100)
commit28ba4b23177e90fa94c88f0bd9a99eb46dbc82c3
tree8372094832603f70593ee8ced37a8649ab2b5458
parent60b8019ea0dcf6fafeb3b89121f062f55bc5ee6c
[ARM][Driver] Warn if -mhard-float is incompatible

Mixing -mfloat-abi=hard with a CPU that doesn't have floating point
registers is an error in GCC:
  cc1: error: '-mfloat-abi=hard': selected processor lacks an FPU

Since there is code in the wild (including in clang tests) that relies
on Clang's current behaviour, emit a warning instead of an error.

Unlike the GCC error, the new warning refers to floating point
registers instead of an FPU. This is because -mfloat-abi=hard and
-march=armv8.1-m.main+mve+nofp are compatible - in that case floating
point registers are required, but an FPU is not required.

My initial thought was to use the floating point ABI calculated by
arm::getARMFloatABI() but in invalid cases which error for other
reasons the ABI is miscalculated and the warning would cause confusion.
Therefore only warn if the user specifies the float ABI explicitly.

Fixes part of https://github.com/llvm/llvm-project/issues/55755

Differential Revision: https://reviews.llvm.org/D150902
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/arm-no-float-regs.c [new file with mode: 0644]