aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorMelanie Blower <melanie.blower@intel.com>2021-07-20 16:01:51 -0400
committerMelanie Blower <melanie.blower@intel.com>2021-07-20 16:02:09 -0400
commitce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7 (patch)
tree2df5effec4c76736b2c1eb5b2ca9a2211bffed92 /clang/lib/Sema/Sema.cpp
parent6bf0f6a4f7d976a54ff59de4ef1c543ad2df9ff0 (diff)
downloadllvm-ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7.zip
llvm-ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7.tar.gz
llvm-ce8024e8ff76e7be8b9ffa1a39d1dc9310bf74c7.tar.bz2
[CLANG][PATCH][FPEnv] Add support for option -ffp-eval-method and extend #pragma float_control similarly
The Intel compiler ICC supports the option "-fp-model=(source|double|extended)" which causes the compiler to use a wider type for intermediate floating point calculations. Also supported is a way to embed this effect in the source program with #pragma float_control(source|double|extended). This patch extends pragma float_control syntax, and also adds support for a new floating point option "-ffp-eval-method=(source|double|extended)". source: intermediate results use source precision double: intermediate results use double precision extended: intermediate results use extended precision Reviewed By: Aaron Ballman Differential Revision: https://reviews.llvm.org/D93769
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r--clang/lib/Sema/Sema.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp
index 704b631..2df4004 100644
--- a/clang/lib/Sema/Sema.cpp
+++ b/clang/lib/Sema/Sema.cpp
@@ -212,6 +212,12 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
SemaPPCallbackHandler = Callbacks.get();
PP.addPPCallbacks(std::move(Callbacks));
SemaPPCallbackHandler->set(*this);
+ if (getLangOpts().getFPEvalMethod() == LangOptions::FEM_TargetDefault)
+ // Use setting from TargetInfo.
+ PP.setCurrentFPEvalMethod(ctxt.getTargetInfo().getFPEvalMethod());
+ else
+ // Set initial value of __FLT_EVAL_METHOD__ from the command line.
+ PP.setCurrentFPEvalMethod(getLangOpts().getFPEvalMethod());
}
// Anchor Sema's type info to this TU.
@@ -2493,3 +2499,14 @@ const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
Sema::getMismatchingDeleteExpressions() const {
return DeleteExprs;
}
+
+Sema::FPFeaturesStateRAII::FPFeaturesStateRAII(Sema &S)
+ : S(S), OldFPFeaturesState(S.CurFPFeatures),
+ OldOverrides(S.FpPragmaStack.CurrentValue),
+ OldEvalMethod(S.PP.getCurrentFPEvalMethod()) {}
+
+Sema::FPFeaturesStateRAII::~FPFeaturesStateRAII() {
+ S.CurFPFeatures = OldFPFeaturesState;
+ S.FpPragmaStack.CurrentValue = OldOverrides;
+ S.PP.setCurrentFPEvalMethod(OldEvalMethod);
+}