aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CommandFlags.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2019-12-04 14:34:14 +0530
committerMatt Arsenault <Matthew.Arsenault@amd.com>2020-03-27 14:00:39 -0700
commita8cc9047de090352d244c0e1d1db8b4d9b4b7502 (patch)
tree5bb676e63bd04dcaf5d291658d3e6b3ed8d72a9f /llvm/lib/CodeGen/CommandFlags.cpp
parenta6dfd827e588aaa0ef221cd29f846dc88ce2877c (diff)
downloadllvm-a8cc9047de090352d244c0e1d1db8b4d9b4b7502.zip
llvm-a8cc9047de090352d244c0e1d1db8b4d9b4b7502.tar.gz
llvm-a8cc9047de090352d244c0e1d1db8b4d9b4b7502.tar.bz2
CodeGen: Add -denormal-fp-math-f32 flag
Make the set of FP related attributes and command flags closer.
Diffstat (limited to 'llvm/lib/CodeGen/CommandFlags.cpp')
-rw-r--r--llvm/lib/CodeGen/CommandFlags.cpp43
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)