File indexing completed on 2026-05-10 08:43:05
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_ADT_GENERICUNIFORMITYINFO_H
0010 #define LLVM_ADT_GENERICUNIFORMITYINFO_H
0011
0012 #include "llvm/ADT/GenericCycleInfo.h"
0013 #include "llvm/Support/raw_ostream.h"
0014
0015 namespace llvm {
0016
0017 class TargetTransformInfo;
0018
0019 template <typename ContextT> class GenericUniformityAnalysisImpl;
0020 template <typename ImplT> struct GenericUniformityAnalysisImplDeleter {
0021
0022
0023
0024
0025 using pointer = ImplT *;
0026 void operator()(ImplT *Impl);
0027 };
0028
0029 template <typename ContextT> class GenericUniformityInfo {
0030 public:
0031 using BlockT = typename ContextT::BlockT;
0032 using FunctionT = typename ContextT::FunctionT;
0033 using ValueRefT = typename ContextT::ValueRefT;
0034 using ConstValueRefT = typename ContextT::ConstValueRefT;
0035 using UseT = typename ContextT::UseT;
0036 using InstructionT = typename ContextT::InstructionT;
0037 using DominatorTreeT = typename ContextT::DominatorTreeT;
0038 using ThisT = GenericUniformityInfo<ContextT>;
0039
0040 using CycleInfoT = GenericCycleInfo<ContextT>;
0041 using CycleT = typename CycleInfoT::CycleT;
0042
0043 GenericUniformityInfo(const DominatorTreeT &DT, const CycleInfoT &CI,
0044 const TargetTransformInfo *TTI = nullptr);
0045 GenericUniformityInfo() = default;
0046 GenericUniformityInfo(GenericUniformityInfo &&) = default;
0047 GenericUniformityInfo &operator=(GenericUniformityInfo &&) = default;
0048
0049 void compute() {
0050 DA->initialize();
0051 DA->compute();
0052 }
0053
0054
0055 bool hasDivergence() const;
0056
0057
0058 const FunctionT &getFunction() const;
0059
0060
0061 bool isDivergent(ConstValueRefT V) const;
0062
0063
0064 bool isUniform(ConstValueRefT V) const { return !isDivergent(V); }
0065
0066
0067
0068
0069
0070 bool isUniform(const InstructionT *I) const { return !isDivergent(I); };
0071 bool isDivergent(const InstructionT *I) const;
0072
0073
0074
0075 bool isDivergentUse(const UseT &U) const;
0076
0077 bool hasDivergentTerminator(const BlockT &B);
0078
0079 void print(raw_ostream &Out) const;
0080
0081 private:
0082 using ImplT = GenericUniformityAnalysisImpl<ContextT>;
0083
0084 std::unique_ptr<ImplT, GenericUniformityAnalysisImplDeleter<ImplT>> DA;
0085
0086 GenericUniformityInfo(const GenericUniformityInfo &) = delete;
0087 GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;
0088 };
0089
0090 }
0091
0092 #endif