From efadb6b8388344bcf13b739fdc22dd8812df5b3b Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Thu, 19 Dec 2019 11:34:43 -0800 Subject: [PATCH] Detemplatize ModuleTranslation::lookupValues This function template has been introduced in the early days of MLIR to work around the absence of common type for ranges of values (operands, block argumeents, vectors, etc). Core IR now provides ValueRange for exactly this purpose. Use it instead of the template parameter. PiperOrigin-RevId: 286431338 --- mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h | 12 ++---------- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index da2670a..7adb4aa 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -87,16 +87,8 @@ protected: llvm::IRBuilder<> &builder); static std::unique_ptr prepareLLVMModule(Operation *m); - // A helper to look up remapped operands in the value remapping table. - template - SmallVector lookupValues(Range &&values) { - SmallVector remapped; - remapped.reserve(llvm::size(values)); - for (Value *v : values) { - remapped.push_back(valueMapping.lookup(v)); - } - return remapped; - } + /// A helper to look up remapped operands in the value remapping table. + SmallVector lookupValues(ValueRange values); private: /// Check whether the module contains only supported ops directly in its body. diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 6206a88..e59c69a 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -492,6 +492,16 @@ LogicalResult ModuleTranslation::convertFunctions() { return success(); } +/// A helper to look up remapped operands in the value remapping table.` +SmallVector +ModuleTranslation::lookupValues(ValueRange values) { + SmallVector remapped; + remapped.reserve(values.size()); + for (Value *v : values) + remapped.push_back(valueMapping.lookup(v)); + return remapped; +} + std::unique_ptr ModuleTranslation::prepareLLVMModule(Operation *m) { auto *dialect = m->getContext()->getRegisteredDialect(); -- 2.7.4