See discussion here: https://llvm.discourse.group/t/rfc-dialect-type-cast-op/538/11
Makes sense to me, mostly nits.
Nit: drop "MLIR" from the def name, we are not using it in other operations (constant, undef)
Nit: the implicit convention for cast operations is to use type($in) 'to' type($res), let's follow it here as well.
Nit: I'd say that the llvm.mlir.cast itself isn't legal, not the conversion.
Actually, I'm not convinced we want to report an error from the pattern at all. There may be cases where a partial conversion is sufficient and the caller will deal with the remaining casts properly, yet we would have reported the error to the user by that time....
Don't you also want to support memrefs?
Well it has to be named as "SomethingCast", as LLVM_CastOp already exists. Renamed to "DialectCast".
Good point. Removed the error reporting.
memref is complicated because of the descriptor. Do we allow the conversion between a memref and the aligned base pointer, or a memref and the descriptor? Neither seems trivial to implement to me, nor I really need it at the moment. Added a TODO.
I'd say between memref and descriptor. But you are right that it adds a lot of complexity since the descriptor type depends on the parameters of the lowering.