Skip to content

Commit c33f9da

Browse files
committed
[mlir] Impl folder for conv_cast
1 parent 03e4723 commit c33f9da

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

libsolidity/codegen/mlir/Sol/SolOps.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
using namespace mlir;
3333
using namespace mlir::sol;
3434

35+
//===----------------------------------------------------------------------===//
36+
// ConvCastOp
37+
//===----------------------------------------------------------------------===//
38+
39+
OpFoldResult ConvCastOp::fold(FoldAdaptor adaptor) { return adaptor.getInp(); }
40+
3541
//===----------------------------------------------------------------------===//
3642
// ConstantOp
3743
//===----------------------------------------------------------------------===//

libsolidity/codegen/mlir/Sol/SolOps.td

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,17 @@ include "mlir/IR/SymbolInterfaces.td"
4040
// specific ops) should verify that their types (ssa argument types and
4141
// TypeAttr) are high level ((un)signed int types, sol dialect types etc.).
4242

43-
// FIXME: Can we have a custom lowering of unrealized_conversion_cast instead?
44-
// ReconcileUnrealizedCasts conversion won't work here.
45-
def Sol_ConvCastOp : Sol_Op<"conv_cast"> {
46-
let summary = "Like unrealized_conversion_cast; Represents the remapped value";
43+
// TODO: Is using builtin.unrealized_conversion_cast better+faster? Can we
44+
// legalize it without a separate reconcile pass?
45+
def Sol_ConvCastOp : Sol_Op<"conv_cast", [Pure]> {
46+
let summary = "No-op cast that casts to the remapped value in conversion";
4747

4848
let arguments = (ins AnyType:$inp);
4949
let results = (outs AnyType:$out);
5050

5151
let assemblyFormat = "$inp attr-dict `:` type($inp) `->` type($out)";
52+
53+
let hasFolder = 1;
5254
}
5355

5456
def Sol_ConstantOp : Op<Sol_Dialect, "constant",

0 commit comments

Comments
 (0)