This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Implement `DataLayoutTypeInterface` for `LLVMArrayType`
ClosedPublic

Authored by zero9178 on Dec 13 2021, 11:48 PM.

Details

Summary

Implementation of the interface allows querying the size and alignments of an LLVMArrayType as well as query the size and alignment of a struct containing an LLVMArrayType.
The implementation should yield the same results as llvm::DataLayout, including support for over aligned element types.
There is no customization point for adjusting an arrays alignment; it is simply taken from the element type.

Diff Detail

Event Timeline

zero9178 created this revision.Dec 13 2021, 11:48 PM
zero9178 requested review of this revision.Dec 13 2021, 11:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 13 2021, 11:48 PM
zero9178 added inline comments.Dec 13 2021, 11:51 PM
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
71

This is basically equal to llvm::DataLayouts getTypeAllocSize. I am not sure whether MLIR wants to support over aligning types in which case we'd need an equivalent of it in DataLayout and co. Maybe worth a future TODO

ftynse accepted this revision.Dec 14 2021, 12:18 AM
ftynse added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
66

nit: kBitsInByte?

71

Ultimately, the LLVM dialect should support anything expressible in LLVM IR. The rest of MLIR is free to make any decisions.

This revision is now accepted and ready to land.Dec 14 2021, 12:18 AM
This revision was automatically updated to reflect the committed changes.
zero9178 marked an inline comment as done.
zero9178 added inline comments.Dec 14 2021, 12:38 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp
66

Addressed in final commit