[flang-commits] [flang] [llvm] [mlir] [Frontend][OpenMP] Refactor getLeafConstructs, add getCompoundConstruct (PR #87247)
Alexey Bataev via flang-commits
flang-commits at lists.llvm.org
Mon Apr 22 06:58:48 PDT 2024
================
@@ -8,12 +8,80 @@
#include "llvm/Frontend/OpenMP/OMP.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/ErrorHandling.h"
+#include <algorithm>
+#include <iterator>
+#include <type_traits>
+
using namespace llvm;
-using namespace omp;
+using namespace llvm::omp;
#define GEN_DIRECTIVES_IMPL
#include "llvm/Frontend/OpenMP/OMP.inc"
+
+namespace llvm::omp {
+ArrayRef<Directive> getLeafConstructs(Directive D) {
+ auto Idx = static_cast<std::size_t>(D);
+ if (Idx >= Directive_enumSize)
+ return {};
+ const auto *Row = LeafConstructTable[LeafConstructTableOrdering[Idx]];
+ return ArrayRef(&Row[2], &Row[2] + static_cast<int>(Row[1]));
----------------
alexey-bataev wrote:
```suggestion
return ArrayRef(&Row[2], Row[1]);
```
https://github.com/llvm/llvm-project/pull/87247
More information about the flang-commits
mailing list