CGRAOmp  0.1
CGRAOmpAnnotationPass.hpp
Go to the documentation of this file.
1 /*
2 * MIT License
3 *
4 * Copyright (c) 2021 Amano laboratory, Keio University & Processor Research Team, RIKEN Center for Computational Science
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy of
7 * this software and associated documentation files (the "Software"), to deal in
8 * the Software without restriction, including without limitation the rights to
9 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10 * of the Software, and to permit persons to whom the Software is furnished to do
11 * so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 *
24 * File: /include/CGRAOmpAnnotationPass.hpp
25 * Project: CGRAOmp
26 * Author: Takuya Kojima in The University of Tokyo (tkojima@hal.ipc.i.u-tokyo.ac.jp)
27 * Created Date: 15-09-2021 09:53:19
28 * Last Modified: 15-09-2021 11:31:23
29 */
30 #ifndef CGRAOmpAnnotationPass_H
31 #define CGRAOmpAnnotationPass_H
32 
33 #include "llvm/IR/PassManager.h"
34 #include "llvm/IR/Function.h"
35 #include "llvm/IR/Module.h"
36 #include "llvm/Passes/PassBuilder.h"
37 #include "llvm/Passes/PassPlugin.h"
38 #include "llvm/Support/raw_ostream.h"
39 #include "llvm/ADT/DenseMap.h"
40 #include "llvm/ADT/SetVector.h"
41 #include "llvm/ADT/StringRef.h"
42 
43 #define LLVM_ANNOT_NAME "llvm.global.annotations"
44 
45 using namespace llvm;
46 
47 namespace CGRAOmp {
48 
54  public AnalysisInfoMixin<ModuleAnnotationAnalysisPass> {
55  public:
56  using ResultBase = DenseMap<Function*, SetVector<StringRef>>;
61  class Result {
62  public:
63  bool invalidate(Module& M, const PreservedAnalyses &PA,
64  ModuleAnalysisManager::Invalidator &Inv) {
65  auto PAC = PA.getChecker<ModuleAnnotationAnalysisPass>();
66  return !PAC.preservedWhenStateless();
67  }
69  ResultBase::iterator find(Function *F) {
70  auto hoge = result[F];
71  return result.find(F);
72  }
74  ResultBase::iterator end() {
75  return result.end();
76  }
78  SetVector<StringRef>& operator [](Function *F) {
79  return result[F];
80  }
81 
82  private:
84  };
85  Result run(Module &F, ModuleAnalysisManager &AM);
86 
87  private:
88  friend AnalysisInfoMixin<ModuleAnnotationAnalysisPass>;
89  static AnalysisKey Key;
90  };
91 
97  public AnalysisInfoMixin<AnnotationAnalysisPass> {
98  public:
99  using Result = SetVector<StringRef>;
100  Result run(Function &F, FunctionAnalysisManager &AM);
101 
102  private:
103  friend AnalysisInfoMixin<AnnotationAnalysisPass>;
104  static AnalysisKey Key;
105  };
106 
107 }
108 
109 #endif //CGRAOmpAnnotationPass_H
llvm
Definition: OptionPlugin.cpp:128
CGRAOmp::ModuleAnnotationAnalysisPass::ResultBase
DenseMap< Function *, SetVector< StringRef > > ResultBase
Definition: CGRAOmpAnnotationPass.hpp:56
CGRAOmp::ModuleAnnotationAnalysisPass::Result::end
ResultBase::iterator end()
interface for DenseMap.end
Definition: CGRAOmpAnnotationPass.hpp:74
CGRAOmp::AnnotationAnalysisPass::Result
SetVector< StringRef > Result
Definition: CGRAOmpAnnotationPass.hpp:99
CGRAOmp::ModuleAnnotationAnalysisPass::Result
Inner class for analysis result for ModuleAnnotationAnalysisPass.
Definition: CGRAOmpAnnotationPass.hpp:61
CGRAOmp
Definition: AGVerifyPass.hpp:50
CGRAOmp::ModuleAnnotationAnalysisPass::Result::result
ResultBase result
Definition: CGRAOmpAnnotationPass.hpp:83
CGRAOmp::AnnotationAnalysisPass
Function Pass to analyze which annotations the function has.
Definition: CGRAOmpAnnotationPass.hpp:96
CGRAOmp::ModuleAnnotationAnalysisPass::Result::find
ResultBase::iterator find(Function *F)
interface for DenseMap.find
Definition: CGRAOmpAnnotationPass.hpp:69
CGRAOmp::ModuleAnnotationAnalysisPass::Result::invalidate
bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
Definition: CGRAOmpAnnotationPass.hpp:63
CGRAOmp::AnnotationAnalysisPass::Key
static AnalysisKey Key
Definition: CGRAOmpAnnotationPass.hpp:104
CGRAOmp::ModuleAnnotationAnalysisPass::Key
static AnalysisKey Key
Definition: CGRAOmpAnnotationPass.hpp:89
CGRAOmp::ModuleAnnotationAnalysisPass
Module Pass to analyze which annotations each function has.
Definition: CGRAOmpAnnotationPass.hpp:53