13#ifndef CIRCT_DIALECT_HW_PORTIMPLEMENTATION_H
14#define CIRCT_DIALECT_HW_PORTIMPLEMENTATION_H
32 LocationAttr
loc = {};
42 InnerSymAttr
getSym()
const;
43 void setSym(InnerSymAttr sym, MLIRContext *ctx);
58 ArrayRef<PortInfo> outputs) {
59 ports.insert(
ports.end(), inputs.begin(), inputs.end());
60 ports.insert(
ports.end(), outputs.begin(), outputs.end());
66 using iterator = SmallVector<PortInfo>::iterator;
81 std::function<bool(
const PortInfo &)> predicateFn;
83 predicateFn = [](
const PortInfo &port) ->
bool {
87 predicateFn = [](
const PortInfo &port) ->
bool {
91 return llvm::make_filter_range(
ports, predicateFn);
95 std::function<bool(
const PortInfo &)> predicateFn;
97 predicateFn = [](
const PortInfo &port) ->
bool {
101 predicateFn = [](
const PortInfo &port) ->
bool {
105 return llvm::make_filter_range(
ports, predicateFn);
123 return std::distance(r.begin(), r.end());
127 return std::distance(r.begin(), r.end());
132 while (idx ||
ports[port].isOutput()) {
133 if (!
ports[port].isOutput())
142 while (idx || !
ports[port].isOutput()) {
143 if (
ports[port].isOutput())
176 StringAttr name)
const {
177 auto it = portMap.find(name);
178 if (it == portMap.end())
195 const SmallVector<PortInfo> &portInfo)
assert(baseType &&"element must be base type")
false return failure()
Parse an optional keyword or string and set instance into 'result'.
OS & operator<<(OS &os, const InnerSymTarget &target)
Printing InnerSymTarget's.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
This holds a decoded list of input/inout and output ports for a module or instance.
const PortInfo & at(size_t idx) const
PortInfo & atInput(size_t idx)
PortInfo & atOutput(size_t idx)
llvm::iterator_range< llvm::filter_iterator< const_iterator, std::function< bool(const PortInfo &)> > > ConstPortDirectionRange
PortInfo & at(size_t idx)
ModulePortInfo(ArrayRef< PortInfo > inputs, ArrayRef< PortInfo > outputs)
const PortInfo & atOutput(size_t idx) const
size_t portNumForInput(size_t idx) const
size_t portNumForOutput(size_t idx) const
size_t sizeOutputs() const
ConstPortDirectionRange getPortsOfDirection(bool input) const
SmallVector< PortInfo > ports
This contains a list of all ports. Input first.
const PortInfo & atInput(size_t idx) const
ConstPortDirectionRange getOutputs() const
SmallVector< PortInfo >::const_iterator const_iterator
SmallVector< PortInfo >::iterator iterator
const_iterator begin() const
llvm::iterator_range< llvm::filter_iterator< iterator, std::function< bool(const PortInfo &)> > > PortDirectionRange
size_t sizeInputs() const
const_iterator end() const
ConstPortDirectionRange getInputs() const
void eraseInput(size_t idx)
PortDirectionRange getPortsOfDirection(bool input)
PortDirectionRange getInputs()
PortDirectionRange getOutputs()
ModulePortInfo(ArrayRef< PortInfo > mergedPorts)
llvm::DenseMap< StringAttr, unsigned > inputPortMap
llvm::DenseMap< StringAttr, unsigned > outputPortMap
FailureOr< unsigned > lookupPortIndex(const llvm::DenseMap< StringAttr, unsigned > &portMap, StringAttr name) const
FailureOr< unsigned > getInputPortIndex(StringAttr name) const
FailureOr< unsigned > getOutputPortIndex(StringRef name) const
FailureOr< unsigned > getInputPortIndex(StringRef name) const
ModulePortLookupInfo(MLIRContext *ctx, const ModulePortInfo &portInfo)
ModulePortLookupInfo(MLIRContext *ctx, const SmallVector< PortInfo > &portInfo)
FailureOr< unsigned > getOutputPortIndex(StringAttr name) const
This holds the name, type, direction of a module's ports.
StringRef getVerilogName() const
ssize_t getId() const
Return a unique numeric identifier for this port.
StringRef getName() const
DictionaryAttr attrs
The optional symbol for this port.
size_t argNum
This is the argument index or the result index depending on the direction.
void setSym(InnerSymAttr sym, MLIRContext *ctx)
InnerSymAttr getSym() const