diff options
author | Lang Hames <lhames@gmail.com> | 2012-07-06 00:59:19 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2012-07-06 00:59:19 +0000 |
commit | aa53b936ec70f2b1adeb7ac9a698fa99ff9622bc (patch) | |
tree | 013a18364576a887f4310f6e554750e400900db2 /clang/lib/Driver/Tools.cpp | |
parent | c7ac1bb94cb7530e5087a6272d8aa3fcb6a5faf3 (diff) | |
download | bcm5719-llvm-aa53b936ec70f2b1adeb7ac9a698fa99ff9622bc.tar.gz bcm5719-llvm-aa53b936ec70f2b1adeb7ac9a698fa99ff9622bc.zip |
Add -ffp-contract = { fast | on | off } command line option support.
This flag sets the 'fp-contract' mode, which controls the formation of fused
floating point operations. Available modes are:
- Fast: Form fused operations anywhere.
- On: Form fused operations where allowed by FP_CONTRACT. This is the default
mode.
- Off: Don't form fused operations (in future this may be relaxed to forming
fused operations where it can be proved that the result won't be
affected).
Currently clang doesn't support the FP_CONTRACT pragma, so the 'On' and 'Off'
modes are equivalent.
llvm-svn: 159794
Diffstat (limited to 'clang/lib/Driver/Tools.cpp')
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index 98beb2234a7..dd198a1e9d8 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -1805,6 +1805,24 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, !TrappingMath) CmdArgs.push_back("-menable-unsafe-fp-math"); + + // Validate and pass through -fp-contract option. + if (Arg *A = Args.getLastArg(options::OPT_ffast_math, + options::OPT_ffp_contract)) { + if (A->getOption().getID() == options::OPT_ffp_contract) { + StringRef Val = A->getValue(Args); + if (Val == "fast" || Val == "on" || Val == "off") { + CmdArgs.push_back(Args.MakeArgString("-ffp-contract=" + Val)); + } else { + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << Val; + } + } else { // A is OPT_ffast_math + // If fast-math is set then set the fp-contract mode to fast. + CmdArgs.push_back(Args.MakeArgString("-ffp-contract=fast")); + } + } + // We separately look for the '-ffast-math' flag, and if we find it, tell the // frontend to provide the appropriate preprocessor macros. This is distinct // from enabling any optimizations as it induces a language change which must |