diff --git a/include/circt/Dialect/FIRRTL/FIRRTLExpressions.td b/include/circt/Dialect/FIRRTL/FIRRTLExpressions.td index e8e25f49c964..449948634227 100644 --- a/include/circt/Dialect/FIRRTL/FIRRTLExpressions.td +++ b/include/circt/Dialect/FIRRTL/FIRRTLExpressions.td @@ -1115,6 +1115,7 @@ def FIntegerConstantOp : FIRRTLOp<"integer", [Pure, ConstantLike]> { }]; let arguments = (ins APSIntAttr:$value); let results = (outs FIntegerType:$result); + let hasFolder = 1; let hasCustomAssemblyFormat = true; } diff --git a/lib/Dialect/FIRRTL/FIRRTLFolds.cpp b/lib/Dialect/FIRRTL/FIRRTLFolds.cpp index 2f4b3735df2f..1ec13dc1735f 100644 --- a/lib/Dialect/FIRRTL/FIRRTLFolds.cpp +++ b/lib/Dialect/FIRRTL/FIRRTLFolds.cpp @@ -410,6 +410,11 @@ OpFoldResult StringConstantOp::fold(FoldAdaptor adaptor) { return getValueAttr(); } +OpFoldResult FIntegerConstantOp::fold(FoldAdaptor adaptor) { + assert(adaptor.getOperands().empty() && "constant has no operands"); + return getValueAttr(); +} + //===----------------------------------------------------------------------===// // Binary Operators //===----------------------------------------------------------------------===//