CIRCT  19.0.0git
TemporalRegions.h
Go to the documentation of this file.
1 //===- TemporalRegions.h - LLHD temporal regions analysis -------*- 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 an Analysis for Behavioral LLHD to find the temporal
10 // regions of an LLHD process
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef DIALECT_LLHD_TRANSFORMS_TEMPORALREGIONS_H
15 #define DIALECT_LLHD_TRANSFORMS_TEMPORALREGIONS_H
16 
17 #include "circt/Support/LLVM.h"
18 #include "mlir/IR/Operation.h"
19 
20 namespace circt {
21 namespace llhd {
22 
24  using BlockMapT = DenseMap<Block *, int>;
25  using TRMapT = DenseMap<int, SmallVector<Block *, 8>>;
26 
27  explicit TemporalRegionAnalysis(Operation *op) { recalculate(op); }
28 
29  void recalculate(Operation *);
30 
31  unsigned getNumTemporalRegions() { return numTRs; }
32 
33  int getBlockTR(Block *);
34  SmallVector<Block *, 8> getBlocksInTR(int);
35 
36  SmallVector<Block *, 8> getExitingBlocksInTR(int);
37  Block *getTREntryBlock(int);
38  bool hasSingleExitBlock(int tr) {
39  return getExitingBlocksInTR(tr).size() == 1;
40  }
41  bool isOwnTRSuccessor(int tr) {
42  auto succs = getTRSuccessors(tr);
43  return std::find(succs.begin(), succs.end(), tr) != succs.end();
44  }
45 
46  SmallVector<int, 8> getTRSuccessors(int);
47  unsigned getNumTRSuccessors(int tr) { return getTRSuccessors(tr).size(); }
48  unsigned numBlocksInTR(int tr) { return getBlocksInTR(tr).size(); }
49 
50 private:
51  unsigned numTRs;
54 };
55 
56 } // namespace llhd
57 } // namespace circt
58 
59 #endif // DIALECT_LLHD_TRANSFORMS_TEMPORALREGIONS_H
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
SmallVector< Block *, 8 > getExitingBlocksInTR(int)
SmallVector< Block *, 8 > getBlocksInTR(int)
DenseMap< int, SmallVector< Block *, 8 > > TRMapT
DenseMap< Block *, int > BlockMapT
SmallVector< int, 8 > getTRSuccessors(int)