[Mlir-commits] [mlir] [mlir][emitc] Add EmitC lowering for arith.trunci, arith.extsi, arith.extui (PR #91491)
Tina Jung
llvmlistbot at llvm.org
Fri May 10 02:54:24 PDT 2024
================
@@ -112,6 +112,78 @@ class CmpIOpConversion : public OpConversionPattern<arith::CmpIOp> {
}
};
+template <typename ArithOp, bool needsUnsigned>
+class CastConversion : public OpConversionPattern<ArithOp> {
+public:
+ using OpConversionPattern<ArithOp>::OpConversionPattern;
+
+ LogicalResult
+ matchAndRewrite(ArithOp op, typename ArithOp::Adaptor adaptor,
+ ConversionPatternRewriter &rewriter) const override {
+
+ Type opReturnType = this->getTypeConverter()->convertType(op.getType());
+ if (!isa_and_nonnull<IntegerType>(opReturnType)) {
+ return rewriter.notifyMatchFailure(op, "expected integer result type");
+ }
+
+ if (adaptor.getOperands().size() != 1) {
+ return rewriter.notifyMatchFailure(
+ op, "CastConversion only supports unary ops");
+ }
----------------
TinaAMD wrote:
```suggestion
if (adaptor.getOperands().size() != 1)
return rewriter.notifyMatchFailure(
op, "CastConversion only supports unary ops");
```
https://github.com/llvm/llvm-project/pull/91491
More information about the Mlir-commits
mailing list