[Mlir-commits] [mlir] [mlir][math] Add vector support for math-to-apfloat (PR #172715)

Matthias Springer llvmlistbot at llvm.org
Sat Jan 10 02:26:51 PST 2026


================
@@ -9,13 +9,74 @@
 #ifndef MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
 #define MLIR_CONVERSION_ARITHANDMATHTOAPFLOAT_UTILS_H_
 
+#include "mlir/Dialect/Vector/IR/VectorOps.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Pass/Pass.h"
+#include "llvm/ADT/SmallVector.h"
+
 namespace mlir {
 class Value;
 class OpBuilder;
 class Location;
 class FloatType;
 
 Value getAPFloatSemanticsValue(OpBuilder &b, Location loc, FloatType floatTy);
+
+/// Given two operands of vector type and vector result type (with the same
+/// shape), call the given function for each pair of scalar operands and
+/// package the result into a vector. If the given operands and result type are
+/// not vectors, call the function directly. The second operand is optional.
+template <typename Fn, typename... Values>
+Value forEachScalarValue(mlir::RewriterBase &rewriter, Location loc,
+                         Value operand1, Value operand2, Type resultType,
+                         Fn fn) {
----------------
matthias-springer wrote:

Now that this is in a header file, maybe it makes sense to pass a function pointer instead of templatizing the function? Then the implementation could be in the `.cpp` file. Not sure if it's really better, just an idea...

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


More information about the Mlir-commits mailing list