|
| 1 | +//=== LoopSwapping.h - Loop Swapping (Clang) ----*- C++ -*===// |
| 2 | +// |
| 3 | +// Traits Static Analyzer (SAPFOR) |
| 4 | +// |
| 5 | +// Copyright 2018 DVM System Group |
| 6 | +// |
| 7 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | +// you may not use this file except in compliance with the License. |
| 9 | +// You may obtain a copy of the License at |
| 10 | +// |
| 11 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +// |
| 13 | +// Unless required by applicable law or agreed to in writing, software |
| 14 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | +// See the License for the specific language governing permissions and |
| 17 | +// limitations under the License. |
| 18 | +// |
| 19 | +//===---------------------------------------------------------------------===// |
| 20 | +// |
| 21 | +// The file declares a pass to perform swapping of specific loops. |
| 22 | +// |
| 23 | +//===---------------------------------------------------------------------===// |
| 24 | + |
1 | 25 | #ifndef TSAR_CLANG_LOOP_SWAPPING_H |
2 | 26 | #define TSAR_CLANG_LOOP_SWAPPING_H |
3 | 27 |
|
| 28 | +#include "tsar/Support/Tags.h" |
4 | 29 | #include "tsar/Transform/Clang/Passes.h" |
| 30 | +#include "tsar/Analysis/AnalysisServer.h" |
| 31 | +#include "tsar/Analysis/Memory/DIDependencyAnalysis.h" |
| 32 | +#include "tsar/Support/GlobalOptions.h" |
5 | 33 | #include <bcl/utility.h> |
6 | 34 | #include <llvm/Pass.h> |
7 | 35 |
|
| 36 | +namespace tsar { |
| 37 | + class TransformationContext; |
| 38 | + class DIAliasNode; |
| 39 | + class DIAliasTree; |
| 40 | + class MemoryMatchInfo; |
| 41 | +} |
| 42 | + |
| 43 | +namespace clang { |
| 44 | + class SourceRange; |
| 45 | + class Rewriter; |
| 46 | +} |
| 47 | + |
8 | 48 | namespace llvm { |
9 | 49 |
|
| 50 | +class Loop; |
| 51 | +class MDNode; |
| 52 | +class GlobalsAAResult; |
| 53 | + |
10 | 54 | class ClangLoopSwapping : public FunctionPass, private bcl::Uncopyable { |
11 | 55 | public: |
12 | 56 | static char ID; |
13 | 57 |
|
14 | 58 | ClangLoopSwapping() : FunctionPass(ID) { |
15 | 59 | initializeClangLoopSwappingPass(*PassRegistry::getPassRegistry()); |
16 | 60 | } |
17 | | - |
18 | 61 | bool runOnFunction(Function &F) override; |
19 | 62 | void getAnalysisUsage(AnalysisUsage &AU) const override; |
| 63 | + void releaseMemory() override; |
| 64 | + |
| 65 | +private: |
| 66 | + void initializeProviderOnClient(llvm::Module &M); |
| 67 | + void initializeProviderOnServer(); |
| 68 | + |
| 69 | + bool LoadDependenceAnalysisInfo(Function &F); |
| 70 | + void SwapLoops(const std::vector<std::vector<clang::SourceRange>> &mRangePairs, |
| 71 | + const std::vector<std::vector<Loop *>> &mLoopPairs); |
| 72 | + bool IsNoLoopID(llvm::MDNode *LoopID); |
| 73 | + std::vector<tsar::DIAliasNode *> GetLoopNodes(llvm::MDNode *LoopID); |
| 74 | + bool IsSwappingAvailable(std::vector<Loop *> loops); |
| 75 | + |
| 76 | + tsar::TransformationContext *mTfmCtx = nullptr; |
| 77 | + tsar::DIDependencInfo *DIDepInfo = nullptr; |
| 78 | + tsar::DIAliasTree *DIAT = nullptr; |
| 79 | + const tsar::GlobalOptions *mGlobalOpts = nullptr; |
| 80 | + GlobalsAAResult * mGlobalsAA = nullptr; |
| 81 | + tsar::AnalysisSocket *mSocket = nullptr; |
| 82 | + tsar::MemoryMatchInfo *mMemoryMatcher = nullptr; |
| 83 | + std::function<tsar::ObjectID(tsar::ObjectID)> getLoopID; |
20 | 84 | }; |
| 85 | + |
21 | 86 | } |
22 | 87 |
|
23 | 88 | #endif//TSAR_CLANG_LOOP_SWAPPING_H |
0 commit comments