[flang] Compute sizes and offsets for symbols
authorTim Keith <tkeith@nvidia.com>
Wed, 22 Apr 2020 22:39:24 +0000 (15:39 -0700)
committerTim Keith <tkeith@nvidia.com>
Thu, 23 Apr 2020 21:54:34 +0000 (14:54 -0700)
commitc353ebbfa4cb30a823fd850de97cb1ef559a05cc
tree092750eefb0ec905195f0d325a2f2046bad0c0e8
parentfcbc613ad8b7785f710996f58726f26ad4ace50b
[flang] Compute sizes and offsets for symbols

Summary:
Add size and offset properties to symbols, representing their byte size
and offset within their enclosing scope.

Add size and align properties to scopes so that they are available for
scopes representing derived types.

Add ComputeOffsets pass over the symbol table to fill in those fields.

Compute descriptor size based on rank and length parameters. Extract
DerivedTypeSpec::NumLengthParameters from DynamicType::RequiresDescriptor
to share the code.

Add Scope::GetSymbols to get symbols in canonical order.
compute-offsets.cpp and mod-file.cpp both need to process symbols in the
order in which they are declared. Move the collecting of those symbols
into Scope so that it can be shared.

Add symbol size and offset to output of `-fdebug-dump-symbols` and use
that in some tests.

Still to do:
- make size and alignment rules configurable based on target
- use offsets to check EQUIVALENCE statements

Differential Revision: https://reviews.llvm.org/D78680
14 files changed:
flang/include/flang/Semantics/scope.h
flang/include/flang/Semantics/symbol.h
flang/include/flang/Semantics/type.h
flang/lib/Evaluate/type.cpp
flang/lib/Semantics/CMakeLists.txt
flang/lib/Semantics/compute-offsets.cpp [new file with mode: 0644]
flang/lib/Semantics/compute-offsets.h [new file with mode: 0644]
flang/lib/Semantics/mod-file.cpp
flang/lib/Semantics/scope.cpp
flang/lib/Semantics/semantics.cpp
flang/lib/Semantics/symbol.cpp
flang/lib/Semantics/type.cpp
flang/test/Semantics/offsets01.f90 [new file with mode: 0644]
flang/test/Semantics/offsets02.f90 [new file with mode: 0644]