Page MenuHomePhabricator

Add size of FP environment to DataLayout
Needs ReviewPublic

Authored by sepavloff on Dec 19 2019, 10:18 PM.



This change extends the layout specification with a new item. The item
has the form "fe:<size>:<align>" in which the argument <size> specifies
the size of memory required to store floating point environment, such as
rounding mode, exception behavior etc. Optional argument <align> specifies
required alignment of that memory.

The motivation for this extension is the need to support programs where
different parts are executed in different FP environment. It takes place,
in particular, when '#pragma STDC FENV_ACCESS' is used. When such program
undergoes transformation, it is possible that FP environment must be
saved and then restored. As an example, inlining a function that
requires default FP environment into a function where FP is non-standard
requires saving the FP environment before entry into the inlined
function and resoring it upon return.

Saving/restoring the FP environment requries creation of a variable for
the FP state but the size of this variable depends on the used target. As
this operation occurs at IR level, the size of FP state must be provided
by a component intended to represent target properties in
target-independent pipeline.