13 #ifndef CIRCT_DIALECT_CALYX_OPS_H
14 #define CIRCT_DIALECT_CALYX_OPS_H
18 #include "mlir/IR/BuiltinOps.h"
19 #include "mlir/IR/OpImplementation.h"
20 #include "mlir/IR/RegionKindInterface.h"
21 #include "mlir/IR/SymbolTable.h"
22 #include "mlir/Interfaces/FunctionInterfaces.h"
23 #include "mlir/Interfaces/InferTypeOpInterface.h"
24 #include "mlir/Interfaces/SideEffectInterfaces.h"
31 static constexpr std::string_view
goPort =
"go";
32 static constexpr std::string_view
donePort =
"done";
33 static constexpr std::string_view
resetPort =
"reset";
34 static constexpr std::string_view
clkPort =
"clk";
41 template <
typename ConcreteType>
53 template <
typename ConcreteType>
58 Attribute staticAttribute = op->getAttr(
"static");
59 if (staticAttribute ==
nullptr)
63 APInt staticValue = cast<IntegerAttr>(staticAttribute).getValue();
64 assert(staticValue == 0 &&
"If combinational, it should take 0 cycles.");
80 IntegerAttr
packAttribute(MLIRContext *context,
size_t nIns,
size_t nOuts);
94 return llvm::any_of(
attributes, [&](
auto idToAttribute) {
95 return identifier == idToAttribute.getName();
103 auto it = llvm::find_if(
attributes, [&](
auto idToAttribute) {
104 return identifier == idToAttribute.getName();
108 return it->getValue();
114 SmallVector<StringRef> identifiers;
115 llvm::transform(
attributes, std::back_inserter(identifiers),
116 [](
auto idToAttribute) {
return idToAttribute.getName(); });
131 LogicalResult
verifyIf(Operation *op);
139 #include "circt/Dialect/Calyx/CalyxInterfaces.h.inc"
141 #define GET_OP_CLASSES
142 #include "circt/Dialect/Calyx/Calyx.h.inc"
assert(baseType &&"element must be base type")
Signals that the following operation is combinational.
static LogicalResult verifyTrait(Operation *op)
Signals that the following operation is "control-like.".
static LogicalResult verifyTrait(Operation *op)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
IntegerAttr packAttribute(MLIRContext *context, size_t nIns, size_t nOuts)
Returns an IntegerAttr containing the packed representation of the direction counts.
static constexpr std::string_view clkPort
LogicalResult verifyComponent(Operation *op)
A helper function to verify each operation with the Ccomponent trait.
static constexpr std::string_view donePort
LogicalResult verifyControlLikeOp(Operation *op)
A helper function to verify each control-like operation has a valid parent and, if applicable,...
LogicalResult verifyGroupInterface(Operation *op)
A helper function to verify each operation with the Group Interface trait.
LogicalResult verifyCell(Operation *op)
A helper function to verify each operation with the Cell trait.
static constexpr std::string_view resetPort
Direction
The direction of a Component or Cell port.
LogicalResult verifyIf(Operation *op)
A helper function to verify each operation with the If trait.
LogicalResult verifyCombinationalOp(Operation *op)
A helper function to verify a combinational operation.
PortInfo getPortInfo(BlockArgument arg)
Returns port information for the block argument provided.
static constexpr std::string_view goPort
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
This holds information about the port for either a Component or Cell.
SmallVector< StringRef > getAllIdentifiers() const
Returns all identifiers for this dictionary attribute.
bool hasAttribute(StringRef identifier) const
Returns whether the given port has attribute with Identifier name.
std::optional< Attribute > getAttribute(StringRef identifier) const
Returns the attribute associated with the given name if it exists, otherwise std::nullopt.
DictionaryAttr attributes
This holds the name, type, direction of a module's ports.