Page MenuHomePhabricator

[flang] Compute sizes and offsets for symbols
ClosedPublic

Authored by tskeith on Apr 22 2020, 3:40 PM.

Details

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

Diff Detail

Event Timeline

tskeith created this revision.Apr 22 2020, 3:40 PM
Herald added a project: Restricted Project. · View Herald Transcript
tskeith retitled this revision from Compute sizes and offsets for symbols to [flang] Compute sizes and offsets for symbols.Apr 22 2020, 3:41 PM
tskeith added reviewers: klausler, PeteSteinfeld.
tskeith added a project: Restricted Project.
klausler accepted this revision.Apr 22 2020, 4:10 PM
This revision is now accepted and ready to land.Apr 22 2020, 4:10 PM
sscalpone added inline comments.Apr 22 2020, 4:22 PM
flang/lib/Semantics/compute-offsets.cpp
77

Please say why the sort must be the same. Is there a way to assert that sizing and alignment match the mod file?

115

SizeInBytes needs to be aware of target size and alignment.

tskeith updated this revision to Diff 259672.Apr 23 2020, 12:18 PM

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.

tskeith updated this revision to Diff 259687.Apr 23 2020, 1:03 PM

[flang] Compute sizes and offsets for symbols

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 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
tskeith updated this revision to Diff 259688.Apr 23 2020, 1:09 PM
tskeith edited the summary of this revision. (Show Details)

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.

tskeith marked an inline comment as done.Apr 23 2020, 1:14 PM
tskeith added inline comments.
flang/lib/Semantics/compute-offsets.cpp
77

I've changed it so that both places get the symbol list the same way, so it's guaranteed to be in the same order.

I suppose that a test we could do is compile the .mod file and verify we get the same sizes and offsets as when compiling the original file.

This revision was automatically updated to reflect the committed changes.