[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);
----------------
ftynse wrote:

```suggestion
    auto funcOp = SymbolTable::lookupNearestSymbolFrom<LLVMFuncOp>(op, funcAttr);
```

This will also avoid the crash on cast below when the symbol is present, but has a wrong op kind.

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


More information about the Mlir-commits mailing list