CIRCT  20.0.0git
ModelInfo.h
Go to the documentation of this file.
1 //===- ModelInfo.h - Information about Arc models -------------------------===//
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 // Defines and computes information about Arc models.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef CIRCT_DIALECT_ARC_MODELINFO_H
14 #define CIRCT_DIALECT_ARC_MODELINFO_H
15 
16 #include "mlir/IR/BuiltinOps.h"
17 #include "llvm/ADT/SmallVector.h"
18 #include "llvm/Support/raw_ostream.h"
19 #include <string>
20 
21 namespace circt {
22 namespace arc {
23 
24 /// Gathers information about a given Arc state.
25 struct StateInfo {
27  std::string name;
28  unsigned offset;
29  unsigned numBits;
30  unsigned memoryStride = 0; // byte separation between memory words
31  unsigned memoryDepth = 0; // number of words in a memory
32 };
33 
34 /// Gathers information about a given Arc model.
35 struct ModelInfo {
36  std::string name;
37  size_t numStateBytes;
38  llvm::SmallVector<StateInfo> states;
39  mlir::FlatSymbolRefAttr initialFnSym;
40  mlir::FlatSymbolRefAttr finalFnSym;
41 
42  ModelInfo(std::string name, size_t numStateBytes,
43  llvm::SmallVector<StateInfo> states,
44  mlir::FlatSymbolRefAttr initialFnSym,
45  mlir::FlatSymbolRefAttr finalFnSym)
46  : name(std::move(name)), numStateBytes(numStateBytes),
47  states(std::move(states)), initialFnSym(initialFnSym),
49 };
50 
51 /// Collects information about states within the provided Arc model storage
52 /// `storage`, assuming default `offset`, and adds it to `states`.
53 mlir::LogicalResult collectStates(mlir::Value storage, unsigned offset,
54  llvm::SmallVector<StateInfo> &states);
55 
56 /// Collects information about all Arc models in the provided `module`,
57 /// and adds it to `models`.
58 mlir::LogicalResult collectModels(mlir::ModuleOp module,
59  llvm::SmallVector<ModelInfo> &models);
60 
61 /// Serializes `models` to `outputStream` in JSON format.
62 void serializeModelInfoToJson(llvm::raw_ostream &outputStream,
63  llvm::ArrayRef<ModelInfo> models);
64 
65 } // namespace arc
66 } // namespace circt
67 
68 #endif // CIRCT_DIALECT_ARC_MODELINFO_H
void serializeModelInfoToJson(llvm::raw_ostream &outputStream, llvm::ArrayRef< ModelInfo > models)
Serializes models to outputStream in JSON format.
mlir::LogicalResult collectModels(mlir::ModuleOp module, llvm::SmallVector< ModelInfo > &models)
Collects information about all Arc models in the provided module, and adds it to models.
mlir::LogicalResult collectStates(mlir::Value storage, unsigned offset, llvm::SmallVector< StateInfo > &states)
Collects information about states within the provided Arc model storage storage, assuming default off...
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Gathers information about a given Arc model.
Definition: ModelInfo.h:35
llvm::SmallVector< StateInfo > states
Definition: ModelInfo.h:38
mlir::FlatSymbolRefAttr initialFnSym
Definition: ModelInfo.h:39
std::string name
Definition: ModelInfo.h:36
mlir::FlatSymbolRefAttr finalFnSym
Definition: ModelInfo.h:40
ModelInfo(std::string name, size_t numStateBytes, llvm::SmallVector< StateInfo > states, mlir::FlatSymbolRefAttr initialFnSym, mlir::FlatSymbolRefAttr finalFnSym)
Definition: ModelInfo.h:42
Gathers information about a given Arc state.
Definition: ModelInfo.h:25
unsigned memoryStride
Definition: ModelInfo.h:30
unsigned memoryDepth
Definition: ModelInfo.h:31
std::string name
Definition: ModelInfo.h:27
enum circt::arc::StateInfo::Type type