|
CIRCT 22.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 "llvm/ADT/DenseMap.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/TinyPtrVector.h"#include "llvm/Support/Debug.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 StringAttr | getDomainPortTypeName (ArrayAttr info, size_t i) |
| From a domain info attribute, get the domain-type of a domain value at index i. | |
| 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. | |
| template<typename T > | |
| static T | fixInstancePorts (T 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, InstanceOp op) |
| static LogicalResult | processOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, const ModuleUpdateTable &updateTable, InstanceChoiceOp 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, 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, 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. | |
| template<typename T > | |
| static LogicalResult | updateInstance (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, T op) |
| static LogicalResult | updateOp (const DomainInfo &info, TermAllocator &allocator, DomainTable &table, Operation *op) |
| 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. | |
| 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. | |
| template<typename T > | |
| static LogicalResult | checkInstanceDomainPortDrivers (T op) |
| Check that the input domain ports are driven. | |
| static LogicalResult | checkOp (Operation *op) |
| static LogicalResult | checkModuleBody (FModuleOp moduleOp) |
| Check that instances under this module have driven domain input ports. | |
| 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 26 of file InferDomains.cpp.
| #define GEN_PASS_DEF_INFERDOMAINS |
Definition at line 30 of file InferDomains.cpp.
| using DomainValue = mlir::TypedValue<DomainType> |
Definition at line 42 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 967 of file InferDomains.cpp.
| using ModuleUpdateTable = DenseMap<StringAttr, ModuleUpdateInfo> |
Definition at line 176 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 999 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 994 of file InferDomains.cpp.
| using PortInsertions = SmallVector<std::pair<unsigned, PortInfo> > |
Definition at line 44 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 1497 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 1420 of file InferDomains.cpp.
References isDriven(), and noteLocation().
Referenced by checkOp().
|
static |
Check that an extmodule's ports are fully annotated.
Definition at line 1489 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 1472 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 1447 of file InferDomains.cpp.
References checkOp().
Referenced by checkModule().
|
static |
Check that output domain ports are driven.
Definition at line 1400 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 1356 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), emitMissingPortDomainAssociationError(), and getPortDomainAssociation().
Referenced by checkAndInferModule(), checkModule(), and checkModule().
|
static |
Definition at line 1438 of file InferDomains.cpp.
References checkInstanceDomainPortDrivers().
Referenced by checkModuleBody().
|
static |
Copy the domain associations from the moduleOp domain info attribute into a small vector.
Definition at line 1151 of file InferDomains.cpp.
References getPortDomainAssociation().
Referenced by updateModuleDomainInfo().
|
static |
Definition at line 1166 of file InferDomains.cpp.
References emitDomainPortInferenceError(), and isDriven().
Referenced by checkAndInferModule(), and updateModule().
|
static |
Definition at line 641 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 620 of file InferDomains.cpp.
References noteLocation().
Referenced by driveModuleOutputDomainPorts().
|
static |
Definition at line 593 of file InferDomains.cpp.
References noteLocation().
Referenced by checkModulePorts(), processInstancePorts(), and processModulePorts().
|
static |
Definition at line 661 of file InferDomains.cpp.
References noteLocation().
Referenced by checkModulePorts().
|
static |
Definition at line 568 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 1040 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 1011 of file InferDomains.cpp.
References context, and circt::Namespace::newName().
Referenced by getUpdatesForDomainAssociationOfPort().
|
static |
Definition at line 243 of file InferDomains.cpp.
References find().
Referenced by find(), circt::arc::ArcCostModel::getShufflingCost(), getUpdatesForDomainAssociationOfPort(), render(), unify(), and updateModuleDomainInfo().
|
static |
Apply the port changes of a moduleOp onto an instance-like op.
Definition at line 180 of file InferDomains.cpp.
Referenced by processOp(), and 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 517 of file InferDomains.cpp.
References assert(), and solve().
Referenced by getUpdatesForModulePorts(), and processOp().
|
static |
From a domain info attribute, get the domain-type of a domain value at index i.
Definition at line 48 of file InferDomains.cpp.
Referenced by updateInstance().
|
static |
From a domain info attribute, get the row of associated domains for a hardware value at index i.
Definition at line 56 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 491 of file InferDomains.cpp.
References assert().
Referenced by processInstancePorts(), processModulePorts(), processOp(), processOp(), and updateInstance().
|
static |
Definition at line 1085 of file InferDomains.cpp.
References find(), and getUpdatesForDomainAssociationOfPort().
|
static |
Definition at line 1068 of file InferDomains.cpp.
References ensureExported(), and ensureSolved().
Referenced by getUpdatesForDomainAssociationOfPort(), and getUpdatesForModulePorts().
|
static |
Definition at line 1110 of file InferDomains.cpp.
References circt::Namespace::add(), and getUpdatesForModulePorts().
Referenced by updateModule().
|
static |
Definition at line 1093 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 1458 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 971 of file InferDomains.cpp.
Referenced by updateModule().
|
static |
Returns true if the value is driven by a connect op.
Definition at line 76 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 63 of file InferDomains.cpp.
Referenced by ensureExported(), and isPort().
|
static |
Return true if the value is a port on the module.
Definition at line 68 of file InferDomains.cpp.
References isPort().
|
static |
Definition at line 545 of file InferDomains.cpp.
Referenced by checkInstanceDomainPortDrivers(), checkModuleDomainPortDrivers(), emitAmbiguousPortDomainAssociation(), emitDomainPortInferenceError(), emitDuplicatePortDomainError(), emitMissingPortDomainAssociationError(), emitPortDomainCrossingError(), and updateModuleDomainInfo().
|
static |
Definition at line 501 of file InferDomains.cpp.
References assert(), and unify().
Referenced by processInstancePorts(), and processModulePorts().
|
static |
Definition at line 776 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), getPortDomainAssociation(), getTermForDomain(), and processDomainDefinition().
Referenced by processOp(), and processOp().
|
static |
Populate the domain table by processing the moduleOp.
If the moduleOp has any domain crossing errors, return failure.
Definition at line 949 of file InferDomains.cpp.
References processModuleBody(), and processModulePorts().
Referenced by checkAndInferModule(), checkModule(), and inferModule().
|
static |
Definition at line 936 of file InferDomains.cpp.
References processOp().
Referenced by processModule().
|
static |
Definition at line 718 of file InferDomains.cpp.
References emitDuplicatePortDomainError(), getPortDomainAssociation(), getTermForDomain(), and processDomainDefinition().
Referenced by processModule().
|
static |
Definition at line 843 of file InferDomains.cpp.
References fixInstancePorts(), and processInstancePorts().
|
static |
Definition at line 832 of file InferDomains.cpp.
References fixInstancePorts(), and processInstancePorts().
Referenced by processModuleBody(), and processOp().
|
static |
Definition at line 896 of file InferDomains.cpp.
References processOp(), and unifyAssociations().
|
static |
Definition at line 875 of file InferDomains.cpp.
References getTermForDomain(), render(), and unify().
|
static |
Definition at line 854 of file InferDomains.cpp.
References getDomainAssociationAsRow(), getTermForDomain(), and unifyAssociations().
|
static |
Definition at line 274 of file InferDomains.cpp.
References find(), circt::firrtl::getFieldName(), and render().
Referenced by emitPortDomainCrossingError(), processOp(), render(), and unifyAssociations().
|
static |
Definition at line 1514 of file InferDomains.cpp.
References checkAndInferModule(), checkModule(), and inferModule().
|
static |
Definition at line 356 of file InferDomains.cpp.
References assert(), and unify().
Referenced by applyUpdatesToModule(), getDomainAssociationAsRow(), and updateInstance().
|
static |
Definition at line 325 of file InferDomains.cpp.
References unify().
|
static |
Definition at line 340 of file InferDomains.cpp.
References find(), and unify().
Referenced by processDomainDefinition(), processOp(), solve(), unify(), unify(), and unifyAssociations().
|
static |
Definition at line 312 of file InferDomains.cpp.
|
static |
Definition at line 306 of file InferDomains.cpp.
References assert().
|
static |
Unify the associated domain rows of two terms.
Definition at line 673 of file InferDomains.cpp.
References render(), and unify().
Referenced by processOp(), and processOp().
|
static |
Definition at line 1267 of file InferDomains.cpp.
References getDomainPortTypeName(), getTermForDomain(), isDriven(), and solve().
Referenced by updateOp().
|
static |
Write the domain associations recorded in the domain table back to the IR.
Definition at line 1323 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.
Definition at line 1313 of file InferDomains.cpp.
References updateOp().
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 1193 of file InferDomains.cpp.
References context, copyPortDomainAssociations(), emitAmbiguousPortDomainAssociation(), find(), and noteLocation().
Referenced by updateModule().
|
static |
Definition at line 1302 of file InferDomains.cpp.
References updateInstance().
Referenced by updateModuleBody().