llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
307 stars 84 forks source link

Data layout modeling for CIR types #710

Open Lancern opened 3 days ago

Lancern commented 3 days ago

The data layout of some types are target-specific. For example, the size of a pointer could be 4 or 8 depending on the target. However, the current DataLayoutTypeInterface implementation for all CIR types only return a fixed data layout regardless of the target.

The data layout subsystem of MLIR allows customization of data layouts of types within a specific region. The module op and each region can be attached with data layout properties, typically in the form of data layout specifications, that affect the layout of the types within them. We can leverage this mechanism to make the CIR types aware of the target when computing data layout, by attaching the module op with data layout information computed for the target.