CIRCT  19.0.0git
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/Tools/mlir-translate/Translation.h"
17 
18 using namespace llvm;
19 using namespace mlir;
20 using namespace circt;
21 using namespace arc;
22 
23 LogicalResult 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  });
41 }
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.
Definition: DebugAnalysis.h:21