Page MenuHomePhabricator

Represent FP options in AST by special Statement node
Needs ReviewPublic

Authored by sepavloff on Mon, Mar 23, 4:45 AM.



Now FPOption object is stored in the bits of Stmt class. The space
there is limited by 7 bits, which is by far not enough as FPOption
is supposed to grow incorporating other options related to floating
point operations. The problem was discussed in In
short, attempts to put FPOption as a field to relevant AST classes
result in substantial increase of AST size because such field would
consume memory even for nodes that do not deal with FP operations.

As a solution, a new statement node FloatingPragmaStmt has been
added. It represents a pragma that modifies floating point options.
This statement is placed at the beginning of corresponding
CompoundStmt. It provides persistency for the FP options and
allows to maintain actual FP state. Other nodes such as BinaryOperator
do not have to have a copy of FPOption, thus no unnecessary memory
consumption occurs.

If more than one pragma are specified in a compound statement, there
is a separate node for each. Each node keeps FP options accumulated
from all previous pragma nodes and from this one. Pragma specified
at file level results in pragma nodes implicitly inserted into every
function body affected by the pragma. In compilation option result
in non-default FP options, the synthesized pragma is inserted as well.

There are cases when an expression occurs outside compound statement.
These are global variable initializers, default arguments and some
other. This solution does not work for them, a special expression
node is required for them, it will be implemented later.

Diff Detail

Unit TestsFailed

Script: -- : 'RUN: at line 7'; /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/bin/clang -cc1 -internal-isystem /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/lib/clang/11.0.0/include -nostdsysteminc -triple nvptx64-nvidia-cuda -fcuda-is-device -std=c++11 -fno-threadsafe-statics -emit-llvm -o - /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/clang/test/CodeGenCUDA/ | /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/build/bin/FileCheck -check-prefixes=DEVICE,NVPTX /mnt/disks/ssd0/agent/workspace/amd64_debian_testing_clang8/clang/test/CodeGenCUDA/

Event Timeline

sepavloff created this revision.Mon, Mar 23, 4:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Mar 23, 4:45 AM
martong removed a subscriber: martong.Mon, Mar 23, 6:08 AM