[Mlir-commits] [mlir] [mlir][emitc] arith.negf to EmitC conversion (PR #95372)

Tina Jung llvmlistbot at llvm.org
Mon Jun 17 03:05:02 PDT 2024


================
@@ -288,6 +288,29 @@ class CmpIOpConversion : public OpConversionPattern<arith::CmpIOp> {
   }
 };
 
+class NegFOpConversion : public OpConversionPattern<arith::NegFOp> {
+public:
+  using OpConversionPattern::OpConversionPattern;
+
+  LogicalResult
+  matchAndRewrite(arith::NegFOp op, OpAdaptor adaptor,
+                  ConversionPatternRewriter &rewriter) const override {
+
+    auto adaptedOp = adaptor.getOperand();
+    auto adaptedOpType = adaptedOp.getType();
+
+    if (!isa<FloatType>(adaptedOpType)) {
+      return rewriter.notifyMatchFailure(op.getLoc(),
+                                         "negf currently only supported on "
+                                         "floats, not tensors/vectors thereof");
+    }
+
----------------
TinaAMD wrote:

What should it mention? Should it explicitly list the supported float types? Or just mention that the reason could be an unsupported float type?

https://github.com/llvm/llvm-project/pull/95372


More information about the Mlir-commits mailing list