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 
41  ModelInfo(std::string name, size_t numStateBytes,
42  llvm::SmallVector<StateInfo> states,
43  mlir::FlatSymbolRefAttr initialFnSym)
44  : name(std::move(name)), numStateBytes(numStateBytes),
45  states(std::move(states)), initialFnSym(initialFnSym) {}
46 };
47 
48 /// Collects information about states within the provided Arc model storage
49 /// `storage`, assuming default `offset`, and adds it to `states`.
50 mlir::LogicalResult collectStates(mlir::Value storage, unsigned offset,
51  llvm::SmallVector<StateInfo> &states);
52 
53 /// Collects information about all Arc models in the provided `module`,
54 /// and adds it to `models`.
55 mlir::LogicalResult collectModels(mlir::ModuleOp module,
56  llvm::SmallVector<ModelInfo> &models);
57 
58 /// Serializes `models` to `outputStream` in JSON format.
59 void serializeModelInfoToJson(llvm::raw_ostream &outputStream,
60  llvm::ArrayRef<ModelInfo> models);
61 
62 } // namespace arc
63 } // namespace circt
64 
65 #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
ModelInfo(std::string name, size_t numStateBytes, llvm::SmallVector< StateInfo > states, mlir::FlatSymbolRefAttr initialFnSym)
Definition: ModelInfo.h:41
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