File indexing completed on 2026-05-10 08:44:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H
0018 #define LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H
0019
0020 #include "llvm/ADT/DenseMap.h"
0021 #include "llvm/ADT/DenseMapInfo.h"
0022 #include "llvm/IR/ValueHandle.h"
0023 #include <cstdint>
0024
0025 namespace llvm {
0026
0027 class BasicBlock;
0028 class Value;
0029
0030 struct DivRemMapKey {
0031 bool SignedOp;
0032 AssertingVH<Value> Dividend;
0033 AssertingVH<Value> Divisor;
0034
0035 DivRemMapKey() = default;
0036
0037 DivRemMapKey(bool InSignedOp, Value *InDividend, Value *InDivisor)
0038 : SignedOp(InSignedOp), Dividend(InDividend), Divisor(InDivisor) {}
0039 };
0040
0041 template <> struct DenseMapInfo<DivRemMapKey> {
0042 static bool isEqual(const DivRemMapKey &Val1, const DivRemMapKey &Val2) {
0043 return Val1.SignedOp == Val2.SignedOp && Val1.Dividend == Val2.Dividend &&
0044 Val1.Divisor == Val2.Divisor;
0045 }
0046
0047 static DivRemMapKey getEmptyKey() {
0048 return DivRemMapKey(false, nullptr, nullptr);
0049 }
0050
0051 static DivRemMapKey getTombstoneKey() {
0052 return DivRemMapKey(true, nullptr, nullptr);
0053 }
0054
0055 static unsigned getHashValue(const DivRemMapKey &Val) {
0056 return (unsigned)(reinterpret_cast<uintptr_t>(
0057 static_cast<Value *>(Val.Dividend)) ^
0058 reinterpret_cast<uintptr_t>(
0059 static_cast<Value *>(Val.Divisor))) ^
0060 (unsigned)Val.SignedOp;
0061 }
0062 };
0063
0064
0065
0066
0067
0068
0069 bool bypassSlowDivision(
0070 BasicBlock *BB, const DenseMap<unsigned int, unsigned int> &BypassWidth);
0071
0072 }
0073
0074 #endif