diff options
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CommandFlags.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp index d1540af..12fc1df 100644 --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -55,6 +55,7 @@ CGOPT(bool, EnableNoNaNsFPMath) CGOPT(bool, EnableNoSignedZerosFPMath) CGOPT(bool, EnableNoTrappingFPMath) CGOPT(DenormalMode::DenormalModeKind, DenormalFPMath) +CGOPT(DenormalMode::DenormalModeKind, DenormalFP32Math) CGOPT(bool, EnableHonorSignDependentRoundingFPMath) CGOPT(FloatABI::ABIType, FloatABIForCalls) CGOPT(FPOpFusion::FPOpFusionMode, FuseFPOps) @@ -212,20 +213,30 @@ codegen::RegisterCodeGenFlags::RegisterCodeGenFlags() { cl::init(false)); CGBINDOPT(EnableNoTrappingFPMath); + static const auto DenormFlagEnumOptions = + cl::values(clEnumValN(DenormalMode::IEEE, "ieee", + "IEEE 754 denormal numbers"), + clEnumValN(DenormalMode::PreserveSign, "preserve-sign", + "the sign of a flushed-to-zero number is preserved " + "in the sign of 0"), + clEnumValN(DenormalMode::PositiveZero, "positive-zero", + "denormals are flushed to positive zero")); + + // FIXME: Doesn't have way to specify separate input and output modes. static cl::opt<DenormalMode::DenormalModeKind> DenormalFPMath( - "denormal-fp-math", - cl::desc( - "Select which denormal numbers the code is permitted to require"), - cl::init(DenormalMode::IEEE), - cl::values( - clEnumValN(DenormalMode::IEEE, "ieee", "IEEE 754 denormal numbers"), - clEnumValN(DenormalMode::PreserveSign, "preserve-sign", - "the sign of a flushed-to-zero number is preserved " - "in the sign of 0"), - clEnumValN(DenormalMode::PositiveZero, "positive-zero", - "denormals are flushed to positive zero"))); + "denormal-fp-math", + cl::desc("Select which denormal numbers the code is permitted to require"), + cl::init(DenormalMode::IEEE), + DenormFlagEnumOptions); CGBINDOPT(DenormalFPMath); + static cl::opt<DenormalMode::DenormalModeKind> DenormalFP32Math( + "denormal-fp-math-f32", + cl::desc("Select which denormal numbers the code is permitted to require for float"), + cl::init(DenormalMode::Invalid), + DenormFlagEnumOptions); + CGBINDOPT(DenormalFP32Math); + static cl::opt<bool> EnableHonorSignDependentRoundingFPMath( "enable-sign-dependent-rounding-fp-math", cl::Hidden, cl::desc("Force codegen to assume rounding mode can change dynamically"), @@ -577,6 +588,16 @@ void codegen::setFunctionAttributes(StringRef CPU, StringRef Features, DenormalMode(DenormKind, DenormKind).str()); } + if (DenormalFP32MathView->getNumOccurrences() > 0 && + !F.hasFnAttribute("denormal-fp-math-f32")) { + // FIXME: Command line flag should expose separate input/output modes. + DenormalMode::DenormalModeKind DenormKind = getDenormalFP32Math(); + + NewAttrs.addAttribute( + "denormal-fp-math-f32", + DenormalMode(DenormKind, DenormKind).str()); + } + if (TrapFuncNameView->getNumOccurrences() > 0) for (auto &B : F) for (auto &I : B) |