Page MenuHomePhabricator

RFC [clang] Add support for option -ffp-eval-method and extend #pragma float_control similarly
Needs ReviewPublic

Authored by mibintc on Wed, Dec 23, 9:50 AM.

Details

Summary

The Intel compiler 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 proposes to extend pragma float_control syntax, and also to support a new floating point option via "-ffp-eval-method=(source|double|extended)"

Note that the C floating point working group has proposed nearly identical pragma semantics in http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1974.pdf like this
#pragma STDC FENV_FLT_EVAL_METHOD width
I would like to add support for this also, but it's not in this patch.

I'm going to add an inline question about how to redefine FLT_EVAL_METHOD macro

The ICL option with description of semantics is at this url, https://software.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/compiler-options/compiler-option-details/floating-point-options/fp-model-fp.html

Diff Detail

Event Timeline

mibintc created this revision.Wed, Dec 23, 9:50 AM
mibintc requested review of this revision.Wed, Dec 23, 9:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptWed, Dec 23, 9:50 AM
mibintc edited the summary of this revision. (Show Details)Wed, Dec 23, 9:51 AM
mibintc edited the summary of this revision. (Show Details)
mibintc added inline comments.Wed, Dec 23, 10:00 AM
clang/lib/Sema/SemaAttr.cpp
429

@rjmccall I would like to push a new value for FLT_EVAL_METHOD at the start of the scope of this pragma, then pop that value of the macro to restore the previous setting when the scope is exited, should I do that in ParsePragma? Can I do that by injecting "pragma push_macro(...)" into the token stream, do you have other suggestion or is there something similar in clang that I can study how to do this?

@rjmccall Hoping you can take a look at this patch