CIRCT  18.0.0git
LogicExporter.h
Go to the documentation of this file.
1 //===- LogicExporter.cpp - class to extrapolate CIRCT IR logic --*- C++ -*-===//
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 /// This file defines the logic-exporting class for the `circt-lec` tool.
10 ///
11 //===----------------------------------------------------------------------===//
12 
13 // NOLINTNEXTLINE
14 #ifndef TOOLS_CIRCT_LEC_LOGICEXPORTER_H
15 #define TOOLS_CIRCT_LEC_LOGICEXPORTER_H
16 
17 #include "Solver.h"
20 #include "circt/Dialect/HW/HWOps.h"
22 #include "mlir/IR/BuiltinOps.h"
23 #include "mlir/Support/LogicalResult.h"
24 #include "llvm/ADT/StringRef.h"
25 #include <string>
26 
27 namespace circt {
28 
29 /// A class traversing MLIR IR to extrapolate the logic of a given circuit.
30 ///
31 /// This class implements a MLIR exporter which searches the IR for the
32 /// specified `hw.module` describing a circuit. It will then traverse its
33 /// operations and collect the underlying logical constraints within an
34 /// abstract circuit representation.
36 public:
39 
40  /// Initializes the exporting by visiting the builtin module.
41  mlir::LogicalResult run(mlir::ModuleOp &module);
42  mlir::LogicalResult run(hw::HWModuleOp &module);
43 
44 private:
45  // For Solver::Circuit::addInstance to access Visitor::visitHW.
46  friend Solver::Circuit;
47 
48  /// The specified module name to look for when traversing the input file.
49  std::string moduleName;
50  /// The circuit representation to hold the logical constraints extracted
51  /// from the IR.
53 };
54 
55 } // namespace circt
56 
57 #endif // TOOLS_CIRCT_LEC_LOGICEXPORTER_H
A class traversing MLIR IR to extrapolate the logic of a given circuit.
Definition: LogicExporter.h:35
std::string moduleName
The specified module name to look for when traversing the input file.
Definition: LogicExporter.h:49
LogicExporter(llvm::StringRef moduleName, Solver::Circuit *circuit)
Definition: LogicExporter.h:37
mlir::LogicalResult run(mlir::ModuleOp &module)
Initializes the exporting by visiting the builtin module.
Solver::Circuit * circuit
The circuit representation to hold the logical constraints extracted from the IR.
Definition: LogicExporter.h:52
The representation of a circuit within a logical engine.
Definition: Circuit.h:35
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
Definition: DebugAnalysis.h:21