From a26ec886a3a4d9d317262861d7a3de4f64bad71c Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Mon, 25 Jul 2011 22:24:51 +0000 Subject: Add BlockFrequency class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135992 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/BlockFrequency.h | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 include/llvm/Support/BlockFrequency.h (limited to 'include/llvm/Support/BlockFrequency.h') 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 -- cgit v1.2.3