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
This commit is contained in:
Lang Hames
2012-07-06 00:59:19 +00:00
parent c7ac1bb94c
commit aa53b936ec
8 changed files with 72 additions and 0 deletions

View File

@@ -759,6 +759,11 @@ static void LangOptsToArgs(const LangOptions &Opts, ToArgsList &Res) {
Res.push_back("-ftrapv-handler", Opts.OverflowHandler);
break;
}
switch (Opts.getFPContractMode()) {
case LangOptions::FPC_Off: Res.push_back("-ffp-contract=off"); break;
case LangOptions::FPC_On: Res.push_back("-ffp-contract=on"); break;
case LangOptions::FPC_Fast: Res.push_back("-ffp-contract=fast"); break;
}
if (Opts.HeinousExtensions)
Res.push_back("-fheinous-gnu-extensions");
// Optimize is implicit.
@@ -1975,6 +1980,18 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
Diags.Report(diag::err_drv_invalid_value)
<< Args.getLastArg(OPT_fvisibility)->getAsString(Args) << Vis;
if (Arg *A = Args.getLastArg(OPT_ffp_contract)) {
StringRef Val = A->getValue(Args);
if (Val == "fast")
Opts.setFPContractMode(LangOptions::FPC_Fast);
else if (Val == "on")
Opts.setFPContractMode(LangOptions::FPC_On);
else if (Val == "off")
Opts.setFPContractMode(LangOptions::FPC_Off);
else
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Val;
}
if (Args.hasArg(OPT_fvisibility_inlines_hidden))
Opts.InlineVisibilityHidden = 1;