blob: 20dfba8759136ffd01a39aad876d4844b09f93a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#pragma once
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#endif
//===- GenericUniformityInfo.h ---------------------------*- C++ -*--------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_ADT_GENERICUNIFORMITYINFO_H
#define LLVM_ADT_GENERICUNIFORMITYINFO_H
// #include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/GenericCycleInfo.h"
// #include "llvm/ADT/SmallPtrSet.h"
// #include "llvm/ADT/Uniformity.h"
// #include "llvm/Analysis/LegacyDivergenceAnalysis.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
class TargetTransformInfo;
template <typename ContextT> class GenericUniformityAnalysisImpl;
template <typename ImplT> struct GenericUniformityAnalysisImplDeleter {
// Ugly hack around the fact that recent (> 15.0) clang will run into an
// is_invocable() check in some GNU libc++'s unique_ptr implementation
// and reject this deleter if you just make it callable with an ImplT *,
// whether or not the type of ImplT is spelled out.
using pointer = ImplT *;
void operator()(ImplT *Impl);
};
template <typename ContextT> class GenericUniformityInfo {
public:
using BlockT = typename ContextT::BlockT;
using FunctionT = typename ContextT::FunctionT;
using ValueRefT = typename ContextT::ValueRefT;
using ConstValueRefT = typename ContextT::ConstValueRefT;
using InstructionT = typename ContextT::InstructionT;
using DominatorTreeT = typename ContextT::DominatorTreeT;
using ThisT = GenericUniformityInfo<ContextT>;
using CycleInfoT = GenericCycleInfo<ContextT>;
using CycleT = typename CycleInfoT::CycleT;
GenericUniformityInfo(FunctionT &F, const DominatorTreeT &DT,
const CycleInfoT &CI,
const TargetTransformInfo *TTI = nullptr);
GenericUniformityInfo() = default;
GenericUniformityInfo(GenericUniformityInfo &&) = default;
GenericUniformityInfo &operator=(GenericUniformityInfo &&) = default;
/// Whether any divergence was detected.
bool hasDivergence() const;
/// The GPU kernel this analysis result is for
const FunctionT &getFunction() const { return *F; }
/// Whether \p V is divergent at its definition.
bool isDivergent(ConstValueRefT V) const;
/// Whether \p V is uniform/non-divergent.
bool isUniform(ConstValueRefT V) const { return !isDivergent(V); }
bool hasDivergentTerminator(const BlockT &B);
void print(raw_ostream &Out) const;
private:
using ImplT = GenericUniformityAnalysisImpl<ContextT>;
FunctionT *F;
std::unique_ptr<ImplT, GenericUniformityAnalysisImplDeleter<ImplT>> DA;
GenericUniformityInfo(const GenericUniformityInfo &) = delete;
GenericUniformityInfo &operator=(const GenericUniformityInfo &) = delete;
};
} // namespace llvm
#endif // LLVM_ADT_GENERICUNIFORMITYINFO_H
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
|