[flang-commits] [flang] [Flang][MLIR] Extend DataLayout utilities to have basic GPU Module support (PR #123149)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Fri Jan 24 03:38:30 PST 2025


================
@@ -46,15 +49,53 @@ void fir::support::setMLIRDataLayoutFromAttributes(mlir::ModuleOp mlirModule,
   fir::support::setMLIRDataLayout(mlirModule, llvmDataLayout);
 }
 
-std::optional<mlir::DataLayout>
-fir::support::getOrSetDataLayout(mlir::ModuleOp mlirModule,
-                                 bool allowDefaultLayout) {
+template <typename ModOpTy>
+std::optional<mlir::DataLayout> getOrSetDataLayout(ModOpTy mlirModule,
+                                                   bool allowDefaultLayout) {
   if (!mlirModule.getDataLayoutSpec()) {
     fir::support::setMLIRDataLayoutFromAttributes(mlirModule,
                                                   allowDefaultLayout);
-    if (!mlirModule.getDataLayoutSpec()) {
+    // if it is a GPU module, we let it proceed, as it's contained within
+    // a module, its parent may have a DataLayout that can take its
+    // place.
----------------
skatrak wrote:

```suggestion
    // If it is a GPU module, we let it proceed. As it's contained within
    // a module, its parent may have a DataLayout that can take its
    // place.
```

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


More information about the flang-commits mailing list