LLVM: include/llvm/Analysis/WithCache.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14#ifndef LLVM_ANALYSIS_WITHCACHE_H
15#define LLVM_ANALYSIS_WITHCACHE_H
16
21#include <type_traits>
22
23namespace llvm {
27
29 static_assert(std::is_pointer_v, "WithCache requires a pointer type!");
30
31 using UnderlyingType = std::remove_pointer_t;
32 constexpr static bool IsConst = std::is_const_v;
33
34 template <typename T, bool Const>
35 using conditionally_const_t = std::conditional_t<Const, const T, T>;
36
37 using PointerType = conditionally_const_t<UnderlyingType *, IsConst>;
38 using ReferenceType = conditionally_const_t<UnderlyingType &, IsConst>;
39
40
41
42
43
46
47 void calculateKnownBits(const SimplifyQuery &Q) const {
49 Pointer.setInt(true);
50 }
51
52public:
55 : Pointer(Pointer, true), Known(Known) {}
56
57 [[nodiscard]] PointerType getValue() const { return Pointer.getPointer(); }
58
61 calculateKnownBits(Q);
62 return Known;
63 }
64
65 [[nodiscard]] bool hasKnownBits() const { return Pointer.getInt(); }
66
67 operator PointerType() const { return Pointer.getPointer(); }
68 PointerType operator->() const { return Pointer.getPointer(); }
69 ReferenceType operator*() const { return *Pointer.getPointer(); }
70};
71}
72
73#endif
This file defines the PointerIntPair class.
PointerIntPair - This class implements a pair of a pointer and small integer.
LLVM Value Representation.
PointerType operator->() const
Definition WithCache.h:68
bool hasKnownBits() const
Definition WithCache.h:65
WithCache(PointerType Pointer)
Definition WithCache.h:53
WithCache(PointerType Pointer, const KnownBits &Known)
Definition WithCache.h:54
const KnownBits & getKnownBits(const SimplifyQuery &Q) const
Definition WithCache.h:59
ReferenceType operator*() const
Definition WithCache.h:69
PointerType getValue() const
Definition WithCache.h:57
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true, unsigned Depth=0)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...