[PATCH] D73894: [MLIR] Add mapping based on ValueRange to BlockAndValueMapper.
Stephan Herhut via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 3 07:43:45 PST 2020
herhut created this revision.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: rriddle.
Herald added a project: LLVM.
herhut added a comment.
Maybe this should even be a template to cover more cases like BlockArguments.
It is often needed to map entire ranges rather than single values. To avoid
writing the same for loop every time, I have added an overload to the map
method.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73894
Files:
mlir/include/mlir/IR/BlockAndValueMapping.h
Index: mlir/include/mlir/IR/BlockAndValueMapping.h
===================================================================
--- mlir/include/mlir/IR/BlockAndValueMapping.h
+++ mlir/include/mlir/IR/BlockAndValueMapping.h
@@ -15,6 +15,7 @@
#define MLIR_IR_BLOCKANDVALUEMAPPING_H
#include "mlir/IR/Block.h"
+#include "mlir/IR/OperationSupport.h"
namespace mlir {
// This is a utility class for mapping one set of values to another. New
@@ -31,6 +32,10 @@
void map(Value from, Value to) {
valueMap[from.getAsOpaquePointer()] = to.getAsOpaquePointer();
}
+ void map(ValueRange from, ValueRange to) {
+ for (auto pair : llvm::zip(from, to))
+ map(std::get<0>(pair), std::get<1>(pair));
+ }
/// Erases a mapping for 'from'.
void erase(Block *from) { valueMap.erase(from); }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73894.242072.patch
Type: text/x-patch
Size: 799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200203/e4737975/attachment.bin>
More information about the llvm-commits
mailing list