14 #ifndef MLIR_IR_IRMAPPING_H
15 #define MLIR_IR_IRMAPPING_H
34 template <
typename S,
typename T,
35 std::enable_if_t<!std::is_assignable_v<Value, S> &&
36 !std::is_assignable_v<Block *, S> &&
37 !std::is_assignable_v<Operation *, S>> * =
nullptr>
38 void map(S &&from, T &&to) {
39 for (
auto [fromValue, toValue] : llvm::zip(from, to))
40 map(fromValue, toValue);
46 getMap<T>().erase(from);
52 return getMap<T>().count(from);
59 return lookupOrValue(from, T(
nullptr));
66 return lookupOrValue(from, from);
74 assert(result &&
"expected 'from' to be contained within the map");
79 void clear() { valueMap.clear(); }
95 auto &getMap()
const {
96 if constexpr (std::is_convertible_v<T, Value>)
98 else if constexpr (std::is_convertible_v<T, Block *>)
106 template <
typename T>
107 auto lookupOrValue(T from, T value)
const {
108 auto &
map = getMap<T>();
109 auto it =
map.find(from);
110 return it !=
map.end() ? it->second : value;
113 DenseMap<Value, Value> valueMap;
114 DenseMap<Block *, Block *> blockMap;
115 DenseMap<Operation *, Operation *> operationMap;
Block represents an ordered list of Operations.
This is a utility class for mapping one set of IR entities to another.
void erase(T from)
Erases a mapping for 'from'.
void map(Block *from, Block *to)
auto lookupOrDefault(T from) const
Lookup a mapped value within the map.
const DenseMap< Operation *, Operation * > & getOperationMap() const
Return the held operation mapping.
auto lookup(T from) const
Lookup a mapped value within the map.
const DenseMap< Block *, Block * > & getBlockMap() const
Return the held block mapping.
const DenseMap< Value, Value > & getValueMap() const
Return the held value mapping.
void map(Operation *from, Operation *to)
void map(S &&from, T &&to)
void clear()
Clears all mappings held by the mapper.
void map(Value from, Value to)
Inserts a new mapping for 'from' to 'to'.
bool contains(T from) const
Checks to see if a mapping for 'from' exists.
auto lookupOrNull(T from) const
Lookup a mapped value within the map.
Operation is the basic unit of execution within MLIR.
This class represents an instance of an SSA value in the MLIR system, representing a computable value...
Include the generated interface declarations.