mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-02 07:17:36 +00:00
Emit Tag_ABI_FP_denormal correctly in fast-math mode.
The default ARM floating-point mode does not support IEEE 754 mode exactly. Of
relevance to this patch is that input denormals are flushed to zero. The way in
which they're flushed to zero depends on the architecture,
* For VFPv2, it is implementation defined as to whether the sign of zero is
preserved.
* For VFPv3 and above, the sign of zero is always preserved when a denormal
is flushed to zero.
When FP support has been disabled, the strategy taken by this patch is to
assume the software support will mirror the behaviour of the hardware support
for the target *if it existed*. That is, for architectures which can only have
VFPv2, it is assumed the software will flush to positive zero. For later
architectures it is assumed the software will flush to zero preserving sign.
Change-Id: Icc5928633ba222a4ba3ca8c0df44a440445865fd
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -694,9 +694,34 @@ void ARMAsmPrinter::emitAttributes() {
|
||||
|
||||
// Signal various FP modes.
|
||||
if (!TM.Options.UnsafeFPMath) {
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal, ARMBuildAttrs::Allowed);
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
||||
ARMBuildAttrs::IEEEDenormals);
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_exceptions,
|
||||
ARMBuildAttrs::Allowed);
|
||||
} else {
|
||||
if (!Subtarget->hasVFP2()) {
|
||||
// When the target doesn't have an FPU (by design or
|
||||
// intention), the assumptions made on the software support
|
||||
// mirror that of the equivalent hardware support *if it
|
||||
// existed*. For v7 and better we indicate that denormals are
|
||||
// flushed preserving sign, and for V6 we indicate that
|
||||
// denormals are flushed to positive zero.
|
||||
if (Subtarget->hasV7Ops())
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
||||
ARMBuildAttrs::PreserveFPSign);
|
||||
} else if (Subtarget->hasVFP3()) {
|
||||
// In VFPv4, VFPv4U, VFPv3, or VFPv3U, it is preserved. That is,
|
||||
// the sign bit of the zero matches the sign bit of the input or
|
||||
// result that is being flushed to zero.
|
||||
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_denormal,
|
||||
ARMBuildAttrs::PreserveFPSign);
|
||||
}
|
||||
// For VFPv2 implementations it is implementation defined as
|
||||
// to whether denormals are flushed to positive zero or to
|
||||
// whatever the sign of zero is (ARM v7AR ARM 2.7.5). Historically
|
||||
// LLVM has chosen to flush this to positive zero (most likely for
|
||||
// GCC compatibility), so that's the chosen value here (the
|
||||
// absence of its emission implies zero).
|
||||
}
|
||||
|
||||
if (TM.Options.NoInfsFPMath && TM.Options.NoNaNsFPMath)
|
||||
|
||||
Reference in New Issue
Block a user