xref: /llvm-project/bolt/include/bolt/Core/BinaryLoop.h (revision fd38366e4525c5507bbb2a2fc1f7d113a964224e)
1 //===- bolt/Core/BinaryLoop.h - Loop info at low-level IR -------*- 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 defines the BinaryLoop class, which represents a loop in the
10 // CFG of a binary function, and the BinaryLoopInfo class, which stores
11 // information about all the loops of a binary function.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef BOLT_CORE_BINARY_LOOP_H
16 #define BOLT_CORE_BINARY_LOOP_H
17 
18 #include "llvm/Support/GenericLoopInfo.h"
19 
20 namespace llvm {
21 namespace bolt {
22 
23 class BinaryBasicBlock;
24 
25 class BinaryLoop : public LoopBase<BinaryBasicBlock, BinaryLoop> {
26 public:
BinaryLoop()27   BinaryLoop() : LoopBase<BinaryBasicBlock, BinaryLoop>() {}
28 
29   // The total count of all the back edges of this loop.
30   uint64_t TotalBackEdgeCount{0};
31 
32   // The times the loop is entered from outside.
33   uint64_t EntryCount{0};
34 
35   // The times the loop is exited.
36   uint64_t ExitCount{0};
37 
38   // Most of the public interface is provided by LoopBase.
39 
40 protected:
41   friend class LoopInfoBase<BinaryBasicBlock, BinaryLoop>;
BinaryLoop(BinaryBasicBlock * BB)42   explicit BinaryLoop(BinaryBasicBlock *BB)
43       : LoopBase<BinaryBasicBlock, BinaryLoop>(BB) {}
44 };
45 
46 class BinaryLoopInfo : public LoopInfoBase<BinaryBasicBlock, BinaryLoop> {
47 public:
BinaryLoopInfo()48   BinaryLoopInfo() {}
49 
50   unsigned OuterLoops{0};
51   unsigned TotalLoops{0};
52   unsigned MaximumDepth{0};
53 
54   // Most of the public interface is provided by LoopInfoBase.
55 };
56 
57 } // namespace bolt
58 } // namespace llvm
59 
60 #endif
61