CIRCT  20.0.0git
ExportTcl.h
Go to the documentation of this file.
1 //===- ExportTcl.h - MSFT Tcl Exporters -------------------------*- 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 // Expose the Tcl exporters.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef CIRCT_DIALECT_MSFT_EXPORTTCL_H
14 #define CIRCT_DIALECT_MSFT_EXPORTTCL_H
15 
18 #include "circt/Support/LLVM.h"
19 
20 #include "llvm/ADT/MapVector.h"
21 #include "llvm/ADT/StringRef.h"
22 
23 namespace circt {
24 namespace msft {
25 class MSFTModuleOp;
26 
27 /// Instantiate for all Tcl emissions. We want to cache the symbols and binned
28 /// ops -- this helper class provides that caching.
29 class TclEmitter {
30 public:
31  TclEmitter(mlir::ModuleOp topLevel);
32  LogicalResult emit(Operation *hwMod, StringRef outputFile);
33 
34  Operation *getDefinition(FlatSymbolRefAttr);
35  const DenseSet<hw::HierPathOp> &getRefsUsed() { return refsUsed; }
36  void usedRef(hw::HierPathOp ref) { refsUsed.insert(ref); }
37 
38 private:
39  mlir::ModuleOp topLevel;
40 
41  bool populated;
43 
44  /// Map Module operations to their top-level "instance" names. Map those
45  /// "instance" names to the lowered ops which get directly emitted as tcl.
46  DenseMap<Operation *,
47  llvm::MapVector<StringAttr, SmallVector<DynInstDataOpInterface, 0>>>
49  DenseSet<hw::HierPathOp> refsUsed;
50 
51  LogicalResult populate();
52 };
53 
54 } // namespace msft
55 } // namespace circt
56 
57 #endif // CIRCT_DIALECT_MSFT_EXPORTTCL_H
This stores lookup tables to make manipulating and working with the IR more efficient.
Definition: HWSymCache.h:27
Instantiate for all Tcl emissions.
Definition: ExportTcl.h:29
Operation * getDefinition(FlatSymbolRefAttr)
hw::HWSymbolCache topLevelSymbols
Definition: ExportTcl.h:42
mlir::ModuleOp topLevel
Definition: ExportTcl.h:39
DenseMap< Operation *, llvm::MapVector< StringAttr, SmallVector< DynInstDataOpInterface, 0 > > > tclOpsForModInstance
Map Module operations to their top-level "instance" names.
Definition: ExportTcl.h:48
DenseSet< hw::HierPathOp > refsUsed
Definition: ExportTcl.h:49
LogicalResult emit(Operation *hwMod, StringRef outputFile)
Write out all the relevant tcl commands.
const DenseSet< hw::HierPathOp > & getRefsUsed()
Definition: ExportTcl.h:35
void usedRef(hw::HierPathOp ref)
Definition: ExportTcl.h:36
TclEmitter(mlir::ModuleOp topLevel)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Definition: DebugAnalysis.h:21
Definition: msft.py:1