llvm-project/clang/lib
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
..
APINotes
ARCMigrate [clang] Don't use Optional::hasValue (NFC) 2022-06-20 10:51:34 -07:00
AST [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
ASTMatchers Adds AST matcher for ObjCStringLiteral 2022-06-30 15:20:10 -07:00
Analysis [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
Basic [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
CodeGen [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
CrossTU [clang][NFC][AST] rename the ImportError to ASTImportError 2022-06-15 00:40:32 +05:30
DirectoryWatcher [clang] Don't use Optional::hasValue (NFC) 2022-06-20 10:51:34 -07:00
Driver [Driver] Always use --as-needed with libunwind 2022-06-30 03:33:40 +00:00
Edit [clang] Don't use Optional::hasValue (NFC) 2022-06-25 22:26:24 -07:00
ExtractAPI Revert "Re-apply "Deferred Concept Instantiation Implementation""" 2022-07-01 11:20:16 -07:00
Format [clang-format] Fix incorrect isspace input (NFC) 2022-06-29 10:20:46 -07:00
Frontend [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback 2022-07-01 14:22:31 -07:00
FrontendTool [C++20][Modules][HU 1/5] Introduce header units as a module type. 2022-03-25 09:17:14 +00:00
Headers [HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits 2022-06-30 06:16:51 -07:00
Index [AST] Improve traversal of concepts and concept requirements 2022-04-28 09:33:26 +00:00
IndexSerialization
Interpreter [Interpreter] Pass target features to JIT 2022-06-30 21:25:14 +02:00
Lex [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback 2022-07-01 14:22:31 -07:00
Parse [OpenMP] Initial parsing and semantic support for 'parallel masked taskloop simd' construct 2022-07-01 08:57:15 -07:00
Rewrite Add assert on End iteration distance to Rewriter::getRewrittenText. 2022-01-25 17:26:13 +00:00
Sema [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
Serialization [FPEnv] Allow CompoundStmt to keep FP options 2022-07-03 17:06:26 +07:00
StaticAnalyzer [OpenMP] Initial parsing and semantic support for 'parallel masked taskloop simd' construct 2022-07-01 08:57:15 -07:00
Support [RISCV][NFC] Move static global variables into static variable in function. 2022-06-30 10:30:01 +08:00
Testing [include-cleaner] Include-cleaner library structure, and simplistic AST walking. 2022-04-29 11:04:11 +02:00
Tooling [clang] Don't use Optional::hasValue (NFC) 2022-06-25 22:26:24 -07:00
CMakeLists.txt [RISCV] Moving RVV intrinsic type related util to clang/Support 2022-04-20 21:13:13 +08:00