[flang-commits] [flang] [Flang][MLIR] Add basic initial support for alloca and program address space handling in FIR->LLVMIR codegen (PR #77518)

via flang-commits flang-commits at lists.llvm.org
Tue Jan 16 12:17:05 PST 2024


================
@@ -3808,6 +3870,17 @@ class FIRToLLVMLowering
     if (!forcedTargetTriple.empty())
       fir::setTargetTriple(mod, forcedTargetTriple);
 
+    if (!forcedDataLayout.empty()) {
+      llvm::DataLayout dl(forcedDataLayout);
+      mlir::MLIRContext *context = mod.getContext();
+      mod->setAttr(
+          mlir::LLVM::LLVMDialect::getDataLayoutAttrName(),
+          mlir::StringAttr::get(context, dl.getStringRepresentation()));
+      mlir::DataLayoutSpecInterface dlSpec =
+          mlir::translateDataLayout(dl, context);
+      mod->setAttr(mlir::DLTIDialect::kDataLayoutAttrName, dlSpec);
----------------
jeanPerier wrote:

You can use `fir::support::setMLIRDataLayout(mod, dl);` here (https://github.com/llvm/llvm-project/blob/a6b5d6dab0544892fb6afc46f71677969285c5a8/flang/include/flang/Optimizer/Support/DataLayout.h#L32C6-L32C23).

https://github.com/llvm/llvm-project/pull/77518


More information about the flang-commits mailing list