================
@@ -42,7 +45,25 @@ static void setMLIRDataLayout(mlir::ModuleOp &mod, const
llvm::DataLayout &dl) {
mlir::MLIRContext *mlirContext = mod.getContext();
mlir::DataLayoutSpecInterface dlSpec =
mlir::translateDataLayout(dl, mlirContext);
- mod->setAttr(mlir::DLTIDialect::kDataLayoutAttrName, dlSpec);
+
+ // Record cir.ptr size/alignment as a #ptr.spec entry keyed on cir.ptr.
+ // TODO(cir): only the default address space is recorded.
+ assert(!cir::MissingFeatures::dataLayoutPtrHandlingBasedOnLangAS());
+ constexpr unsigned kBitsInByte = 8;
+ unsigned ptrSizeBits = dl.getPointerSizeInBits(/*AS=*/0);
+ unsigned ptrAbiBits =
+ dl.getPointerABIAlignment(/*AS=*/0).value() * kBitsInByte;
+ unsigned ptrPrefBits =
+ dl.getPointerPrefAlignment(/*AS=*/0).value() * kBitsInByte;
+ auto ptrKey = cir::PointerType::get(cir::VoidType::get(mlirContext));
+ auto ptrSpec = mlir::ptr::SpecAttr::get(mlirContext, ptrSizeBits, ptrAbiBits,
----------------
kumarak wrote:
Pushed a commit to have CIR native `PtrSpecAttr` mirroring `ptr::SpecAttr` that
will hold the `PointerType` specification. Also, move the `setMLIRDatalayout`
to use it for both `cir-translate` and `-fclagir` path.
https://github.com/llvm/llvm-project/pull/204185
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits