|
CIRCT 23.0.0git
|
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"#include "circt/Dialect/FIRRTL/FIRRTLOps.h"#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"#include "circt/Dialect/FIRRTL/Passes.h"#include "circt/Support/Debug.h"#include "circt/Support/Namespace.h"#include "mlir/IR/Iterators.h"#include "mlir/IR/Threading.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/TinyPtrVector.h"#include "circt/Dialect/FIRRTL/Passes.h.inc"
Go to the source code of this file.
Namespaces | |
| namespace | circt |
| The InstanceGraph op interface, see InstanceGraphInterface.td for more details. | |
| namespace | circt::firrtl |
Macros | |
| #define | DEBUG_TYPE "firrtl-infer-domains" |
| #define | GEN_PASS_DEF_INFERDOMAINS |
Typedefs | |
| using | DomainValue = mlir::TypedValue< DomainType > |
| using | PortInsertions = SmallVector< std::pair< unsigned, PortInfo > > |
| using | ModuleUpdateTable = DenseMap< StringAttr, ModuleUpdateInfo > |
| using | ExportTable = DenseMap< DomainValue, TinyPtrVector< DomainValue > > |
| A map from domain IR values defined internal to the moduleOp, to ports that alias that domain. | |
| using | PendingSolutions = DenseMap< VariableTerm *, unsigned > |
| A map from unsolved variables to a port index, where that port has not yet been created. | |
| using | PendingExports = llvm::MapVector< DomainValue, unsigned > |
| A map from local domains to an aliasing port index, where that port has not yet been created. | |
Functions | |
| static auto | getPortDomainAssociation (ArrayAttr info, size_t i) |
| From a domain info attribute, get the row of associated domains for a hardware value at index i. | |
| static bool | isPort (BlockArgument arg) |
| Return true if the value is a port on the module. | |
| static bool | isPort (Value value) |
| Return true if the value is a port on the module. | |
| static bool | isDriven (DomainValue port) |
| Returns true if the value is driven by a connect op. | |
| static FInstanceLike | fixInstancePorts (FInstanceLike op, const ModuleUpdateInfo &update) |
| Apply the port changes of a moduleOp onto an instance-like op. | |
| static Term * | find (Term *x) |
| static void | render (const DomainInfo &info, Diagnostic &out, VariableIDTable &idTable, Term *term) |
| static LogicalResult | unify (Term *lhs, Term *rhs) |
| static LogicalResult | unify (VariableTerm *x, Term *y) |
| static LogicalResult | unify (ValueTerm *xv, Term *y) |
| static LogicalResult | unify (RowTerm *lhsRow, Term *rhs) |
| static void | solve (Term *lhs, Term *rhs) |
| static Term * | getTermForDomain (TermAllocator &allocator, DomainTable &table, DomainValue value) |
| Get the corresponding term for a domain in the IR. | |
| static void | processDomainDefinition (TermAllocator &allocator, DomainTable &table, DomainValue domain) |
| static RowTerm * | getDomainAssociationAsRow (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, Value value) |
| Get the row of domains that a hardware value in the IR is associated with. | |
| static void | noteLocation (mlir::InFlightDiagnostic &diag, Operation *op) |
| template<typename T > | |
| static void | emitPortDomainCrossingError (const DomainInfo &info, T op, size_t i, DomainTypeID domainTypeID, Term *term1, Term *term2) |
| template<typename T > | |
| static void | emitDuplicatePortDomainError (const DomainInfo &info, T op, size_t i, DomainTypeID domainTypeID, IntegerAttr domainPortIndexAttr1, IntegerAttr domainPortIndexAttr2) |
| template<typename T > | |
| static void | emitDomainPortInferenceError (T op, size_t i) |
| Emit an error when we fail to infer the concrete domain to drive to a domain port. | |
| template<typename T > | |
| static void | emitAmbiguousPortDomainAssociation (const DomainInfo &info, T op, const llvm::TinyPtrVector< DomainValue > &exports, DomainTypeID typeID, size_t i) |
| template<typename T > | |
| static void | emitMissingPortDomainAssociationError (const DomainInfo &info, T op, DomainTypeID typeID, size_t i) |
| static LogicalResult | unifyAssociations (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, Operation *op, Value lhs, Value rhs) |
| Unify the associated domain rows of two terms. | |
| static LogicalResult | processModulePorts (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, FModuleOp moduleOp) |
| template<typename T > | |
| static LogicalResult | processInstancePorts (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, T op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, const ModuleUpdateTable &updateTable, FInstanceLike op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, UnsafeDomainCastOp op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, DomainDefineOp op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, WireOp op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, const ModuleUpdateTable &updateTable, Operation *op) |
| static LogicalResult | processModuleBody (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, const ModuleUpdateTable &updateTable, FModuleOp moduleOp) |
| static LogicalResult | processModule (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, const ModuleUpdateTable &updateTable, FModuleOp moduleOp) |
| Populate the domain table by processing the moduleOp. | |
| static ExportTable | initializeExportTable (const DomainTable &table, FModuleOp moduleOp) |
| Build a table of exported domains: a map from domains defined internally, to their set of aliasing output ports. | |
| static void | ensureSolved (const DomainInfo &info, Namespace &ns, DomainTypeID typeID, size_t ip, LocationAttr loc, VariableTerm *var, PendingUpdates &pending) |
If var is not solved, solve it by recording a pending input port at the indicated insertion point. | |
| static void | ensureExported (const DomainInfo &info, Namespace &ns, const ExportTable &exports, DomainTypeID typeID, size_t ip, LocationAttr loc, ValueTerm *val, PendingUpdates &pending) |
| Ensure that the domain value is available in the signature of the moduleOp, so that subsequent hardware ports may be associated with this domain. | |
| static void | getUpdatesForDomainAssociationOfPort (const DomainInfo &info, Namespace &ns, PendingUpdates &pending, DomainTypeID typeID, size_t ip, LocationAttr loc, Term *term, const ExportTable &exports) |
| static void | getUpdatesForDomainAssociationOfPort (const DomainInfo &info, Namespace &ns, const ExportTable &exports, size_t ip, LocationAttr loc, RowTerm *row, PendingUpdates &pending) |
| static void | getUpdatesForModulePorts (const DomainInfo &info, TermAllocator &allocator, const ExportTable &exports, DomainTable &table, Namespace &ns, FModuleOp moduleOp, PendingUpdates &pending) |
| static void | getUpdatesForModule (const DomainInfo &info, TermAllocator &allocator, const ExportTable &exports, DomainTable &table, FModuleOp mod, PendingUpdates &pending) |
| static void | applyUpdatesToModule (const DomainInfo &info, TermAllocator &allocator, ExportTable &exports, DomainTable &table, FModuleOp moduleOp, const PendingUpdates &pending) |
| static SmallVector< Attribute > | copyPortDomainAssociations (const DomainInfo &info, FModuleLike moduleOp, ArrayAttr moduleDomainInfo, size_t portIndex) |
| Copy the domain associations from the moduleOp domain info attribute into a small vector. | |
| static LogicalResult | driveModuleOutputDomainPorts (const DomainInfo &info, const DomainTable &table, FModuleOp moduleOp) |
| static LogicalResult | updateModuleDomainInfo (const DomainInfo &info, const DomainTable &table, const ExportTable &exportTable, ArrayAttr &result, FModuleOp moduleOp) |
| After generalizing the moduleOp, all domains should be solved. | |
| static LogicalResult | updateInstance (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, FInstanceLike op, OpBuilder &builder) |
| static LogicalResult | updateWire (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, WireOp wireOp) |
| Update a wire operation with inferred domain associations. | |
| static LogicalResult | updateModuleBody (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, FModuleOp moduleOp) |
| After updating the port domain associations, walk the body of the moduleOp to fix up any child instance modules and update wires with inferred domains. | |
| static LogicalResult | updateModule (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, ModuleUpdateTable &updates, FModuleOp op) |
| Write the domain associations recorded in the domain table back to the IR. | |
| static LogicalResult | checkModulePorts (const DomainInfo &info, FModuleLike moduleOp) |
| Check that a module's hardware ports have complete domain associations. | |
| static LogicalResult | checkModuleDomainPortDrivers (const DomainInfo &info, FModuleOp moduleOp) |
| Check that output domain ports are driven. | |
| static LogicalResult | checkInstanceDomainPortDrivers (FInstanceLike op) |
| Check that the input domain ports are driven. | |
| static LogicalResult | checkModuleBody (FModuleOp moduleOp) |
| Check that instances under this module have driven domain input ports. | |
| static LogicalResult | stripModule (FModuleLike op) |
| static LogicalResult | stripCircuit (MLIRContext *context, CircuitOp circuit) |
| static LogicalResult | inferModule (const DomainInfo &info, ModuleUpdateTable &updates, FModuleOp moduleOp) |
| Solve for domains and then write the domain associations back to the IR. | |
| static LogicalResult | checkModule (const DomainInfo &info, FModuleOp moduleOp) |
| Check that a module's ports are fully annotated, before performing domain inference on the module. | |
| static LogicalResult | checkModule (const DomainInfo &info, FExtModuleOp moduleOp) |
| Check that an extmodule's ports are fully annotated. | |
| static LogicalResult | checkAndInferModule (const DomainInfo &info, ModuleUpdateTable &updateTable, FModuleOp moduleOp) |
| Check that a module's ports are fully annotated, before performing domain inference on the module. | |
| static LogicalResult | runOnModuleLike (InferDomainsMode mode, const DomainInfo &info, ModuleUpdateTable &updateTable, Operation *op) |
| #define DEBUG_TYPE "firrtl-infer-domains" |
Definition at line 33 of file InferDomains.cpp.
| #define GEN_PASS_DEF_INFERDOMAINS |
Definition at line 37 of file InferDomains.cpp.
| using DomainValue = mlir::TypedValue<DomainType> |
Definition at line 52 of file InferDomains.cpp.
| using ExportTable = DenseMap<DomainValue, TinyPtrVector<DomainValue> > |
A map from domain IR values defined internal to the moduleOp, to ports that alias that domain.
These ports make the domain useable as associations of ports, and we say these are exporting ports.
Definition at line 970 of file InferDomains.cpp.
| using ModuleUpdateTable = DenseMap<StringAttr, ModuleUpdateInfo> |
Definition at line 156 of file InferDomains.cpp.
| using PendingExports = llvm::MapVector<DomainValue, unsigned> |
A map from local domains to an aliasing port index, where that port has not yet been created.
Eventually we will be exporting the domain value at the port index.
Definition at line 1002 of file InferDomains.cpp.
| using PendingSolutions = DenseMap<VariableTerm *, unsigned> |
A map from unsolved variables to a port index, where that port has not yet been created.
Eventually we will have an input domain at the port index, which will be the solution to the recorded variable.
Definition at line 997 of file InferDomains.cpp.
| using PortInsertions = SmallVector<std::pair<unsigned, PortInfo> > |
Definition at line 54 of file InferDomains.cpp.
|
static |
|
static |
Check that a module's ports are fully annotated, before performing domain inference on the module.
We use this when private module interfaces are inferred but public module interfaces are checked.
Definition at line 1623 of file InferDomains.cpp.
References checkModulePorts(), driveModuleOutputDomainPorts(), processModule(), and updateModuleBody().
Referenced by runOnModuleLike().
|
static |
Check that the input domain ports are driven.
Definition at line 1469 of file InferDomains.cpp.
References isDriven(), and noteLocation().
Referenced by checkModuleBody().
|
static |
Check that an extmodule's ports are fully annotated.
Definition at line 1615 of file InferDomains.cpp.
References checkModulePorts().
|
static |
Check that a module's ports are fully annotated, before performing domain inference on the module.
Definition at line 1598 of file InferDomains.cpp.
References checkModuleBody(), checkModuleDomainPortDrivers(), checkModulePorts(), and processModule().
Referenced by runOnModuleLike().
|
static |
Check that instances under this module have driven domain input ports.
Definition at line 1489 of file InferDomains.cpp.
References checkInstanceDomainPortDrivers().
Referenced by checkModule().
|
static |
Check that output domain ports are driven.
Definition at line 1450 of file InferDomains.cpp.
References isDriven(), and noteLocation().
Referenced by checkModule().
|
static |
Check that a module's hardware ports have complete domain associations.
Definition at line 1406 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), emitMissingPortDomainAssociationError(), and getPortDomainAssociation().
Referenced by checkAndInferModule(), checkModule(), and checkModule().
|
static |
Copy the domain associations from the moduleOp domain info attribute into a small vector.
Definition at line 1156 of file InferDomains.cpp.
References getPortDomainAssociation().
Referenced by updateModuleDomainInfo().
|
static |
Definition at line 1171 of file InferDomains.cpp.
References emitDomainPortInferenceError(), and isDriven().
Referenced by checkAndInferModule(), and updateModule().
|
static |
Definition at line 621 of file InferDomains.cpp.
References noteLocation().
Referenced by updateModuleDomainInfo().
|
static |
Emit an error when we fail to infer the concrete domain to drive to a domain port.
Definition at line 600 of file InferDomains.cpp.
References noteLocation().
Referenced by driveModuleOutputDomainPorts().
|
static |
Definition at line 573 of file InferDomains.cpp.
References noteLocation().
Referenced by checkModulePorts(), processInstancePorts(), and processModulePorts().
|
static |
Definition at line 641 of file InferDomains.cpp.
References noteLocation().
Referenced by checkModulePorts().
|
static |
Definition at line 548 of file InferDomains.cpp.
References noteLocation(), and render().
|
static |
Ensure that the domain value is available in the signature of the moduleOp, so that subsequent hardware ports may be associated with this domain.
output port.
Definition at line 1044 of file InferDomains.cpp.
References assert(), context, isPort(), and circt::Namespace::newName().
Referenced by getUpdatesForDomainAssociationOfPort().
|
static |
If var is not solved, solve it by recording a pending input port at the indicated insertion point.
Definition at line 1014 of file InferDomains.cpp.
References context, and circt::Namespace::newName().
Referenced by getUpdatesForDomainAssociationOfPort().
|
static |
Definition at line 223 of file InferDomains.cpp.
References find().
Referenced by find(), circt::arc::ArcCostModel::getShufflingCost(), getUpdatesForDomainAssociationOfPort(), render(), unify(), updateModuleDomainInfo(), and updateWire().
|
static |
Apply the port changes of a moduleOp onto an instance-like op.
Definition at line 159 of file InferDomains.cpp.
Referenced by processOp().
|
static |
Get the row of domains that a hardware value in the IR is associated with.
The returned term is forced to be at least a row.
Definition at line 497 of file InferDomains.cpp.
References assert(), and solve().
Referenced by getUpdatesForModulePorts(), and processOp().
|
static |
From a domain info attribute, get the row of associated domains for a hardware value at index i.
Definition at line 58 of file InferDomains.cpp.
Referenced by checkModulePorts(), copyPortDomainAssociations(), processInstancePorts(), and processModulePorts().
|
static |
Get the corresponding term for a domain in the IR.
If we don't know what the term is, then map the domain in the IR to a variable term.
Definition at line 471 of file InferDomains.cpp.
References assert().
Referenced by processInstancePorts(), processModulePorts(), processOp(), processOp(), processOp(), and updateInstance().
|
static |
Definition at line 1090 of file InferDomains.cpp.
References find(), and getUpdatesForDomainAssociationOfPort().
|
static |
Definition at line 1073 of file InferDomains.cpp.
References ensureExported(), and ensureSolved().
Referenced by getUpdatesForDomainAssociationOfPort(), and getUpdatesForModulePorts().
|
static |
Definition at line 1115 of file InferDomains.cpp.
References circt::Namespace::add(), and getUpdatesForModulePorts().
Referenced by updateModule().
|
static |
Definition at line 1098 of file InferDomains.cpp.
References getDomainAssociationAsRow(), and getUpdatesForDomainAssociationOfPort().
Referenced by getUpdatesForModule().
|
static |
Solve for domains and then write the domain associations back to the IR.
Definition at line 1584 of file InferDomains.cpp.
References processModule(), and updateModule().
Referenced by runOnModuleLike().
|
static |
Build a table of exported domains: a map from domains defined internally, to their set of aliasing output ports.
Definition at line 974 of file InferDomains.cpp.
Referenced by updateModule().
|
static |
Returns true if the value is driven by a connect op.
Definition at line 78 of file InferDomains.cpp.
Referenced by checkInstanceDomainPortDrivers(), checkModuleDomainPortDrivers(), driveModuleOutputDomainPorts(), and updateInstance().
|
static |
Return true if the value is a port on the module.
Definition at line 65 of file InferDomains.cpp.
Referenced by ensureExported(), and isPort().
|
static |
Return true if the value is a port on the module.
Definition at line 70 of file InferDomains.cpp.
References isPort().
|
static |
Definition at line 525 of file InferDomains.cpp.
Referenced by checkInstanceDomainPortDrivers(), checkModuleDomainPortDrivers(), emitAmbiguousPortDomainAssociation(), emitDomainPortInferenceError(), emitDuplicatePortDomainError(), emitMissingPortDomainAssociationError(), emitPortDomainCrossingError(), and updateModuleDomainInfo().
|
static |
Definition at line 481 of file InferDomains.cpp.
References assert(), and unify().
Referenced by processInstancePorts(), processModulePorts(), and processOp().
|
static |
Definition at line 756 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), getPortDomainAssociation(), getTermForDomain(), and processDomainDefinition().
Referenced by DiscoverLoops::handleInstanceChoiceOp(), DiscoverLoops::handleInstanceOp(), and processOp().
|
static |
Populate the domain table by processing the moduleOp.
If the moduleOp has any domain crossing errors, return failure.
Definition at line 952 of file InferDomains.cpp.
References processModuleBody(), and processModulePorts().
Referenced by checkAndInferModule(), checkModule(), and inferModule().
|
static |
Definition at line 937 of file InferDomains.cpp.
Referenced by processModule().
|
static |
Definition at line 698 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), getPortDomainAssociation(), getTermForDomain(), and processDomainDefinition().
Referenced by processModule().
|
static |
Definition at line 812 of file InferDomains.cpp.
References fixInstancePorts(), and processInstancePorts().
Referenced by processOp().
|
static |
Definition at line 889 of file InferDomains.cpp.
References processDomainDefinition(), processOp(), and unifyAssociations().
|
static |
Definition at line 845 of file InferDomains.cpp.
References circt::firrtl::getFieldName(), getTermForDomain(), render(), and unify().
|
static |
Definition at line 824 of file InferDomains.cpp.
References getDomainAssociationAsRow(), getTermForDomain(), and unifyAssociations().
|
static |
Definition at line 865 of file InferDomains.cpp.
References getTermForDomain().
|
static |
Definition at line 254 of file InferDomains.cpp.
References find(), circt::firrtl::getFieldName(), and render().
Referenced by emitPortDomainCrossingError(), processOp(), render(), and unifyAssociations().
|
static |
Definition at line 1640 of file InferDomains.cpp.
References assert(), checkAndInferModule(), checkModule(), and inferModule().
|
static |
Definition at line 336 of file InferDomains.cpp.
References assert(), and unify().
Referenced by applyUpdatesToModule(), getDomainAssociationAsRow(), and updateInstance().
|
static |
Definition at line 1569 of file InferDomains.cpp.
References context, and stripModule().
|
static |
Definition at line 1500 of file InferDomains.cpp.
Referenced by stripCircuit().
|
static |
Definition at line 305 of file InferDomains.cpp.
References unify().
|
static |
Definition at line 320 of file InferDomains.cpp.
References find(), and unify().
Referenced by processDomainDefinition(), processOp(), solve(), unify(), unify(), and unifyAssociations().
|
static |
Definition at line 292 of file InferDomains.cpp.
|
static |
Definition at line 286 of file InferDomains.cpp.
References assert().
|
static |
Unify the associated domain rows of two terms.
Definition at line 653 of file InferDomains.cpp.
References render(), and unify().
Referenced by processOp(), and processOp().
|
static |
Definition at line 1272 of file InferDomains.cpp.
References getTermForDomain(), isDriven(), and solve().
Referenced by updateModuleBody().
|
static |
Write the domain associations recorded in the domain table back to the IR.
Definition at line 1373 of file InferDomains.cpp.
References applyUpdatesToModule(), driveModuleOutputDomainPorts(), getUpdatesForModule(), initializeExportTable(), updateModuleBody(), and updateModuleDomainInfo().
Referenced by inferModule().
|
static |
After updating the port domain associations, walk the body of the moduleOp to fix up any child instance modules and update wires with inferred domains.
Definition at line 1349 of file InferDomains.cpp.
References updateInstance(), and updateWire().
Referenced by checkAndInferModule(), and updateModule().
|
static |
After generalizing the moduleOp, all domains should be solved.
Reflect the solved domain associations into the port domain info attribute.
Definition at line 1198 of file InferDomains.cpp.
References context, copyPortDomainAssociations(), emitAmbiguousPortDomainAssociation(), find(), and noteLocation().
Referenced by updateModule().
|
static |
Update a wire operation with inferred domain associations.
Definition at line 1317 of file InferDomains.cpp.
References find().
Referenced by updateModuleBody().