diff options
author | River Riddle <riverriddle@google.com> | 2019-12-22 21:59:55 -0800 |
---|---|---|
committer | A. Unique TensorFlower <gardener@tensorflow.org> | 2019-12-22 22:00:23 -0800 |
commit | 35807bc4c5c9d8abc31ba0b2f955a82abf276e12 (patch) | |
tree | d083d37d993a774239081509a50e3e6c65366421 /mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | |
parent | 22954a0e408afde1d8686dffb3a3dcab107a2cd3 (diff) | |
download | bcm5719-llvm-35807bc4c5c9d8abc31ba0b2f955a82abf276e12.tar.gz bcm5719-llvm-35807bc4c5c9d8abc31ba0b2f955a82abf276e12.zip |
NFC: Introduce new ValuePtr/ValueRef typedefs to simplify the transition to Value being value-typed.
This is an initial step to refactoring the representation of OpResult as proposed in: https://groups.google.com/a/tensorflow.org/g/mlir/c/XXzzKhqqF_0/m/v6bKb08WCgAJ
This change will make it much simpler to incrementally transition all of the existing code to use value-typed semantics.
PiperOrigin-RevId: 286844725
Diffstat (limited to 'mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp')
-rw-r--r-- | mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp index 4baac53b89f..9b47045ea61 100644 --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -323,7 +323,7 @@ private: uint32_t opcode, ArrayRef<uint32_t> operands); - uint32_t getValueID(Value *val) const { return valueIDMap.lookup(val); } + uint32_t getValueID(ValuePtr val) const { return valueIDMap.lookup(val); } LogicalResult processAddressOfOp(spirv::AddressOfOp addressOfOp); @@ -414,7 +414,7 @@ private: DenseMap<Type, uint32_t> undefValIDMap; /// Map from results of normal operations to their <id>s. - DenseMap<Value *, uint32_t> valueIDMap; + DenseMap<ValuePtr, uint32_t> valueIDMap; /// Map from extended instruction set name to <id>s. llvm::StringMap<uint32_t> extendedInstSetIDMap; @@ -457,7 +457,7 @@ private: /// placed inside `functions`) here. And then after emitting all blocks, we /// replace the dummy <id> 0 with the real result <id> by overwriting /// `functions[offset]`. - DenseMap<Value *, SmallVector<size_t, 1>> deferredPhiValues; + DenseMap<ValuePtr, SmallVector<size_t, 1>> deferredPhiValues; }; } // namespace @@ -513,12 +513,12 @@ void Serializer::collect(SmallVectorImpl<uint32_t> &binary) { void Serializer::printValueIDMap(raw_ostream &os) { os << "\n= Value <id> Map =\n\n"; for (auto valueIDPair : valueIDMap) { - Value *val = valueIDPair.first; + ValuePtr val = valueIDPair.first; os << " " << val << " " << "id = " << valueIDPair.second << ' '; if (auto *op = val->getDefiningOp()) { os << "from op '" << op->getName() << "'"; - } else if (auto *arg = dyn_cast<BlockArgument>(val)) { + } else if (auto arg = dyn_cast<BlockArgument>(val)) { Block *block = arg->getOwner(); os << "from argument of block " << block << ' '; os << " in op '" << block->getParentOp()->getName() << "'"; @@ -752,7 +752,7 @@ LogicalResult Serializer::processFuncOp(FuncOp op) { // There might be OpPhi instructions who have value references needing to fix. for (auto deferredValue : deferredPhiValues) { - Value *value = deferredValue.first; + ValuePtr value = deferredValue.first; uint32_t id = getValueID(value); LLVM_DEBUG(llvm::dbgs() << "[phi] fix reference of value " << value << " to id = " << id << '\n'); @@ -1402,7 +1402,7 @@ LogicalResult Serializer::emitPhiForBlockArguments(Block *block) { // Then create OpPhi instruction for each of the block argument. for (auto argIndex : llvm::seq<unsigned>(0, block->getNumArguments())) { - BlockArgument *arg = block->getArgument(argIndex); + BlockArgumentPtr arg = block->getArgument(argIndex); // Get the type <id> and result <id> for this OpPhi instruction. uint32_t phiTypeID = 0; @@ -1418,7 +1418,7 @@ LogicalResult Serializer::emitPhiForBlockArguments(Block *block) { phiArgs.push_back(phiID); for (auto predIndex : llvm::seq<unsigned>(0, predecessors.size())) { - Value *value = *(predecessors[predIndex].second + argIndex); + ValuePtr value = *(predecessors[predIndex].second + argIndex); uint32_t predBlockId = getOrCreateBlockID(predecessors[predIndex].first); LLVM_DEBUG(llvm::dbgs() << "[phi] use predecessor (id = " << predBlockId << ") value " << value << ' '); @@ -1784,7 +1784,7 @@ Serializer::processOp<spirv::FunctionCallOp>(spirv::FunctionCallOp op) { auto funcCallID = getNextID(); SmallVector<uint32_t, 8> operands{resTypeID, funcCallID, funcID}; - for (auto *value : op.arguments()) { + for (auto value : op.arguments()) { auto valueID = getValueID(value); assert(valueID && "cannot find a value for spv.FunctionCall"); operands.push_back(valueID); |