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