-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][OpenMP] Implement getOpenMPVersion helper function, NFC #90086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-flang-fir-hlfir Author: Krzysztof Parzyszek (kparzysz) ChangesFull diff: https://github.com/llvm/llvm-project/pull/90086.diff 2 Files Affected:
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp
index da3f2be73e5095..1400f1f4cc8dd2 100644
--- a/flang/lib/Lower/OpenMP/Utils.cpp
+++ b/flang/lib/Lower/OpenMP/Utils.cpp
@@ -47,6 +47,12 @@ int64_t getCollapseValue(const List<Clause> &clauses) {
return 1;
}
+uint32_t getOpenMPVersion(mlir::ModuleOp mod) {
+ if (mlir::Attribute verAttr = mod->getAttr("omp.version"))
+ return llvm::cast<mlir::omp::VersionAttr>(verAttr).getVersion();
+ llvm_unreachable("Expecting OpenMP version attribute in module");
+}
+
void genObjectList(const ObjectList &objects,
Fortran::lower::AbstractConverter &converter,
llvm::SmallVectorImpl<mlir::Value> &operands) {
diff --git a/flang/lib/Lower/OpenMP/Utils.h b/flang/lib/Lower/OpenMP/Utils.h
index b3a9f7f30c98bd..693a91f7cc6954 100644
--- a/flang/lib/Lower/OpenMP/Utils.h
+++ b/flang/lib/Lower/OpenMP/Utils.h
@@ -59,6 +59,7 @@ void gatherFuncAndVarSyms(
llvm::SmallVectorImpl<DeclareTargetCapturePair> &symbolAndClause);
int64_t getCollapseValue(const List<Clause> &clauses);
+uint32_t getOpenMPVersion(mlir::ModuleOp mod);
Fortran::semantics::Symbol *
getOmpObjectSymbol(const Fortran::parser::OmpObject &ompObject);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe instead of llvm_unreachable
, we could return std::nullopt
or some sentinel value. It would be unfortunate if we got into a situation where every mlir file in the test suite needed to have this attribute added to the module.
But it is hard to comment without seeing where this will be used so LGTM whether or not you decide to change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you Krzysztof, I have just a small non-blocking comment.
flang/lib/Lower/OpenMP/Utils.cpp
Outdated
@@ -47,6 +47,12 @@ int64_t getCollapseValue(const List<Clause> &clauses) { | |||
return 1; | |||
} | |||
|
|||
uint32_t getOpenMPVersion(mlir::ModuleOp mod, uint32_t fallback) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Wouldn't it be better placed along with setOpenMPVersionAttribute
in flang/include/flang/Tools/CrossToolHelpers.h? And perhaps also call it getOpenMPVersionAttribute
for consistency.
✅ With the latest revision this PR passed the C/C++ code formatter. |
No description provided.