8 #ifndef MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ 9 #define MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ 28 template <
typename SourceOp>
34 lowering_.getDialect()->getContext(), lowering_),
35 f32Func(f32Func), f64Func(f64Func) {}
40 using LLVM::LLVMFuncOp;
45 "expected single result op");
48 .
template cast<LLVM::LLVMType>();
49 LLVMType funcType = getFunctionType(resultType, operands);
50 StringRef funcName = getFunctionName(resultType);
54 LLVMFuncOp funcOp = appendOrGetFuncOp(funcName, funcType, op);
55 auto callOp = rewriter.
create<LLVM::CallOp>(
66 for (
Value operand : operands) {
67 operandTypes.push_back(operand->getType().cast<LLVMType>());
69 return LLVMType::getFunctionTy(resultType, operandTypes,
81 LLVM::LLVMFuncOp appendOrGetFuncOp(StringRef funcName,
84 using LLVM::LLVMFuncOp;
88 return cast<LLVMFuncOp>(*funcOp);
91 return b.
create<LLVMFuncOp>(op->
getLoc(), funcName, funcType);
94 const std::string f32Func;
95 const std::string f64Func;
100 #endif // MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ Definition: InferTypeOpInterface.cpp:20
Definition: Operation.h:27
Definition: OpDefinition.h:29
LLVMTypeConverter & lowering
Definition: ConvertStandardToLLVM.h:239
FlatSymbolRefAttr getSymbolRefAttr(Operation *value)
Definition: Builders.cpp:153
OpTy create(Location location, Args... args)
Definition: PatternMatch.h:265
bool isDoubleTy()
Definition: LLVMDialect.h:60
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
Definition: Operation.h:121
void replaceOp(Operation *op, ValueRange newValues, ValueRange valuesToRemoveIfDead) override
PatternRewriter hook for replacing the results of an operation.
Definition: DialectConversion.cpp:841
OpTy create(Location location, Args &&... args)
Create an operation of specific op type at the current insertion point.
Definition: Builders.h:294
bool isFloatTy()
Utilities to identify types.
Definition: LLVMDialect.h:59
Type getType() const
Return the type of this value.
Definition: Value.cpp:34
OpResult getResult(unsigned idx)
Get the 'idx'th result of this operation.
Definition: Operation.h:246
Location getLoc()
The source location the operation was defined or derived from.
Definition: Operation.h:107
static Operation * lookupNearestSymbolFrom(Operation *from, StringRef symbol)
Definition: SymbolTable.cpp:125
PatternMatchResult matchSuccess(std::unique_ptr< PatternState > state={}) const
This method indicates that a match was found and has the specified cost.
Definition: PatternMatch.h:116
Conversion from types in the Standard dialect to the LLVM IR dialect.
Definition: ConvertStandardToLLVM.h:37
PatternMatchResult matchAndRewrite(Operation *op, ArrayRef< Value > operands, ConversionPatternRewriter &rewriter) const override
Hook for derived classes to implement combined matching and rewriting.
Definition: OpToFuncCallLowering.h:38
Definition: DialectConversion.h:311
static PatternMatchResult matchFailure()
This method indicates that no match was found.
Definition: PatternMatch.h:112
Definition: ConvertStandardToLLVM.h:231
Definition: Builders.h:158
Definition: OpToFuncCallLowering.h:29
OpToFuncCallLowering(LLVMTypeConverter &lowering_, StringRef f32Func, StringRef f64Func)
Definition: OpToFuncCallLowering.h:31
Type convertType(Type t) override
Definition: ConvertStandardToLLVM.cpp:2149
Definition: LLVMDialect.h:44