Open kito-cheng opened 5 years ago
My intuition is using HasLegalHalfType to determine the value of FLT_EVAL_METHOD like gcc, but HasLegalHalfType is always true for AArch64, so it's mis-match with GCC, GCC only define that to 16 on certain CPU/arch.
diff --git a/clang/lib/Basic/Targets/AArch64.h b/clang/lib/Basic/Targets/AArch64.h index b6aa07780ed..1fdc1db26fd 100644 --- a/clang/lib/Basic/Targets/AArch64.h +++ b/clang/lib/Basic/Targets/AArch64.h @@ -97,6 +97,10 @@ public: }
int getEHDataRegisterNumber(unsigned RegNo) const override; +
} };
class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo {
Extended Description
$ aarch64-elf-gcc -mcpu=cortex-a55 -dM -E - < /dev/null | grep FLT_EVAL_METHOD
define FLT_EVAL_METHOD 16
$ clang -target aarch64-elf -mcpu=cortex-a55 -dM -E - < /dev/null | grep FLT_EVAL_METHOD
define FLT_EVAL_METHOD 0
GCC will check fp16 is supported or not to decide the value of FLT_EVAL_METHOD:
static enum flt_eval_method aarch64_excess_precision (enum excess_precision_type type) { switch (type) { case EXCESS_PRECISION_TYPE_FAST: case EXCESS_PRECISION_TYPE_STANDARD: / We can calculate either in 16-bit range and precision or 32-bit range and precision. Make that decision based on whether we have native support for the ARMv8.2-A 16-bit floating-point instructions or not. / return (TARGET_FP_F16INST ? FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16 : FLT_EVAL_METHOD_PROMOTE_TO_FLOAT); case EXCESS_PRECISION_TYPE_IMPLICIT: return FLT_EVAL_METHOD_PROMOTE_TO_FLOAT16; default: gcc_unreachable (); } return FLT_EVAL_METHOD_UNPREDICTABLE; }
But clang/LLVM for AArch64 seems like didn't override TargetInfo::getFloatEvalMethod().