diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 18:23:42 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-06-28 18:23:42 +0000 |
commit | d7648ff20f8bbc8217a26576ca96addc55e003de (patch) | |
tree | 533f916f95e5936947c567f3d37c2a478d8224cd /include/llvm/Support/BlockFrequency.h | |
parent | f52578c08c71dc356428c25b0ba8759fd7ee2c66 (diff) | |
download | llvm-d7648ff20f8bbc8217a26576ca96addc55e003de.tar.gz llvm-d7648ff20f8bbc8217a26576ca96addc55e003de.tar.bz2 llvm-d7648ff20f8bbc8217a26576ca96addc55e003de.tar.xz |
Add a division operator to BlockFrequency.
Allow a BlockFrequency to be divided by a non-zero BranchProbability
with saturating arithmetic. This will be used to compute the frequency
of a loop header given the probability of leaving the loop.
Our long division algorithm already saturates on overflow, so that was a
freebie.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185184 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/BlockFrequency.h')
-rw-r--r-- | include/llvm/Support/BlockFrequency.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/llvm/Support/BlockFrequency.h b/include/llvm/Support/BlockFrequency.h index 85e9437a57..147d52abe4 100644 --- a/include/llvm/Support/BlockFrequency.h +++ b/include/llvm/Support/BlockFrequency.h @@ -27,6 +27,9 @@ class BlockFrequency { uint64_t Frequency; static const int64_t ENTRY_FREQ = 1 << 14; + // Scale frequency by N/D, saturating on overflow. + void scale(uint32_t N, uint32_t D); + public: BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { } @@ -42,6 +45,11 @@ public: BlockFrequency &operator*=(const BranchProbability &Prob); const BlockFrequency operator*(const BranchProbability &Prob) const; + /// \brief Divide by a non-zero branch probability using saturating + /// arithmetic. + BlockFrequency &operator/=(const BranchProbability &Prob); + BlockFrequency operator/(const BranchProbability &Prob) const; + /// \brief Adds another block frequency using saturating arithmetic. BlockFrequency &operator+=(const BlockFrequency &Freq); const BlockFrequency operator+(const BlockFrequency &Freq) const; |