[mlir] Allow to specify target type in `convertType`
Add a new helper function for the type converter that takes care of casting to the target type. This is to avoid bugs where an incorrect cast function is used after type conversion, e.g., `dyn_cast` or `cast`. These are not guaranteed to work when type conversion fails, or when type conversion succeeds but the provided type converted returned a type that a conversion pattern did not expect. I saw this being an issue in some SPIR-V passes and in mlir-hlo. Exercise the new function in a couple of passes. As a side-effect, this also made the code more concise. Reviewed By: rriddle, mehdi_amini Differential Revision: https://reviews.llvm.org/D148725
Loading
Please sign in to comment