diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 | 
| commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
| tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /include/llvm/Transforms/Utils/BypassSlowDivision.h | |
| parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
Notes
Diffstat (limited to 'include/llvm/Transforms/Utils/BypassSlowDivision.h')
| -rw-r--r-- | include/llvm/Transforms/Utils/BypassSlowDivision.h | 42 | 
1 files changed, 38 insertions, 4 deletions
| diff --git a/include/llvm/Transforms/Utils/BypassSlowDivision.h b/include/llvm/Transforms/Utils/BypassSlowDivision.h index af0d60b2625f..6eca5ed2154e 100644 --- a/include/llvm/Transforms/Utils/BypassSlowDivision.h +++ b/include/llvm/Transforms/Utils/BypassSlowDivision.h @@ -1,4 +1,4 @@ -//===- llvm/Transforms/Utils/BypassSlowDivision.h --------------*- C++ -*-===// +//===- llvm/Transforms/Utils/BypassSlowDivision.h ---------------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -19,10 +19,44 @@  #define LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H  #include "llvm/ADT/DenseMap.h" -#include "llvm/IR/Function.h" +#include "llvm/ADT/DenseMapInfo.h" +#include <cstdint>  namespace llvm { +class BasicBlock; +class Value; + +struct DivRemMapKey { +  bool SignedOp; +  Value *Dividend; +  Value *Divisor; + +  DivRemMapKey(bool InSignedOp, Value *InDividend, Value *InDivisor) +      : SignedOp(InSignedOp), Dividend(InDividend), Divisor(InDivisor) {} +}; + +template <> struct DenseMapInfo<DivRemMapKey> { +  static bool isEqual(const DivRemMapKey &Val1, const DivRemMapKey &Val2) { +    return Val1.SignedOp == Val2.SignedOp && Val1.Dividend == Val2.Dividend && +           Val1.Divisor == Val2.Divisor; +  } + +  static DivRemMapKey getEmptyKey() { +    return DivRemMapKey(false, nullptr, nullptr); +  } + +  static DivRemMapKey getTombstoneKey() { +    return DivRemMapKey(true, nullptr, nullptr); +  } + +  static unsigned getHashValue(const DivRemMapKey &Val) { +    return (unsigned)(reinterpret_cast<uintptr_t>(Val.Dividend) ^ +                      reinterpret_cast<uintptr_t>(Val.Divisor)) ^ +           (unsigned)Val.SignedOp; +  } +}; +  /// This optimization identifies DIV instructions in a BB that can be  /// profitably bypassed and carried out with a shorter, faster divide.  /// @@ -31,6 +65,6 @@ namespace llvm {  bool bypassSlowDivision(      BasicBlock *BB, const DenseMap<unsigned int, unsigned int> &BypassWidth); -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_TRANSFORMS_UTILS_BYPASSSLOWDIVISION_H | 
