summaryrefslogtreecommitdiff
path: root/bolt/include/bolt/Core/BinaryLoop.h
blob: 72dce77df8c14b970023a59b82180f6bc2bb1633 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//===- bolt/Core/BinaryLoop.h - Loop info at low-level IR -------*- 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
//
//===----------------------------------------------------------------------===//
//
// This file defines the BinaryLoop class, which represents a loop in the
// CFG of a binary function, and the BinaryLoopInfo class, which stores
// information about all the loops of a binary function.
//
//===----------------------------------------------------------------------===//

#ifndef BOLT_CORE_BINARY_LOOP_H
#define BOLT_CORE_BINARY_LOOP_H

#include "llvm/Support/GenericLoopInfoImpl.h"

namespace llvm {
namespace bolt {

class BinaryBasicBlock;

class BinaryLoop : public LoopBase<BinaryBasicBlock, BinaryLoop> {
public:
  BinaryLoop() : LoopBase<BinaryBasicBlock, BinaryLoop>() {}

  // The total count of all the back edges of this loop.
  uint64_t TotalBackEdgeCount{0};

  // The times the loop is entered from outside.
  uint64_t EntryCount{0};

  // The times the loop is exited.
  uint64_t ExitCount{0};

  // Most of the public interface is provided by LoopBase.

protected:
  friend class LoopInfoBase<BinaryBasicBlock, BinaryLoop>;
  explicit BinaryLoop(BinaryBasicBlock *BB)
      : LoopBase<BinaryBasicBlock, BinaryLoop>(BB) {}
};

class BinaryLoopInfo : public LoopInfoBase<BinaryBasicBlock, BinaryLoop> {
public:
  BinaryLoopInfo() {}

  unsigned OuterLoops{0};
  unsigned TotalLoops{0};
  unsigned MaximumDepth{0};

  // Most of the public interface is provided by LoopInfoBase.
};

} // namespace bolt
} // namespace llvm

#endif