This is an archive of the discontinued LLVM Phabricator instance.

Add default DataLayout support for complex numbers
ClosedPublic

Authored by tpopp on Apr 12 2021, 1:29 AM.

Diff Detail

Event Timeline

tpopp created this revision.Apr 12 2021, 1:29 AM
tpopp requested review of this revision.Apr 12 2021, 1:29 AM
ftynse requested changes to this revision.Apr 13 2021, 9:24 AM

Thanks! Please update DataLayout.md to describe this default.

mlir/lib/Interfaces/DataLayoutInterfaces.cpp
57–59

How do we handle size in bytes for, e.g. complex<i4> (if that is even allowed)? The size in bits is 8, but the byte size may be 2 if each i4 should be aligned at byte boundary.

This revision now requires changes to proceed.Apr 13 2021, 9:24 AM
tpopp updated this revision to Diff 337367.Apr 14 2021, 1:25 AM
tpopp marked an inline comment as done.

Change complex DataLayout size computation to include alignment padding between elements.

tpopp added a comment.Apr 14 2021, 1:33 AM

Please let me know what you think of my interpretation of the default sizes for complex types.

mlir/lib/Interfaces/DataLayoutInterfaces.cpp
57–59

Good point. I changed this to also include any padding needed to keep both elements in the structure aligned.

I'm proposing that bitsize be 12 in the case of complex<i4> (the 2 elements and the padding to align the second element). This is the most accurate representation if treating complex like a C struct.

This would not guarantee that collections of the struct are aligned when only considering bitsize of the object and would require the users to remember to compute the aligned size, but I think that's best rather than giving a false representation.

ftynse accepted this revision.Apr 16 2021, 8:48 AM
This revision is now accepted and ready to land.Apr 16 2021, 8:48 AM