Skip to content

Commit

Permalink
[FIRRTL] Add a folder for FIntegerConstantOp.
Browse files Browse the repository at this point in the history
This isn't used by much yet, but some parts of the MLIR
infrastructure (e.g., Dialect Conversion) assume ConstantLike ops have
a folder. This adds the usual folder, same as StringConstantOp and
others.
  • Loading branch information
mikeurbach committed Aug 15, 2023
1 parent 2df81c9 commit 5c20f56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/circt/Dialect/FIRRTL/FIRRTLExpressions.td
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/Dialect/FIRRTL/FIRRTLFolds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//===----------------------------------------------------------------------===//
Expand Down

0 comments on commit 5c20f56

Please sign in to comment.