diff options
author | Melanie Blower <melanie.blower@intel.com> | 2019-11-05 13:41:21 -0800 |
---|---|---|
committer | Melanie Blower <melanie.blower@intel.com> | 2019-11-07 07:22:45 -0800 |
commit | af57dbf12e54f3a8ff48534bf1078f4de104c1cd (patch) | |
tree | c5ae577882a5e6750c379d1735cdc423b88ce83c /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | de61aa3118b9bac85c468ea7ec40604a086744f5 (diff) | |
download | bcm5719-llvm-af57dbf12e54f3a8ff48534bf1078f4de104c1cd.tar.gz bcm5719-llvm-af57dbf12e54f3a8ff48534bf1078f4de104c1cd.zip |
Add support for options -frounding-math, ftrapping-math, -ffp-model=, and -ffp-exception-behavior=
Add options to control floating point behavior: trapping and
exception behavior, rounding, and control of optimizations that affect
floating point calculations. More details in UsersManual.rst.
Reviewers: rjmccall
Differential Revision: https://reviews.llvm.org/D62731
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 46a7e39770a..195a29d7118 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -3129,6 +3129,36 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val; } + if (Args.hasArg(OPT_frounding_math)) { + Opts.setFPRoundingMode(LangOptions::FPR_Dynamic); + } + + if (Args.hasArg(OPT_fno_rounding_math)) { + Opts.setFPRoundingMode(LangOptions::FPR_ToNearest); + } + + if (Args.hasArg(OPT_ftrapping_math)) { + Opts.setFPExceptionMode(LangOptions::FPE_Strict); + } + + if (Args.hasArg(OPT_fno_trapping_math)) { + Opts.setFPExceptionMode(LangOptions::FPE_Ignore); + } + + LangOptions::FPExceptionModeKind FPEB = LangOptions::FPE_Ignore; + if (Arg *A = Args.getLastArg(OPT_ffp_exception_behavior_EQ)) { + StringRef Val = A->getValue(); + if (Val.equals("ignore")) + FPEB = LangOptions::FPE_Ignore; + else if (Val.equals("maytrap")) + FPEB = LangOptions::FPE_MayTrap; + else if (Val.equals("strict")) + FPEB = LangOptions::FPE_Strict; + else + Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val; + Opts.setFPExceptionMode(FPEB); + } + Opts.RetainCommentsFromSystemHeaders = Args.hasArg(OPT_fretain_comments_from_system_headers); |