diff options
| author | Alexander Belyaev <pifon@google.com> | 2019-10-26 08:20:59 -0700 |
|---|---|---|
| committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-10-26 08:21:36 -0700 |
| commit | 780a108d31d798d4cc3c3373dfd26108a613ae0f (patch) | |
| tree | 61c899e9ce4dfc3a09e9aee714f45efeb897c9b9 /mlir/lib/Conversion/GPUCommon | |
| parent | cde337cfdeecc495692caf42aa8fdd0bf89e7c50 (diff) | |
| download | bcm5719-llvm-780a108d31d798d4cc3c3373dfd26108a613ae0f.tar.gz bcm5719-llvm-780a108d31d798d4cc3c3373dfd26108a613ae0f.zip | |
Fix include guards and add tests for OpToFuncCallLowering.
PiperOrigin-RevId: 276859463
Diffstat (limited to 'mlir/lib/Conversion/GPUCommon')
| -rw-r--r-- | mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h index 0622dc61b9d..4c083f98230 100644 --- a/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h +++ b/mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h @@ -14,8 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // ============================================================================= -#ifndef THIRD_PARTY_LLVM_LLVM_PROJECTS_GOOGLE_MLIR_LIB_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ -#define THIRD_PARTY_LLVM_LLVM_PROJECTS_GOOGLE_MLIR_LIB_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ +#ifndef MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ +#define MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Dialect/GPU/GPUDialect.h" @@ -26,6 +26,15 @@ namespace mlir { +/// Rewriting that replace SourceOp with a CallOp to `f32Func` or `f64Func` +/// depending on the element type that Op operates upon. The function +/// declaration is added in case it was not added before. +/// +/// Example with NVVM: +/// %exp_f32 = std.exp %arg_f32 : f32 +/// +/// will be transformed into +/// llvm.call @__nv_expf(%arg_f32) : (!llvm.float) -> !llvm.float template <typename SourceOp> struct OpToFuncCallLowering : public LLVMOpLowering { public: @@ -48,10 +57,9 @@ public: LLVMType resultType = lowering.convertType(op->getResult(0)->getType()) .template cast<LLVM::LLVMType>(); LLVMType funcType = getFunctionType(resultType, operands); - const std::string funcName = getFunctionName(resultType); - if (funcName.empty()) { + StringRef funcName = getFunctionName(resultType); + if (funcName.empty()) return matchFailure(); - } LLVMFuncOp funcOp = appendOrGetFuncOp(funcName, funcType, op); auto callOp = rewriter.create<LLVM::CallOp>( @@ -100,4 +108,4 @@ private: } // namespace mlir -#endif // THIRD_PARTY_LLVM_LLVM_PROJECTS_GOOGLE_MLIR_LIB_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ +#endif // MLIR_CONVERSION_GPUCOMMON_OPTOFUNCCALLLOWERING_H_ |

