[flang-commits] [flang] [flang][cuda] Lower attribute for module variables (PR #81226)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Feb 8 21:13:18 PST 2024


================
@@ -271,27 +271,29 @@ mlir::Value fir::FirOpBuilder::createHeapTemporary(
 
 /// Create a global variable in the (read-only) data section. A global variable
 /// must have a unique name to identify and reference it.
-fir::GlobalOp fir::FirOpBuilder::createGlobal(mlir::Location loc,
-                                              mlir::Type type,
-                                              llvm::StringRef name,
-                                              mlir::StringAttr linkage,
-                                              mlir::Attribute value,
-                                              bool isConst, bool isTarget) {
+fir::GlobalOp fir::FirOpBuilder::createGlobal(
+    mlir::Location loc, mlir::Type type, llvm::StringRef name,
+    mlir::StringAttr linkage, mlir::Attribute value, bool isConst,
+    bool isTarget, fir::CUDAAttributeAttr cudaAttr) {
   auto module = getModule();
   auto insertPt = saveInsertionPoint();
   if (auto glob = module.lookupSymbol<fir::GlobalOp>(name))
     return glob;
   setInsertionPoint(module.getBody(), module.getBody()->end());
-  auto glob =
-      create<fir::GlobalOp>(loc, name, isConst, isTarget, type, value, linkage);
+  llvm::SmallVector<mlir::NamedAttribute> attrs;
+  if (cudaAttr)
+    attrs.push_back(mlir::NamedAttribute(
+        mlir::StringAttr::get(module.getContext(), "cuda_attr"), cudaAttr));
----------------
clementval wrote:

Leftover from early test. Sure I'll update it.

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


More information about the flang-commits mailing list