[PATCH] D131143: [Clang] Interaction of FP pragmas and function template instantiation

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 3 23:30:41 PDT 2022

sepavloff created this revision.
sepavloff added reviewers: rsmith, rjmccall, aaron.ballman, efriedma.
Herald added a subscriber: martong.
Herald added a reviewer: shafik.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: clang.

C standard defines set of pragmas that modify code generation for
operations on floating point values. In C++ code may be obtained using
template instantiation and from practical viewpoint it is necessary to
have possibility to modify code generation in this case as well. This
change implements interaction of FP pragmas with function template

If a function template contains a floating-point control pragma, the
latter is a part of template definition and presents in all
instantiations. If a pragma in placed outside any function it acts on
function templates in the same way as on functions. For the task of
function instantiation such pragma is equivalent to the same pragma put
at the beginning of all affected function bodies.

In the case is explicit instantiation there is apparent connection
between a point in source code and instantiated function. It can
support interaction of pragmas that act in that point. For example, in
the code:

  template float func_05<short>(float, float);

the instantiated function is created with the specified constant
rounding mode. The effect is same as if the template pattern were
textually inserted into the code with needed replacements.

Implicit instantiations occur with FP options deduced from LangOpts.
They have no apparent connection to source code and are not influenced
by FP pragmas.

  rG LLVM Github Monorepo



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131143.449884.patch
Type: text/x-patch
Size: 16539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220804/e7845e0a/attachment-0001.bin>

More information about the cfe-commits mailing list