Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. //===- GenericUniformityInfo.h ---------------------------*- 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. //
  10. //===----------------------------------------------------------------------===//
  11.  
  12. #ifndef LLVM_ADT_GENERICUNIFORMITYINFO_H
  13. #define LLVM_ADT_GENERICUNIFORMITYINFO_H
  14.  
  15. // #include "llvm/ADT/DenseSet.h"
  16. #include "llvm/ADT/GenericCycleInfo.h"
  17. // #include "llvm/ADT/SmallPtrSet.h"
  18. // #include "llvm/ADT/Uniformity.h"
  19. // #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
  20. #include "llvm/Support/raw_ostream.h"
  21.  
  22. namespace llvm {
  23.  
  24. class TargetTransformInfo;
  25.  
  26. template <typename ContextT> class GenericUniformityAnalysisImpl;
  27. template <typename ImplT> struct GenericUniformityAnalysisImplDeleter {
  28.   // Ugly hack around the fact that recent (> 15.0) clang will run into an
  29.   // is_invocable() check in some GNU libc++'s unique_ptr implementation
  30.   // and reject this deleter if you just make it callable with an ImplT *,
  31.   // whether or not the type of ImplT is spelled out.
  32.   using pointer = ImplT *;
  33.   void operator()(ImplT *Impl);
  34. };
  35.  
  36. template <typename ContextT> class GenericUniformityInfo {
  37. public:
  38.   using BlockT = typename ContextT::BlockT;
  39.   using FunctionT = typename ContextT::FunctionT;
  40.   using ValueRefT = typename ContextT::ValueRefT;
  41.   using ConstValueRefT = typename ContextT::ConstValueRefT;
  42.   using InstructionT = typename ContextT::InstructionT;
  43.   using DominatorTreeT = typename ContextT::DominatorTreeT;
  44.   using ThisT = GenericUniformityInfo<ContextT>;
  45.  
  46.   using CycleInfoT = GenericCycleInfo<ContextT>;
  47.   using CycleT = typename CycleInfoT::CycleT;
  48.  
  49.   GenericUniformityInfo(FunctionT &F, const DominatorTreeT &DT,
  50.                         const CycleInfoT &CI,
  51.                         const TargetTransformInfo *TTI = nullptr);
  52.   GenericUniformityInfo() = default;
  53.   GenericUniformityInfo(GenericUniformityInfo &&) = default;
  54.   GenericUniformityInfo &operator=(GenericUniformityInfo &&) = default;
  55.  
  56.   /// Whether any divergence was detected.
  57.   bool hasDivergence() const;
  58.  
  59.   /// The GPU kernel this analysis result is for
  60.   const FunctionT &getFunction() const { return *F; }
  61.  
  62.   /// Whether \p V is divergent at its definition.
  63.   bool isDivergent(ConstValueRefT V) const;
  64.  
  65.   /// Whether \p V is uniform/non-divergent.
  66.   bool isUniform(ConstValueRefT V) const { return !isDivergent(V); }
  67.  
  68.   bool hasDivergentTerminator(const BlockT &B);
  69.  
  70.   void print(raw_ostream &Out) const;
  71.  
  72. private:
  73.   using ImplT = GenericUniformityAnalysisImpl<ContextT>;
  74.  
  75.   FunctionT *F;
  76.   std::unique_ptr<ImplT, GenericUniformityAnalysisImplDeleter<ImplT>> DA;
  77.  
  78.   GenericUniformityInfo(const GenericUniformityInfo &) = delete;
  79.   GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;
  80. };
  81.  
  82. } // namespace llvm
  83.  
  84. #endif // LLVM_ADT_GENERICUNIFORMITYINFO_H
  85.