PolyhedralInfo.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #ifndef POLLY_POLYHEDRAL_INFO_H
  16. #define POLLY_POLYHEDRAL_INFO_H
  17. #include "llvm/Pass.h"
  18. #include "isl/aff_type.h"
  19. #include "isl/ctx.h"
  20. #include "isl/union_map_type.h"
  21. namespace llvm {
  22. class Loop;
  23. } // namespace llvm
  24. namespace polly {
  25. class Scop;
  26. class ScopInfo;
  27. class DependenceInfoWrapperPass;
  28. class PolyhedralInfo : public llvm::FunctionPass {
  29. public:
  30. static char ID; // Pass identification, replacement for typeid
  31. /// Construct a new PolyhedralInfo pass.
  32. PolyhedralInfo() : FunctionPass(ID) {}
  33. ~PolyhedralInfo() {}
  34. /// Check if a given loop is parallel.
  35. ///
  36. /// @param L The loop.
  37. ///
  38. /// @return Returns true, if loop is parallel false otherwise.
  39. bool isParallel(llvm::Loop *L) const;
  40. /// Return the SCoP containing the @p L loop.
  41. ///
  42. /// @param L The loop.
  43. ///
  44. /// @return Returns the SCoP containing the given loop.
  45. /// Returns null if the loop is not contained in any SCoP.
  46. const Scop *getScopContainingLoop(llvm::Loop *L) const;
  47. /// Computes the partial schedule for the given @p L loop.
  48. ///
  49. /// @param S The SCoP containing the given loop
  50. /// @param L The loop.
  51. ///
  52. /// @return Returns the partial schedule for the given loop
  53. __isl_give isl_union_map *getScheduleForLoop(const Scop *S,
  54. llvm::Loop *L) const;
  55. /// Get the SCoP and dependence analysis information for @p F.
  56. bool runOnFunction(llvm::Function &F) override;
  57. /// Release the internal memory.
  58. void releaseMemory() override {}
  59. /// Print to @p OS if each dimension of a loop nest is parallel or not.
  60. void print(llvm::raw_ostream &OS,
  61. const llvm::Module *M = nullptr) const override;
  62. /// Register all analyses and transformation required.
  63. void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
  64. private:
  65. /// Check if a given loop is parallel or vectorizable.
  66. ///
  67. /// @param L The loop.
  68. /// @param MinDepDistPtr If not nullptr, the minimal dependence distance will
  69. /// be returned at the address of that pointer
  70. ///
  71. /// @return Returns true if loop is parallel or vectorizable, false
  72. /// otherwise.
  73. bool checkParallel(llvm::Loop *L,
  74. __isl_give isl_pw_aff **MinDepDistPtr = nullptr) const;
  75. ScopInfo *SI;
  76. DependenceInfoWrapperPass *DI;
  77. };
  78. } // end namespace polly
  79. namespace llvm {
  80. class PassRegistry;
  81. void initializePolyhedralInfoPass(llvm::PassRegistry &);
  82. } // namespace llvm
  83. #endif