13 #ifndef CIRCT_DIALECT_HW_PORTIMPLEMENTATION_H
14 #define CIRCT_DIALECT_HW_PORTIMPLEMENTATION_H
32 LocationAttr
loc = {};
43 InnerSymAttr
getSym()
const;
44 void setSym(InnerSymAttr sym, MLIRContext *ctx);
59 ArrayRef<PortInfo> outputs) {
60 ports.insert(
ports.end(), inputs.begin(), inputs.end());
61 ports.insert(
ports.end(), outputs.begin(), outputs.end());
70 using iterator = SmallVector<PortInfo>::iterator;
85 std::function<bool(
const PortInfo &)> predicateFn;
87 predicateFn = [](
const PortInfo &port) ->
bool {
92 predicateFn = [](
const PortInfo &port) ->
bool {
96 return llvm::make_filter_range(
ports, predicateFn);
100 std::function<bool(
const PortInfo &)> predicateFn;
102 predicateFn = [](
const PortInfo &port) ->
bool {
107 predicateFn = [](
const PortInfo &port) ->
bool {
111 return llvm::make_filter_range(
ports, predicateFn);
129 return std::distance(r.begin(), r.end());
133 return std::distance(r.begin(), r.end());
138 while (idx ||
ports[port].isOutput()) {
139 if (!
ports[port].isOutput())
148 while (idx || !
ports[port].isOutput()) {
149 if (
ports[port].isOutput())
176 for (
auto &p :
ports)
177 if (
auto inout = dyn_cast<hw::InOutType>(p.type)) {
178 p.type = inout.getElementType();
191 StringAttr name)
const {
192 auto it = portMap.find(name);
193 if (it == portMap.end())
210 const SmallVector<PortInfo> &portInfo)
assert(baseType &&"element must be base type")
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
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
const PortInfo & atInput(size_t idx) const
ModulePortInfo(ArrayRef< PortInfo > inputs, ArrayRef< PortInfo > outputs)
size_t portNumForInput(size_t idx) const
llvm::iterator_range< llvm::filter_iterator< iterator, std::function< bool(const PortInfo &)> >> PortDirectionRange
size_t portNumForOutput(size_t idx) const
size_t sizeOutputs() const
ConstPortDirectionRange getPortsOfDirection(bool input) const
llvm::iterator_range< llvm::filter_iterator< const_iterator, std::function< bool(const PortInfo &)> >> ConstPortDirectionRange
SmallVector< PortInfo > ports
This contains a list of all ports. Input first.
PortInfo & at(size_t idx)
ConstPortDirectionRange getOutputs() const
SmallVector< PortInfo >::const_iterator const_iterator
const PortInfo & atOutput(size_t idx) const
SmallVector< PortInfo >::iterator iterator
const_iterator begin() const
PortInfo & atInput(size_t idx)
size_t sizeInputs() const
const_iterator end() const
ConstPortDirectionRange getInputs() const
void eraseInput(size_t idx)
PortDirectionRange getPortsOfDirection(bool input)
PortInfo & atOutput(size_t idx)
PortDirectionRange getInputs()
PortDirectionRange getOutputs()
ModulePortInfo(ArrayRef< PortInfo > mergedPorts)
llvm::DenseMap< StringAttr, unsigned > inputPortMap
llvm::DenseMap< StringAttr, unsigned > outputPortMap
FailureOr< unsigned > getOutputPortIndex(StringRef name) const
FailureOr< unsigned > getInputPortIndex(StringAttr name) const
FailureOr< unsigned > lookupPortIndex(const llvm::DenseMap< StringAttr, unsigned > &portMap, StringAttr name) const
ModulePortLookupInfo(MLIRContext *ctx, const ModulePortInfo &portInfo)
FailureOr< unsigned > getInputPortIndex(StringRef name) const
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