diff options
author | Jakub Staszak <jstaszak@apple.com> | 2011-07-25 22:24:51 +0000 |
---|---|---|
committer | Jakub Staszak <jstaszak@apple.com> | 2011-07-25 22:24:51 +0000 |
commit | a26ec886a3a4d9d317262861d7a3de4f64bad71c (patch) | |
tree | 257ec74b403d4e77737919d7538760293555f428 /include/llvm/Support/BlockFrequency.h | |
parent | 580f4a9c1c2fcbb8877463f873c6e9ca2a5ccf9f (diff) | |
download | llvm-a26ec886a3a4d9d317262861d7a3de4f64bad71c.tar.gz llvm-a26ec886a3a4d9d317262861d7a3de4f64bad71c.tar.bz2 llvm-a26ec886a3a4d9d317262861d7a3de4f64bad71c.tar.xz |
Add BlockFrequency class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/BlockFrequency.h')
-rw-r--r-- | include/llvm/Support/BlockFrequency.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/include/llvm/Support/BlockFrequency.h b/include/llvm/Support/BlockFrequency.h new file mode 100644 index 0000000000..b133c961f6 --- /dev/null +++ b/include/llvm/Support/BlockFrequency.h @@ -0,0 +1,64 @@ +//===-------- BlockFrequency.h - Block Frequency Wrapper --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements Block Frequency class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H +#define LLVM_SUPPORT_BLOCKFREQUENCY_H + +namespace llvm { + +class raw_ostream; +class BranchProbability; + +// This class represents Block Frequency as a 64-bit value. +class BlockFrequency { + + uint64_t Frequency; + + static void mult96bit(uint64_t freq, uint32_t N, uint64_t W[2]); + static uint64_t div96bit(uint64_t W[2], uint32_t D); + +public: + BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { } + + uint64_t getFrequency() const { return Frequency; } + + BlockFrequency &operator*=(const BranchProbability &Prob); + const BlockFrequency operator*(const BranchProbability &Prob) const; + + BlockFrequency &operator+=(const BlockFrequency &Freq); + const BlockFrequency operator+(const BlockFrequency &Freq) const; + + bool operator<(const BlockFrequency &RHS) const { + return Frequency < RHS.Frequency; + } + + bool operator<=(const BlockFrequency &RHS) const { + return Frequency <= RHS.Frequency; + } + + bool operator>(const BlockFrequency &RHS) const { + return Frequency > RHS.Frequency; + } + + bool operator>=(const BlockFrequency &RHS) const { + return Frequency >= RHS.Frequency; + } + + void print(raw_ostream &OS) const; +}; + +raw_ostream &operator<<(raw_ostream &OS, const BlockFrequency &Freq); + +} + +#endif |