• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- polly/PolyhedralInfo.h - PolyhedralInfo class definition -*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
8 ///
9 /// This file contains the declaration of the PolyhedralInfo class, which will
10 /// provide an interface to expose polyhedral analysis information of Polly.
11 ///
12 /// This is work in progress. We will add more API's as and when deemed
13 /// required.
14 //===----------------------------------------------------------------------===///
15 
16 #ifndef POLLY_POLYHEDRAL_INFO_H
17 #define POLLY_POLYHEDRAL_INFO_H
18 
19 #include "llvm/Pass.h"
20 #include "isl/aff_type.h"
21 #include "isl/ctx.h"
22 #include "isl/union_map_type.h"
23 
24 namespace llvm {
25 class Loop;
26 } // namespace llvm
27 
28 namespace polly {
29 
30 class Scop;
31 class ScopInfo;
32 class DependenceInfoWrapperPass;
33 
34 class PolyhedralInfo : public llvm::FunctionPass {
35 public:
36   static char ID; // Pass identification, replacement for typeid
37 
38   /// Construct a new PolyhedralInfo pass.
PolyhedralInfo()39   PolyhedralInfo() : FunctionPass(ID) {}
~PolyhedralInfo()40   ~PolyhedralInfo() {}
41 
42   /// Check if a given loop is parallel.
43   ///
44   /// @param L The loop.
45   ///
46   /// @return  Returns true, if loop is parallel false otherwise.
47   bool isParallel(llvm::Loop *L) const;
48 
49   /// Return the SCoP containing the @p L loop.
50   ///
51   /// @param L The loop.
52   ///
53   /// @return  Returns the SCoP containing the given loop.
54   ///          Returns null if the loop is not contained in any SCoP.
55   const Scop *getScopContainingLoop(llvm::Loop *L) const;
56 
57   /// Computes the partial schedule for the given @p L loop.
58   ///
59   /// @param S The SCoP containing the given loop
60   /// @param L The loop.
61   ///
62   /// @return  Returns the partial schedule for the given loop
63   __isl_give isl_union_map *getScheduleForLoop(const Scop *S,
64                                                llvm::Loop *L) const;
65 
66   /// Get the SCoP and dependence analysis information for @p F.
67   bool runOnFunction(llvm::Function &F) override;
68 
69   /// Release the internal memory.
releaseMemory()70   void releaseMemory() override {}
71 
72   /// Print to @p OS if each dimension of a loop nest is parallel or not.
73   void print(llvm::raw_ostream &OS,
74              const llvm::Module *M = nullptr) const override;
75 
76   /// Register all analyses and transformation required.
77   void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
78 
79 private:
80   /// Check if a given loop is parallel or vectorizable.
81   ///
82   /// @param L             The loop.
83   /// @param MinDepDistPtr If not nullptr, the minimal dependence distance will
84   ///                      be returned at the address of that pointer
85   ///
86   /// @return  Returns true if loop is parallel or vectorizable, false
87   ///          otherwise.
88   bool checkParallel(llvm::Loop *L,
89                      __isl_give isl_pw_aff **MinDepDistPtr = nullptr) const;
90 
91   ScopInfo *SI;
92   DependenceInfoWrapperPass *DI;
93 };
94 } // end namespace polly
95 
96 namespace llvm {
97 class PassRegistry;
98 void initializePolyhedralInfoPass(llvm::PassRegistry &);
99 } // namespace llvm
100 
101 #endif
102