[Mlir-commits] [mlir] [MLIR][Math][GPU] Add lowering of absi and fpowi to libdevice (PR #123422)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Sun Jan 19 11:56:53 PST 2025
================
@@ -132,23 +159,84 @@ struct OpToFuncCallLowering : public ConvertOpToLLVMPattern<SourceOp> {
return "";
}
- LLVM::LLVMFuncOp appendOrGetFuncOp(StringRef funcName, Type funcType,
- Operation *op) const {
- using LLVM::LLVMFuncOp;
+ const std::string f32Func;
+ const std::string f64Func;
+ const std::string f32ApproxFunc;
+ const std::string f16Func;
+};
- auto funcAttr = StringAttr::get(op->getContext(), funcName);
- Operation *funcOp = SymbolTable::lookupNearestSymbolFrom(op, funcAttr);
- if (funcOp)
- return cast<LLVMFuncOp>(*funcOp);
+/// Rewriting that replace SourceOp with a CallOp to `i32Func`
+/// The function declaration is added in case it was not added before.
+/// This assumes that all types integral.
+///
+/// Example with NVVM:
+/// %abs_i32 = math.iabs %arg_i32 : i32
+///
+/// will be transformed into
+/// llvm.call @__nv_abs(%arg_i32) : (i32) -> i32
+///
+template <typename SourceOp>
+struct IntOpToFuncCallLowering
----------------
ftynse wrote:
Can this just be folded into the the `OpToFuncCallLowering` as another option with an empty-by-default function name?
https://github.com/llvm/llvm-project/pull/123422
More information about the Mlir-commits
mailing list