[Mlir-commits] [mlir] [mlir][math] Add FP software implementation lowering pass: math-to-apfloat (PR #171221)
Matthias Springer
llvmlistbot at llvm.org
Thu Dec 11 01:13:31 PST 2025
================
@@ -516,3 +516,34 @@ Value mlir::LLVM::getStridedElementPtr(OpBuilder &builder, Location loc,
base, index, noWrapFlags)
: base;
}
+
+/// Return the given type if it's a floating point type. If the given type is
+/// a vector type, return its element type if it's a floating point type.
+static FloatType getFloatingPointType(Type type) {
+ if (auto floatType = dyn_cast<FloatType>(type))
+ return floatType;
+ if (auto vecType = dyn_cast<VectorType>(type))
+ return dyn_cast<FloatType>(vecType.getElementType());
+ return nullptr;
+}
+
+bool LLVM::detail::isUnsupportedFloatingPointType(
+ const TypeConverter &typeConverter, Type type) {
+ FloatType floatType = getFloatingPointType(type);
+ if (!floatType)
+ return false;
+ Type convertedType = typeConverter.convertType(floatType);
+ if (!convertedType)
+ return true;
+ return !isa<FloatType>(convertedType);
+}
+
+bool LLVM::detail::opHasUnsupportedFloatingPointTypes(
+ Operation *op, const TypeConverter &typeConverter) {
+ for (Value operand : op->getOperands())
+ if (isUnsupportedFloatingPointType(typeConverter, operand.getType()))
+ return true;
+ if (isUnsupportedFloatingPointType(typeConverter, op->getResult(0).getType()))
----------------
matthias-springer wrote:
I think this should take into account all results.
https://github.com/llvm/llvm-project/pull/171221
More information about the Mlir-commits
mailing list