[flang-commits] [flang] fbe8d2a - [flang][OpenMP] Implement getOpenMPVersionAttribute helper function, NFC (#90086)

via flang-commits flang-commits at lists.llvm.org
Tue Apr 30 09:40:43 PDT 2024


Author: Krzysztof Parzyszek
Date: 2024-04-30T11:40:39-05:00
New Revision: fbe8d2a22189233590b15dad62c881a60c74b201

URL: https://github.com/llvm/llvm-project/commit/fbe8d2a22189233590b15dad62c881a60c74b201
DIFF: https://github.com/llvm/llvm-project/commit/fbe8d2a22189233590b15dad62c881a60c74b201.diff

LOG: [flang][OpenMP] Implement getOpenMPVersionAttribute helper function, NFC (#90086)

Added: 
    

Modified: 
    flang/include/flang/Tools/CrossToolHelpers.h

Removed: 
    


################################################################################
diff  --git a/flang/include/flang/Tools/CrossToolHelpers.h b/flang/include/flang/Tools/CrossToolHelpers.h
index b7d84af8c483ee..cebdd6d181c364 100644
--- a/flang/include/flang/Tools/CrossToolHelpers.h
+++ b/flang/include/flang/Tools/CrossToolHelpers.h
@@ -109,7 +109,7 @@ struct OffloadModuleOpts {
 
 //  Shares assinging of the OpenMP OffloadModuleInterface and its assorted
 //  attributes accross Flang tools (bbc/flang)
-void setOffloadModuleInterfaceAttributes(
+[[maybe_unused]] static void setOffloadModuleInterfaceAttributes(
     mlir::ModuleOp &module, OffloadModuleOpts Opts) {
   // Should be registered by the OpenMPDialect
   if (auto offloadMod = llvm::dyn_cast<mlir::omp::OffloadModuleInterface>(
@@ -127,10 +127,18 @@ void setOffloadModuleInterfaceAttributes(
   }
 }
 
-void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
+[[maybe_unused]] static void setOpenMPVersionAttribute(
+    mlir::ModuleOp &module, int64_t version) {
   module.getOperation()->setAttr(
       mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
       mlir::omp::VersionAttr::get(module.getContext(), version));
 }
 
+[[maybe_unused]] static int64_t getOpenMPVersionAttribute(
+    mlir::ModuleOp module, int64_t fallback = -1) {
+  if (mlir::Attribute verAttr = module->getAttr("omp.version"))
+    return llvm::cast<mlir::omp::VersionAttr>(verAttr).getVersion();
+  return fallback;
+}
+
 #endif // FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H


        


More information about the flang-commits mailing list