From 729d521b7f2b099ae517167edbb4ac12f612e0f0 Mon Sep 17 00:00:00 2001 From: Andrew Lenharth Date: Wed, 1 Dec 2021 14:40:56 -0600 Subject: [PATCH] [NFC] add nicer builders to chirtl mems --- .../Dialect/FIRRTL/FIRRTLDeclarations.td | 11 ++++++++++ lib/Dialect/FIRRTL/FIRRTLOps.cpp | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td b/include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td index 5c0ee9f1fd..238fc1d0b6 100644 --- a/include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td +++ b/include/circt/Dialect/FIRRTL/FIRRTLDeclarations.td @@ -96,6 +96,12 @@ def CombMemOp : FIRRTLOp<"combmem"> { let results = (outs CMemoryType:$result); let assemblyFormat = "custom(attr-dict) `:` type($result)"; let hasCanonicalizer = true; + let builders = [ + OpBuilder<(ins "FIRRTLType":$elementType, + "unsigned":$numElements, "mlir::StringRef":$name, + CArg<"ArrayRef","{}">:$annotations)> + ]; + } def SeqMemOp : FIRRTLOp<"seqmem"> { @@ -109,6 +115,11 @@ def SeqMemOp : FIRRTLOp<"seqmem"> { let results = (outs CMemoryType:$result); let assemblyFormat = "$ruw custom(attr-dict) `:` type($result)"; let hasCanonicalizer = true; + let builders = [ + OpBuilder<(ins "FIRRTLType":$elementType, + "unsigned":$numElements, "RUWAttr":$ruw, "mlir::StringRef":$name, + CArg<"ArrayRef","{}">:$annotations)> + ]; } def MemoryPortOp : FIRRTLOp<"memoryport", [InferTypeOpInterface, diff --git a/lib/Dialect/FIRRTL/FIRRTLOps.cpp b/lib/Dialect/FIRRTL/FIRRTLOps.cpp index 79abe7568c..0d7abd3a89 100644 --- a/lib/Dialect/FIRRTL/FIRRTLOps.cpp +++ b/lib/Dialect/FIRRTL/FIRRTLOps.cpp @@ -2863,6 +2863,26 @@ static void printSeqMemOp(OpAsmPrinter &p, Operation *op, DictionaryAttr attr) { printImplicitSSAName(p, op, attr, {"ruw"}); } +void SeqMemOp::build(OpBuilder &builder, OperationState &result, + FIRRTLType elementType, unsigned numElements, RUWAttr ruw, + StringRef name, ArrayRef annotations) { + build(builder, result, + CMemoryType::get(builder.getContext(), elementType, numElements), ruw, + name, builder.getArrayAttr(annotations)); +} + +//===----------------------------------------------------------------------===// +// CombMemOp Custom attr-dict Directive +//===----------------------------------------------------------------------===// + +void CombMemOp::build(OpBuilder &builder, OperationState &result, + FIRRTLType elementType, unsigned numElements, + StringRef name, ArrayRef annotations) { + build(builder, result, + CMemoryType::get(builder.getContext(), elementType, numElements), name, + builder.getArrayAttr(annotations)); +} + //===----------------------------------------------------------------------===// // MemOp Custom attr-dict Directive //===----------------------------------------------------------------------===//