CIRCT  20.0.0git
Public Types | Public Member Functions | Public Attributes | List of all members
circt::ExportVerilog::SharedEmitterState Struct Reference

This class tracks the top-level state for the emitters, which is built and then shared across all per-file emissions that happen in parallel. More...

#include <ExportVerilogInternals.h>

Collaboration diagram for circt::ExportVerilog::SharedEmitterState:
Collaboration graph
[legend]

Public Types

using EmissionList = std::vector< StringOrOpToEmit >
 

Public Member Functions

 SharedEmitterState (ModuleOp designOp, const LoweringOptions &options, GlobalNameTable globalNames)
 
void gatherFiles (bool separateModules)
 Organize the operations in the root MLIR module into output files to be generated. More...
 
void collectOpsForFile (const FileInfo &fileInfo, EmissionList &thingsToEmit, bool emitHeader=false)
 Given a FileInfo, collect all the replicated and designated operations that go into it and append them to "thingsToEmit". More...
 
void emitOps (EmissionList &thingsToEmit, llvm::formatted_raw_ostream &os, StringAttr fileName, bool parallelize)
 Actually emit the collected list of operations and strings to the specified file. More...
 

Public Attributes

ModuleOp designOp
 The MLIR module to emit. More...
 
FileInfo rootFile
 The main file that collects all operations that are neither replicated per-file ops nor specifically assigned to a file. More...
 
llvm::MapVector< StringAttr, FileInfofiles
 The additional files to emit, with the output file name as the key into the map. More...
 
llvm::StringMap< SmallVector< StringAttr > > fileLists
 The various file lists and their contents to emit. More...
 
SmallVector< Operation *, 0 > replicatedOps
 A list of operations replicated in each output file (e.g., sv.verbatim or sv.ifdef without dedicated output file). More...
 
std::atomic< bool > encounteredError = {}
 Whether any error has been encountered during emission. More...
 
hw::HWSymbolCache symbolCache
 A cache of symbol -> defining ops built once and used by each of the verilog module emitters. More...
 
const LoweringOptionsoptions
 
SmallPtrSet< Operation *, 8 > modulesContainingBinds
 This is a set is populated at "gather" time, containing the hw.module operations that have a sv.bind in them. More...
 
const GlobalNameTable globalNames
 Information about renamed global symbols, parameters, etc. More...
 
FileMapping fileMapping
 Tracks the referenceable files through their symbol. More...
 
FragmentMapping fragmentMapping
 Tracks referenceable files through their symbol. More...
 

Detailed Description

This class tracks the top-level state for the emitters, which is built and then shared across all per-file emissions that happen in parallel.

Definition at line 344 of file ExportVerilogInternals.h.

Member Typedef Documentation

◆ EmissionList

Definition at line 392 of file ExportVerilogInternals.h.

Constructor & Destructor Documentation

◆ SharedEmitterState()

circt::ExportVerilog::SharedEmitterState::SharedEmitterState ( ModuleOp  designOp,
const LoweringOptions options,
GlobalNameTable  globalNames 
)
inlineexplicit

Definition at line 386 of file ExportVerilogInternals.h.

Member Function Documentation

◆ collectOpsForFile()

void SharedEmitterState::collectOpsForFile ( const FileInfo fileInfo,
EmissionList thingsToEmit,
bool  emitHeader = false 
)

◆ emitOps()

void SharedEmitterState::emitOps ( EmissionList thingsToEmit,
llvm::formatted_raw_ostream &  os,
StringAttr  fileName,
bool  parallelize 
)

◆ gatherFiles()

void SharedEmitterState::gatherFiles ( bool  separateModules)

Organize the operations in the root MLIR module into output files to be generated.

If separateModules is true, a handful of top-level declarations will be split into separate output files even in the absence of an explicit output file attribute.

Collect all the inner names from the specified module and add them to the IRCache. Declarations (named things) only exist at the top level of the module. Also keep track of any modules that contain bind operations. These are non-hierarchical references which we need to be careful about during emission.

Collect any port marked as being referenced via symbol.

Definition at line 6557 of file ExportVerilog.cpp.

References circt::hw::HWSymbolCache::addDefinition(), append(), circt::appendPossiblyAbsolutePath(), designOp, encounteredError, fileMapping, files, fragmentMapping, circt::hw::HWSymbolCache::freeze(), circt::calyx::direction::get(), circt::hw::InnerSymbolTable::getInnerSymbolAttrName(), getVerilogModuleName(), modulesContainingBinds, circt::ExportVerilog::FileInfo::ops, replicatedOps, rootFile, and symbolCache.

Referenced by exportSplitVerilogImpl(), and exportVerilogImpl().

Member Data Documentation

◆ designOp

ModuleOp circt::ExportVerilog::SharedEmitterState::designOp

The MLIR module to emit.

Definition at line 346 of file ExportVerilogInternals.h.

Referenced by createOutputFile(), emitOps(), and gatherFiles().

◆ encounteredError

std::atomic<bool> circt::ExportVerilog::SharedEmitterState::encounteredError = {}

Whether any error has been encountered during emission.

Definition at line 364 of file ExportVerilogInternals.h.

Referenced by collectOpsForFile(), createOutputFile(), emitOps(), exportSplitVerilogImpl(), exportVerilogImpl(), and gatherFiles().

◆ fileLists

llvm::StringMap<SmallVector<StringAttr> > circt::ExportVerilog::SharedEmitterState::fileLists

The various file lists and their contents to emit.

Definition at line 357 of file ExportVerilogInternals.h.

Referenced by exportSplitVerilogImpl(), and exportVerilogImpl().

◆ fileMapping

FileMapping circt::ExportVerilog::SharedEmitterState::fileMapping

Tracks the referenceable files through their symbol.

Definition at line 381 of file ExportVerilogInternals.h.

Referenced by emitOps(), and gatherFiles().

◆ files

llvm::MapVector<StringAttr, FileInfo> circt::ExportVerilog::SharedEmitterState::files

The additional files to emit, with the output file name as the key into the map.

Definition at line 354 of file ExportVerilogInternals.h.

Referenced by exportSplitVerilogImpl(), exportVerilogImpl(), and gatherFiles().

◆ fragmentMapping

FragmentMapping circt::ExportVerilog::SharedEmitterState::fragmentMapping

Tracks referenceable files through their symbol.

Definition at line 384 of file ExportVerilogInternals.h.

Referenced by collectOpsForFile(), and gatherFiles().

◆ globalNames

const GlobalNameTable circt::ExportVerilog::SharedEmitterState::globalNames

Information about renamed global symbols, parameters, etc.

Definition at line 378 of file ExportVerilogInternals.h.

Referenced by emitOps().

◆ modulesContainingBinds

SmallPtrSet<Operation *, 8> circt::ExportVerilog::SharedEmitterState::modulesContainingBinds

This is a set is populated at "gather" time, containing the hw.module operations that have a sv.bind in them.

Definition at line 375 of file ExportVerilogInternals.h.

Referenced by emitOps(), and gatherFiles().

◆ options

const LoweringOptions& circt::ExportVerilog::SharedEmitterState::options

◆ replicatedOps

SmallVector<Operation *, 0> circt::ExportVerilog::SharedEmitterState::replicatedOps

A list of operations replicated in each output file (e.g., sv.verbatim or sv.ifdef without dedicated output file).

Definition at line 361 of file ExportVerilogInternals.h.

Referenced by collectOpsForFile(), and gatherFiles().

◆ rootFile

FileInfo circt::ExportVerilog::SharedEmitterState::rootFile

The main file that collects all operations that are neither replicated per-file ops nor specifically assigned to a file.

Definition at line 350 of file ExportVerilogInternals.h.

Referenced by exportVerilogImpl(), and gatherFiles().

◆ symbolCache

hw::HWSymbolCache circt::ExportVerilog::SharedEmitterState::symbolCache

A cache of symbol -> defining ops built once and used by each of the verilog module emitters.

This is built at "gatherFiles" time.

Definition at line 368 of file ExportVerilogInternals.h.

Referenced by emitOps(), and gatherFiles().


The documentation for this struct was generated from the following files: