CIRCT 24.0.0git
Loading...
Searching...
No Matches
ModelInfoExport.cpp
Go to the documentation of this file.
1//===- ModelInfoExport.cpp - Exports model info to JSON format ------------===//
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// Register the MLIR translation to export model info to JSON format.
10//
11//===----------------------------------------------------------------------===//
12
16#include "mlir/Dialect/Func/IR/FuncOps.h"
17#include "mlir/Tools/mlir-translate/Translation.h"
18
19using namespace mlir;
20using namespace circt;
21using namespace arc;
22
23LogicalResult circt::arc::collectAndExportModelInfo(ModuleOp module,
24 llvm::raw_ostream &os) {
25 SmallVector<ModelInfo> models;
26 if (failed(collectModels(module, models)))
27 return failure();
28 serializeModelInfoToJson(os, models);
29 return success();
30}
31
33 static mlir::TranslateFromMLIRRegistration modelInfoToJson(
34 "export-arc-model-info", "export Arc model info in JSON format",
35 [](ModuleOp module, llvm::raw_ostream &os) {
36 return arc::collectAndExportModelInfo(module, os);
37 },
38 [](mlir::DialectRegistry &registry) {
39 registry.insert<arc::ArcDialect>();
40 registry.insert<func::FuncDialect>();
41 });
42}
false return failure()
Parse an optional keyword or string and set instance into 'result'.
return success()
Definition arc.py:1
mlir::LogicalResult collectAndExportModelInfo(mlir::ModuleOp module, llvm::raw_ostream &os)
Collects and exports Arc model info to JSON.
void registerArcModelInfoTranslation()
Registers CIRCT translation from Arc to JSON model info.
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.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.