//===- BranchProbability.h - Branch Probability Wrapper ---------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // Definition of BranchProbability shared by IR and Machine Instructions. // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H #define LLVM_SUPPORT_BRANCHPROBABILITY_H #include "llvm/Support/DataTypes.h" #include <algorithm> #include <cassert> #include <iterator> #include <numeric> namespace llvm { class raw_ostream; // This class represents Branch Probability as a non-negative fraction that is // no greater than 1. It uses a fixed-point-like implementation, in which the // denominator is always a constant value (here we use 1<<31 for maximum // precision). class BranchProbability { … }; inline raw_ostream &operator<<(raw_ostream &OS, BranchProbability Prob) { … } template <class ProbabilityIter> void BranchProbability::normalizeProbabilities(ProbabilityIter Begin, ProbabilityIter End) { … } } #endif