Detemplatize ModuleTranslation::lookupValues
authorAlex Zinenko <zinenko@google.com>
Thu, 19 Dec 2019 19:34:43 +0000 (11:34 -0800)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 19 Dec 2019 19:35:57 +0000 (11:35 -0800)
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
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

index da2670a..7adb4aa 100644 (file)
@@ -87,16 +87,8 @@ protected:
                                          llvm::IRBuilder<> &builder);
   static std::unique_ptr<llvm::Module> prepareLLVMModule(Operation *m);
 
-  // A helper to look up remapped operands in the value remapping table.
-  template <typename Range>
-  SmallVector<llvm::Value *, 8> lookupValues(Range &&values) {
-    SmallVector<llvm::Value *, 8> 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<llvm::Value *, 8> lookupValues(ValueRange values);
 
 private:
   /// Check whether the module contains only supported ops directly in its body.
index 6206a88..e59c69a 100644 (file)
@@ -492,6 +492,16 @@ LogicalResult ModuleTranslation::convertFunctions() {
   return success();
 }
 
+/// A helper to look up remapped operands in the value remapping table.`
+SmallVector<llvm::Value *, 8>
+ModuleTranslation::lookupValues(ValueRange values) {
+  SmallVector<llvm::Value *, 8> remapped;
+  remapped.reserve(values.size());
+  for (Value *v : values)
+    remapped.push_back(valueMapping.lookup(v));
+  return remapped;
+}
+
 std::unique_ptr<llvm::Module>
 ModuleTranslation::prepareLLVMModule(Operation *m) {
   auto *dialect = m->getContext()->getRegisteredDialect<LLVM::LLVMDialect>();