[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
================
@@ -99,6 +75,61 @@ struct OpToFuncCallLowering : public ConvertOpToLLVMPattern<SourceOp> {
}
private:
+ Type getFunctionType(Type resultType, ValueRange operands) const {
+ SmallVector<Type> operandTypes(operands.getTypes());
+ return LLVM::LLVMFunctionType::get(resultType, operandTypes);
+ }
+
+ LLVM::LLVMFuncOp appendOrGetFuncOp(StringRef funcName, Type funcType,
+ Operation *op) const {
+ using LLVM::LLVMFuncOp;
+
+ auto funcAttr = StringAttr::get(op->getContext(), funcName);
+ Operation *funcOp = SymbolTable::lookupNearestSymbolFrom(op, funcAttr);
+ if (funcOp)
+ return cast<LLVMFuncOp>(*funcOp);
+
+ mlir::OpBuilder b(op->getParentOfType<FunctionOpInterface>());
----------------
ftynse wrote:
```suggestion
auto parentFunc = op->getParentOfType<FunctionOpInterface>();
assert(parentFunc && "expected there to be a parent function");
OpBuilder b(parentFunc);
```
Nullptr insertion points are annoying to debug, better safe.
https://github.com/llvm/llvm-project/pull/123422
More information about the Mlir-commits
mailing list