17 #include "mlir/IR/PatternMatch.h"
23 ComponentOp component,
size_t width,
25 OpBuilder::InsertionGuard guard(builder);
26 builder.setInsertionPointToStart(component.getBodyBlock());
27 return builder.create<RegisterOp>(loc, (prefix +
"_reg").str(),
width);
31 ComponentOp component, Type type,
33 OpBuilder::InsertionGuard guard(builder);
34 builder.setInsertionPointToStart(component.getBodyBlock());
35 return builder.create<RegisterOp>(loc, (prefix +
"_reg").str(), type);
39 ComponentOp component,
size_t width,
41 OpBuilder::InsertionGuard g(builder);
42 builder.setInsertionPointToStart(component.getBodyBlock());
44 APInt(
width, value,
true));
48 ComponentOp component,
49 SmallVectorImpl<Type> &resultTypes,
50 StringRef instanceName,
51 StringRef componentName) {
52 OpBuilder::InsertionGuard g(builder);
53 builder.setInsertionPointToStart(component.getBodyBlock());
54 return builder.create<InstanceOp>(loc, resultTypes, instanceName,
59 SmallVector<StringRef, 2> strVet = {callOp.getCallee(),
"instance"};
60 return llvm::join(strVet,
"_");
71 SmallVectorImpl<calyx::PortInfo> &ports) {
72 MLIRContext *ctx = rewriter.getContext();
74 rewriter.getStringAttr(
clkPort),
86 rewriter.getStringAttr(
goPort),
100 return std::max(llvm::Log2_64_Ceil(dim), 1U);
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
static constexpr std::string_view clkPort
void addMandatoryComponentPorts(PatternRewriter &rewriter, SmallVectorImpl< calyx::PortInfo > &ports)
static constexpr std::string_view donePort
bool isControlLeafNode(Operation *op)
static constexpr std::string_view resetPort
unsigned handleZeroWidth(int64_t dim)
hw::ConstantOp createConstant(Location loc, OpBuilder &builder, ComponentOp component, size_t width, size_t value)
A helper function to create constants in the HW dialect.
DictionaryAttr getMandatoryPortAttr(MLIRContext *ctx, StringRef name)
calyx::RegisterOp createRegister(Location loc, OpBuilder &builder, ComponentOp component, size_t width, Twine prefix)
Creates a RegisterOp, with input and output port bit widths defined by width.
calyx::InstanceOp createInstance(Location loc, OpBuilder &builder, ComponentOp component, SmallVectorImpl< Type > &resultTypes, StringRef instanceName, StringRef componentName)
A helper function to create calyx.instance operation.
static constexpr std::string_view goPort
std::string getInstanceName(mlir::func::CallOp callOp)
A helper function to get the instance name.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.