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"
34 template <
typename ConcreteType>
46 template <
typename ConcreteType>
51 Attribute staticAttribute = op->getAttr(
"static");
52 if (staticAttribute ==
nullptr)
56 APInt staticValue = staticAttribute.cast<IntegerAttr>().getValue();
57 assert(staticValue == 0 &&
"If combinational, it should take 0 cycles.");
73 IntegerAttr
packAttribute(MLIRContext *context,
size_t nIns,
size_t nOuts);
87 return llvm::any_of(
attributes, [&](
auto idToAttribute) {
88 return identifier == idToAttribute.getName();
94 std::optional<Attribute>
getAttribute(StringRef identifier)
const {
96 auto it = llvm::find_if(
attributes, [&](
auto idToAttribute) {
97 return identifier == idToAttribute.getName();
101 return it->getValue();
107 SmallVector<StringRef> identifiers;
108 llvm::transform(
attributes, std::back_inserter(identifiers),
109 [](
auto idToAttribute) {
return idToAttribute.getName(); });
124 LogicalResult
verifyIf(Operation *op);
132 #include "circt/Dialect/Calyx/CalyxInterfaces.h.inc"
134 #define GET_OP_CLASSES
135 #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.
LogicalResult verifyComponent(Operation *op)
A helper function to verify each operation with the Ccomponent trait.
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.
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.
This file defines an intermediate representation for circuits acting as an abstraction for constraint...
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