Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:48:20

0001 //===- polly/PolyhedralInfo.h - PolyhedralInfo class definition -*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// This file contains the declaration of the PolyhedralInfo class, which will
0010 /// provide an interface to expose polyhedral analysis information of Polly.
0011 ///
0012 /// This is work in progress. We will add more API's as and when deemed
0013 /// required.
0014 //===----------------------------------------------------------------------===///
0015 
0016 #ifndef POLLY_POLYHEDRAL_INFO_H
0017 #define POLLY_POLYHEDRAL_INFO_H
0018 
0019 #include "llvm/Pass.h"
0020 #include "isl/aff_type.h"
0021 #include "isl/ctx.h"
0022 #include "isl/union_map_type.h"
0023 
0024 namespace llvm {
0025 class Loop;
0026 } // namespace llvm
0027 
0028 namespace polly {
0029 
0030 class Scop;
0031 class ScopInfo;
0032 class DependenceInfoWrapperPass;
0033 
0034 class PolyhedralInfo final : public llvm::FunctionPass {
0035 public:
0036   static char ID; // Pass identification, replacement for typeid
0037 
0038   /// Construct a new PolyhedralInfo pass.
0039   PolyhedralInfo() : FunctionPass(ID) {}
0040   ~PolyhedralInfo() {}
0041 
0042   /// Check if a given loop is parallel.
0043   ///
0044   /// @param L The loop.
0045   ///
0046   /// @return  Returns true, if loop is parallel false otherwise.
0047   bool isParallel(llvm::Loop *L) const;
0048 
0049   /// Return the SCoP containing the @p L loop.
0050   ///
0051   /// @param L The loop.
0052   ///
0053   /// @return  Returns the SCoP containing the given loop.
0054   ///          Returns null if the loop is not contained in any SCoP.
0055   const Scop *getScopContainingLoop(llvm::Loop *L) const;
0056 
0057   /// Computes the partial schedule for the given @p L loop.
0058   ///
0059   /// @param S The SCoP containing the given loop
0060   /// @param L The loop.
0061   ///
0062   /// @return  Returns the partial schedule for the given loop
0063   __isl_give isl_union_map *getScheduleForLoop(const Scop *S,
0064                                                llvm::Loop *L) const;
0065 
0066   /// Get the SCoP and dependence analysis information for @p F.
0067   bool runOnFunction(llvm::Function &F) override;
0068 
0069   /// Release the internal memory.
0070   void releaseMemory() override {}
0071 
0072   /// Print to @p OS if each dimension of a loop nest is parallel or not.
0073   void print(llvm::raw_ostream &OS,
0074              const llvm::Module *M = nullptr) const override;
0075 
0076   /// Register all analyses and transformation required.
0077   void getAnalysisUsage(llvm::AnalysisUsage &AU) const override;
0078 
0079 private:
0080   /// Check if a given loop is parallel or vectorizable.
0081   ///
0082   /// @param L             The loop.
0083   /// @param MinDepDistPtr If not nullptr, the minimal dependence distance will
0084   ///                      be returned at the address of that pointer
0085   ///
0086   /// @return  Returns true if loop is parallel or vectorizable, false
0087   ///          otherwise.
0088   bool checkParallel(llvm::Loop *L,
0089                      __isl_give isl_pw_aff **MinDepDistPtr = nullptr) const;
0090 
0091   ScopInfo *SI;
0092   DependenceInfoWrapperPass *DI;
0093 };
0094 
0095 llvm::Pass *createPolyhedralInfoPrinterLegacyPass(llvm::raw_ostream &OS);
0096 } // end namespace polly
0097 
0098 namespace llvm {
0099 class PassRegistry;
0100 void initializePolyhedralInfoPass(llvm::PassRegistry &);
0101 void initializePolyhedralInfoPrinterLegacyPassPass(llvm::PassRegistry &);
0102 } // namespace llvm
0103 
0104 #endif