[flang] Implement STORAGE_SIZE(), SIZEOF(), C_SIZEOF()
authorpeter klausler <pklausler@nvidia.com>
Tue, 15 Dec 2020 19:06:44 +0000 (11:06 -0800)
committerpeter klausler <pklausler@nvidia.com>
Wed, 16 Dec 2020 01:26:20 +0000 (17:26 -0800)
commit6aa3591e98402418e110c506cdd488ed1e3021b6
tree8b0310ee7dd9b39fe1070227383761d348c7f098
parent0f903015c7746e1c91da742792dd7ee0ae7dd51e
[flang] Implement STORAGE_SIZE(), SIZEOF(), C_SIZEOF()

STORAGE_SIZE() is a standard inquiry intrinsic (size in bits
of an array element of the same type as the argument); SIZEOF()
is a common extension that returns the size in bytes of its
argument; C_SIZEOF() is a renaming of SIZEOF() in module ISO_C_BINDING.

STORAGE_SIZE() and SIZEOF() are implemented via rewrites to
expressions; these expressions will be constant when the necessary
type parameters and bounds are also constant.

Code to calculate the sizes of types (with and without alignment)
was isolated into Evaluate/type.* and /characteristics.*.
Code in Semantics/compute-offsets.* to calculate sizes and alignments
of derived types' scopes was exposed so that it can be called at type
instantiation time (earlier than before) so that these inquiry intrinsics
could be called from specification expressions.

Differential Revision: https://reviews.llvm.org/D93322
22 files changed:
flang/docs/Extensions.md
flang/include/flang/Evaluate/characteristics.h
flang/include/flang/Evaluate/common.h
flang/include/flang/Evaluate/initial-image.h
flang/include/flang/Evaluate/type.h
flang/lib/Evaluate/characteristics.cpp
flang/lib/Evaluate/fold-designator.cpp
flang/lib/Evaluate/fold-integer.cpp
flang/lib/Evaluate/initial-image.cpp
flang/lib/Evaluate/intrinsics.cpp
flang/lib/Evaluate/shape.cpp
flang/lib/Evaluate/type.cpp
flang/lib/Semantics/compute-offsets.cpp
flang/lib/Semantics/compute-offsets.h
flang/lib/Semantics/data-to-inits.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/type.cpp
flang/module/__fortran_builtins.f90
flang/module/iso_c_binding.f90
flang/test/Evaluate/folding17.f90 [new file with mode: 0644]
flang/test/Semantics/resolve92.f90
flang/test/Semantics/typeinfo01.f90