summaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-29 16:15:35 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-04-29 16:15:35 +0000
commit048f520b91e5fcabb1aa85cae3ec522ab5a539e6 (patch)
treee263b166b42d4f06416f0553649ec9eb871a4bb8 /include/llvm
parentf90262a09d35f9aba24357196f961733a4291aba (diff)
downloadllvm-048f520b91e5fcabb1aa85cae3ec522ab5a539e6.tar.gz
llvm-048f520b91e5fcabb1aa85cae3ec522ab5a539e6.tar.bz2
llvm-048f520b91e5fcabb1aa85cae3ec522ab5a539e6.tar.xz
Support: Add BranchProbability::scale() and ::scaleByInverse()
Add API to `BranchProbability` for scaling big integers. Next job is to rip the logic out of `BlockMass` and `BlockFrequency`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207544 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Support/BranchProbability.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/include/llvm/Support/BranchProbability.h b/include/llvm/Support/BranchProbability.h
index bf6b01defa..74d64194cf 100644
--- a/include/llvm/Support/BranchProbability.h
+++ b/include/llvm/Support/BranchProbability.h
@@ -50,6 +50,30 @@ public:
void dump() const;
+ /// \brief Scale a large integer.
+ ///
+ /// Scales \c Num. Guarantees full precision. Returns the floor of the
+ /// result.
+ ///
+ /// \return \c Num times \c this.
+ ///
+ /// \note This code should be shared with (or replaced by) the implementation
+ /// of \a BlockFrequency::scale(), which seems to be calculating something
+ /// similar.
+ uint64_t scale(uint64_t Num) const;
+
+ /// \brief Scale a large integer by the inverse.
+ ///
+ /// Scales \c Num by the inverse of \c this. Guarantees full precision.
+ /// Returns the floor of the result.
+ ///
+ /// \return \c Num divided by \c this.
+ ///
+ /// \note This code should be shared with (or replaced by) the implementation
+ /// of \a BlockFrequency::scale(), which seems to be calculating something
+ /// similar.
+ uint64_t scaleByInverse(uint64_t Num) const;
+
bool operator==(BranchProbability RHS) const {
return (uint64_t)N * RHS.D == (uint64_t)D * RHS.N;
}