CIRCT 22.0.0git
Loading...
Searching...
No Matches
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
17#include "mlir/IR/BuiltinOps.h"
18#include "llvm/ADT/SmallVector.h"
19#include "llvm/Support/raw_ostream.h"
20#include <string>
21
22namespace circt {
23namespace arc {
24
25/// Gathers information about a given Arc state.
26struct StateInfo {
28 std::string name;
29 unsigned offset;
30 unsigned numBits;
31 unsigned memoryStride = 0; // byte separation between memory words
32 unsigned memoryDepth = 0; // number of words in a memory
33};
34
35/// Gathers information about a given Arc model.
36struct ModelInfo {
37 std::string name;
39 llvm::SmallVector<StateInfo> states;
40 mlir::FlatSymbolRefAttr initialFnSym;
41 mlir::FlatSymbolRefAttr finalFnSym;
42
43 ModelInfo(std::string name, size_t numStateBytes,
44 llvm::SmallVector<StateInfo> states,
45 mlir::FlatSymbolRefAttr initialFnSym,
46 mlir::FlatSymbolRefAttr finalFnSym)
47 : name(std::move(name)), numStateBytes(numStateBytes),
50};
51
53 explicit ModelInfoAnalysis(Operation *container);
54 llvm::DenseMap<ModelOp, ModelInfo> infoMap;
55};
56
57/// Collects information about states within the provided Arc model storage
58/// `storage`, assuming default `offset`, and adds it to `states`.
59mlir::LogicalResult collectStates(mlir::Value storage, unsigned offset,
60 llvm::SmallVector<StateInfo> &states);
61
62/// Collects information about all Arc models in the provided `module`,
63/// and adds it to `models`.
64mlir::LogicalResult collectModels(mlir::ModuleOp module,
65 llvm::SmallVector<ModelInfo> &models);
66
67/// Serializes `models` to `outputStream` in JSON format.
68void serializeModelInfoToJson(llvm::raw_ostream &outputStream,
69 llvm::ArrayRef<ModelInfo> models);
70
71} // namespace arc
72} // namespace circt
73
74#endif // CIRCT_DIALECT_ARC_MODELINFO_H
Definition arc.py:1
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.
llvm::DenseMap< ModelOp, ModelInfo > infoMap
Definition ModelInfo.h:54
Gathers information about a given Arc model.
Definition ModelInfo.h:36
llvm::SmallVector< StateInfo > states
Definition ModelInfo.h:39
mlir::FlatSymbolRefAttr initialFnSym
Definition ModelInfo.h:40
mlir::FlatSymbolRefAttr finalFnSym
Definition ModelInfo.h:41
ModelInfo(std::string name, size_t numStateBytes, llvm::SmallVector< StateInfo > states, mlir::FlatSymbolRefAttr initialFnSym, mlir::FlatSymbolRefAttr finalFnSym)
Definition ModelInfo.h:43
Gathers information about a given Arc state.
Definition ModelInfo.h:26
enum circt::arc::StateInfo::Type type