xref: /freebsd/contrib/llvm-project/llvm/lib/Support/BlockFrequency.cpp (revision 5ca8e32633c4ffbbcd6762e5888b6a4ba0708c6c)
1 //====--------------- lib/Support/BlockFrequency.cpp -----------*- C++ -*-====//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements Block Frequency class.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/Support/BlockFrequency.h"
14 #include "llvm/Support/BranchProbability.h"
15 
16 using namespace llvm;
17 
18 BlockFrequency &BlockFrequency::operator*=(BranchProbability Prob) {
19   Frequency = Prob.scale(Frequency);
20   return *this;
21 }
22 
23 BlockFrequency BlockFrequency::operator*(BranchProbability Prob) const {
24   BlockFrequency Freq(Frequency);
25   Freq *= Prob;
26   return Freq;
27 }
28 
29 BlockFrequency &BlockFrequency::operator/=(BranchProbability Prob) {
30   Frequency = Prob.scaleByInverse(Frequency);
31   return *this;
32 }
33 
34 BlockFrequency BlockFrequency::operator/(BranchProbability Prob) const {
35   BlockFrequency Freq(Frequency);
36   Freq /= Prob;
37   return Freq;
38 }
39