Skip to content

Commit fbe8d2a

Browse files
authored
[flang][OpenMP] Implement getOpenMPVersionAttribute helper function, NFC (#90086)
1 parent 91c52b9 commit fbe8d2a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

flang/include/flang/Tools/CrossToolHelpers.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct OffloadModuleOpts {
109109

110110
// Shares assinging of the OpenMP OffloadModuleInterface and its assorted
111111
// attributes accross Flang tools (bbc/flang)
112-
void setOffloadModuleInterfaceAttributes(
112+
[[maybe_unused]] static void setOffloadModuleInterfaceAttributes(
113113
mlir::ModuleOp &module, OffloadModuleOpts Opts) {
114114
// Should be registered by the OpenMPDialect
115115
if (auto offloadMod = llvm::dyn_cast<mlir::omp::OffloadModuleInterface>(
@@ -127,10 +127,18 @@ void setOffloadModuleInterfaceAttributes(
127127
}
128128
}
129129

130-
void setOpenMPVersionAttribute(mlir::ModuleOp &module, int64_t version) {
130+
[[maybe_unused]] static void setOpenMPVersionAttribute(
131+
mlir::ModuleOp &module, int64_t version) {
131132
module.getOperation()->setAttr(
132133
mlir::StringAttr::get(module.getContext(), llvm::Twine{"omp.version"}),
133134
mlir::omp::VersionAttr::get(module.getContext(), version));
134135
}
135136

137+
[[maybe_unused]] static int64_t getOpenMPVersionAttribute(
138+
mlir::ModuleOp module, int64_t fallback = -1) {
139+
if (mlir::Attribute verAttr = module->getAttr("omp.version"))
140+
return llvm::cast<mlir::omp::VersionAttr>(verAttr).getVersion();
141+
return fallback;
142+
}
143+
136144
#endif // FORTRAN_TOOLS_CROSS_TOOL_HELPERS_H

0 commit comments

Comments
 (0)