CIRCT  20.0.0git
OpCountAnalysis.h
Go to the documentation of this file.
1 //===- OpCountAnalysis.h - operation count analyses -----------------------===//
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 header file defines prototypes for methods that perform analysis
10 // involving the frequency of different kinds of operations found in a
11 // builtin.module.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef CIRCT_ANALYSIS_OPCOUNT_ANALYSIS_H
16 #define CIRCT_ANALYSIS_OPCOUNT_ANALYSIS_H
17 
18 #include "circt/Support/LLVM.h"
19 #include "mlir/IR/Operation.h"
20 #include "llvm/ADT/DenseMap.h"
21 
22 namespace mlir {
23 class AnalysisManager;
24 } // namespace mlir
25 namespace circt {
26 namespace analysis {
27 
29 public:
30  OpCountAnalysis(Operation *moduleOp, mlir::AnalysisManager &am);
31 
32  /// Get the frequency of operations of a specific name
33  size_t getOpCount(OperationName opName);
34 
35  /// Get the names of all distinct operations found by the analysis
36  SmallVector<OperationName> getFoundOpNames();
37 
38  /// Get a map from number of operands to corresponding frequency for the given
39  /// operation
40  DenseMap<size_t, size_t> getOperandCountMap(OperationName opName);
41 
42 private:
43  DenseMap<OperationName, size_t> opCounts;
44  DenseMap<OperationName, DenseMap<size_t, size_t>> operandCounts;
45 };
46 
47 } // namespace analysis
48 } // namespace circt
49 
50 #endif // CIRCT_ANALYSIS_OPCOUNT_ANALYSIS_H
size_t getOpCount(OperationName opName)
Get the frequency of operations of a specific name.
DenseMap< size_t, size_t > getOperandCountMap(OperationName opName)
Get a map from number of operands to corresponding frequency for the given operation.
DenseMap< OperationName, DenseMap< size_t, size_t > > operandCounts
DenseMap< OperationName, size_t > opCounts
SmallVector< OperationName > getFoundOpNames()
Get the names of all distinct operations found by the analysis.
OpCountAnalysis(Operation *moduleOp, mlir::AnalysisManager &am)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21