[TargetVersion] Only enable on RISC-V and AArch64 (#115991)
[llvm-project.git] / flang / examples / FlangOmpReport / FlangOmpReportVisitor.h
blob6c2d194a88e69aa0630a329cc47478e3b7da9352
1 //===-- examples/flang-omp-report-plugin/flang-omp-report-visitor.h -------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef FORTRAN_FLANG_OMP_REPORT_VISITOR_H
10 #define FORTRAN_FLANG_OMP_REPORT_VISITOR_H
12 #include "flang/Parser/parse-tree-visitor.h"
13 #include "flang/Parser/parse-tree.h"
14 #include "flang/Parser/parsing.h"
16 #include "llvm/ADT/DenseMap.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/ADT/StringRef.h"
20 #include <string>
22 namespace Fortran {
23 namespace parser {
24 struct ClauseInfo {
25 std::string clause;
26 std::string clauseDetails;
27 ClauseInfo() {}
28 ClauseInfo(const std::string &c, const std::string &cd)
29 : clause{c}, clauseDetails{cd} {}
30 ClauseInfo(const std::pair<std::string, std::string> &p)
31 : clause{std::get<0>(p)}, clauseDetails{std::get<1>(p)} {}
33 bool operator<(const ClauseInfo &a, const ClauseInfo &b);
34 bool operator==(const ClauseInfo &a, const ClauseInfo &b);
35 bool operator!=(const ClauseInfo &a, const ClauseInfo &b);
37 struct LogRecord {
38 std::string file;
39 int line;
40 std::string construct;
41 llvm::SmallVector<ClauseInfo> clauses;
43 bool operator==(const LogRecord &a, const LogRecord &b);
44 bool operator!=(const LogRecord &a, const LogRecord &b);
46 using OmpWrapperType =
47 std::variant<const OpenMPConstruct *, const OpenMPDeclarativeConstruct *>;
49 struct OpenMPCounterVisitor {
50 std::string normalize_construct_name(std::string s);
51 ClauseInfo normalize_clause_name(const llvm::StringRef s);
52 SourcePosition getLocation(const OmpWrapperType &w);
53 SourcePosition getLocation(const OpenMPDeclarativeConstruct &c);
54 SourcePosition getLocation(const OpenMPConstruct &c);
56 std::string getName(const OmpWrapperType &w);
57 std::string getName(const OpenMPDeclarativeConstruct &c);
58 std::string getName(const OpenMPConstruct &c);
60 template <typename A> bool Pre(const A &) { return true; }
61 template <typename A> void Post(const A &) {}
62 bool Pre(const OpenMPDeclarativeConstruct &c);
63 bool Pre(const OpenMPConstruct &c);
65 void Post(const OpenMPDeclarativeConstruct &);
66 void Post(const OpenMPConstruct &);
67 void PostConstructsCommon();
69 void Post(const OmpProcBindClause::Type &c);
70 void Post(const OmpDefaultClause::Type &c);
71 void Post(const OmpDefaultmapClause::ImplicitBehavior &c);
72 void Post(const OmpDefaultmapClause::VariableCategory &c);
73 void Post(const OmpDeviceTypeClause::Type &c);
74 void Post(const OmpScheduleModifierType::ModType &c);
75 void Post(const OmpLinearModifier::Value &c);
76 void Post(const OmpTaskDependenceType::Value &c);
77 void Post(const OmpMapClause::Type &c);
78 void Post(const OmpScheduleClause::ScheduleType &c);
79 void Post(const OmpIfClause::DirectiveNameModifier &c);
80 void Post(const OmpCancelType::Type &c);
81 void Post(const OmpClause &c);
82 void PostClauseCommon(const ClauseInfo &ci);
84 std::string clauseDetails;
85 llvm::SmallVector<LogRecord> constructClauses;
86 llvm::SmallVector<OmpWrapperType *> ompWrapperStack;
87 llvm::DenseMap<OmpWrapperType *, llvm::SmallVector<ClauseInfo>> clauseStrings;
88 Parsing *parsing{nullptr};
90 } // namespace parser
91 } // namespace Fortran
93 #endif /* FORTRAN_FLANG_OMP_REPORT_VISITOR_H */