llvm-project/clang/lib/Basic
Serge Pavlov f7819ce166 [FPEnv] Allow CompoundStmt to keep FP options
This is a recommit of b822efc740,
reverted in dc34d8df4c. The commit caused
fails because the test ast-print-fp-pragmas.c did not specify particular
target, and it failed on targets which do not support constrained
intrinsics. The original commit message is below.

AST does not have special nodes for pragmas. Instead a pragma modifies
some state variables of Sema, which in turn results in modified
attributes of AST nodes. This technique applies to floating point
operations as well. Every AST node that can depend on FP options keeps
current set of them.

This technique works well for options like exception behavior or fast
math options. They represent instructions to the compiler how to modify
code generation for the affected nodes. However treatment of FP control
modes has problems with this technique. Modifying FP control mode
(like rounding direction) usually requires operations on hardware, like
writing to control registers. It must be done prior to the first
operation that depends on the control mode. In particular, such
operations are required for implementation of `pragma STDC FENV_ROUND`,
compiler should set up necessary rounding direction at the beginning of
compound statement where the pragma occurs. As there is no representation
for pragmas in AST, the code generation becomes a complicated task in
this case.

To solve this issue FP options are kept inside CompoundStmt. Unlike to FP
options in expressions, these does not affect any operation on FP values,
but only inform the codegen about the FP options that act in the body of
the statement. As all pragmas that modify FP environment may occurs only
at the start of compound statement or at global level, such solution
works for all relevant pragmas. The options are kept as a difference
from the options in the enclosing compound statement or default options,
it helps codegen to set only changed control modes.

Differential Revision: https://reviews.llvm.org/D123952
2022-07-03 17:06:26 +07:00
..
Targets [X86] Support `_Float16` on SSE2 and up 2022-06-30 17:21:37 +08:00
Attributes.cpp [Attributes] Remove AttrSyntax and migrate uses to AttributeCommonInfo::Syntax (NFC) 2022-06-03 12:11:48 -04:00
BuiltinTargetFeatures.h [clang] Fix __has_builtin 2022-05-19 11:34:42 -04:00
Builtins.cpp [clang] Fix __has_builtin 2022-05-19 11:34:42 -04:00
CLWarnings.cpp Reland "[clang-cl] Accept `#pragma warning(disable : N)` for some N" 2021-09-30 15:03:23 -04:00
CMakeLists.txt Revert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface" 2022-06-30 13:39:47 -04:00
CharInfo.cpp
CodeGenOptions.cpp [NFC] Remove duplicate isNoBuiltinFunc method 2021-03-10 09:18:55 +01:00
Cuda.cpp [clang] Use value_or instead of getValueOr (NFC) 2022-06-18 23:21:34 -07:00
DarwinSDKInfo.cpp [Clang] Extract availability mapping from VersionMap for watchOS/tvOS 2022-01-05 17:00:03 -08:00
Diagnostic.cpp Improve handling of static assert messages. 2022-06-29 14:57:35 +02:00
DiagnosticIDs.cpp [clang][tablegen] adds human documentation to `WarningOption` 2022-06-10 17:23:00 +00:00
DiagnosticOptions.cpp
ExpressionTraits.cpp
FileEntry.cpp Basic: Add native support for stdin to SourceManager and FileManager 2020-12-23 15:18:50 -08:00
FileManager.cpp [VFS] RedirectingFileSystem only replace path if not already mapped 2022-04-11 14:52:48 -07:00
FileSystemStatCache.cpp
IdentifierTable.cpp [clang] Fix KEYALL 2022-05-11 14:28:08 -04:00
LangOptions.cpp [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
LangStandards.cpp [PS5] Add PS5OSTargetInfo class, update affected tests 2022-06-01 13:30:29 -07:00
Module.cpp [clang][modules] Report module maps affecting `no_undeclared_includes` modules 2022-03-07 10:47:46 +01:00
NoSanitizeList.cpp [clang][patch] Inclusive language, modify filename SanitizerBlacklist.h to NoSanitizeList.h 2021-02-22 15:11:37 -05:00
ObjCRuntime.cpp
OpenCLOptions.cpp [OpenCL] Turn global vector into static array. NFCI. 2022-03-05 19:16:28 +01:00
OpenMPKinds.cpp [OpenMP] Initial parsing and semantic support for 'parallel masked taskloop simd' construct 2022-07-01 08:57:15 -07:00
OperatorPrecedence.cpp
ProfileList.cpp [clang] Replace report_fatal_error(std::string) uses with report_fatal_error(Twine) 2021-10-06 11:43:19 +01:00
SanitizerSpecialCaseList.cpp
Sanitizers.cpp [clang-cl][sanitizer] Add -fsanitize-address-use-after-return to clang. 2021-06-11 12:07:35 -07:00
SourceLocation.cpp Revert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface" 2022-06-24 07:33:07 -04:00
SourceManager.cpp [Basic] SourceManager docs: macro expansion SLocs aren't a single token. NFC 2022-04-25 19:57:47 +02:00
Stack.cpp
TargetID.cpp [clang] Don't use Optional::getValue (NFC) 2022-06-20 22:59:26 -07:00
TargetInfo.cpp [Clang] Allow 'Complex float __attribute__((mode(HC)))' 2022-06-17 12:39:52 +01:00
Targets.cpp [PS5] Add PS5OSTargetInfo class, update affected tests 2022-06-01 13:30:29 -07:00
Targets.h
TokenKinds.cpp [Pseudo] Token/TokenStream, PP directive parser. 2022-02-23 17:52:02 +01:00
TypeTraits.cpp
Version.cpp [NFC][clang] Return underlying strings directly instead of OS.str() 2021-12-09 16:05:46 -08:00
Warnings.cpp [Sema] Special case -Werror-implicit-function-declaration and reject other -Werror- 2020-11-05 10:25:30 -08:00
XRayInstr.cpp [clang][cli] Generate and round-trip CodeGen options 2021-02-09 11:43:38 +01:00
XRayLists.cpp