diff options
| -rw-r--r-- | mlir/g3doc/UsageOfConst.md | 14 | ||||
| -rw-r--r-- | mlir/include/mlir/IR/Operation.h | 10 | ||||
| -rw-r--r-- | mlir/include/mlir/IR/OperationSupport.h | 42 | ||||
| -rw-r--r-- | mlir/include/mlir/IR/Value.h | 6 | ||||
| -rw-r--r-- | mlir/lib/Analysis/LoopAnalysis.cpp | 2 | ||||
| -rw-r--r-- | mlir/lib/IR/Block.cpp | 6 | ||||
| -rw-r--r-- | mlir/lib/IR/Operation.cpp | 18 | ||||
| -rw-r--r-- | mlir/lib/IR/OperationSupport.cpp | 24 | ||||
| -rw-r--r-- | mlir/lib/Transforms/MemRefDataFlowOpt.cpp | 4 | ||||
| -rw-r--r-- | mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp | 2 | 
10 files changed, 57 insertions, 71 deletions
diff --git a/mlir/g3doc/UsageOfConst.md b/mlir/g3doc/UsageOfConst.md index d573600a9f5..d33739f281d 100644 --- a/mlir/g3doc/UsageOfConst.md +++ b/mlir/g3doc/UsageOfConst.md @@ -144,16 +144,16 @@ const.    /// Returns a const iterator on the underlying Value's (Value *).    llvm::iterator_range<const_operand_iterator> getOperands() const; -  ArrayRef<InstOperand> getInstOperands() const { -    return getOperandStorage().getInstOperands(); +  ArrayRef<OpOperand> getOpOperands() const { +    return getOperandStorage().getOperands();    } -  MutableArrayRef<InstOperand> getInstOperands() { -    return getOperandStorage().getInstOperands(); +  MutableArrayRef<OpOperand> getOpOperands() { +    return getOperandStorage().getOperands();    } -  InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } -  const InstOperand &getInstOperand(unsigned idx) const { -    return getInstOperands()[idx]; +  OpOperand &getOpOperand(unsigned idx) { return getOpOperands()[idx]; } +  const OpOperand &getOpOperand(unsigned idx) const { +    return getOpOperands()[idx];    }  ``` diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h index 2b8626c7e58..2ffb91a785d 100644 --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -162,9 +162,9 @@ public:    unsigned getNumOperands() { return getOperandStorage().size(); } -  Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); } +  Value *getOperand(unsigned idx) { return getOpOperand(idx).get(); }    void setOperand(unsigned idx, Value *value) { -    return getInstOperand(idx).set(value); +    return getOpOperand(idx).set(value);    }    // Support operand iteration. @@ -177,11 +177,11 @@ public:    /// Returns an iterator on the underlying Value's (Value *).    operand_range getOperands(); -  MutableArrayRef<InstOperand> getInstOperands() { -    return getOperandStorage().getInstOperands(); +  MutableArrayRef<OpOperand> getOpOperands() { +    return getOperandStorage().getOperands();    } -  InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } +  OpOperand &getOpOperand(unsigned idx) { return getOpOperands()[idx]; }    //===--------------------------------------------------------------------===//    // Results diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h index fc343328f30..4caf6aa43c1 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -296,7 +296,7 @@ namespace detail {  /// A utility class holding the information necessary to dynamically resize  /// operands.  struct ResizableStorage { -  ResizableStorage(InstOperand *opBegin, unsigned numOperands) +  ResizableStorage(OpOperand *opBegin, unsigned numOperands)        : firstOpAndIsDynamic(opBegin, false), capacity(numOperands) {}    ~ResizableStorage() { cleanupStorage(); } @@ -309,17 +309,14 @@ struct ResizableStorage {    }    /// Sets the storage pointer to a new dynamically allocated block. -  void setDynamicStorage(InstOperand *opBegin) { +  void setDynamicStorage(OpOperand *opBegin) {      /// Cleanup the old storage if necessary.      cleanupStorage();      firstOpAndIsDynamic.setPointerAndInt(opBegin, true);    }    /// Returns the current storage pointer. -  InstOperand *getPointer() { return firstOpAndIsDynamic.getPointer(); } -  const InstOperand *getPointer() const { -    return firstOpAndIsDynamic.getPointer(); -  } +  OpOperand *getPointer() { return firstOpAndIsDynamic.getPointer(); }    /// Returns if the current storage of operands is in the trailing objects is    /// in a dynamically allocated memory block. @@ -327,7 +324,7 @@ struct ResizableStorage {    /// A pointer to the first operand element. This is either to the trailing    /// objects storage, or a dynamically allocated block of memory. -  llvm::PointerIntPair<InstOperand *, 1, bool> firstOpAndIsDynamic; +  llvm::PointerIntPair<OpOperand *, 1, bool> firstOpAndIsDynamic;    // The maximum number of operands that can be currently held by the storage.    unsigned capacity; @@ -340,21 +337,21 @@ struct ResizableStorage {  /// is optional.  class OperandStorage final      : private llvm::TrailingObjects<OperandStorage, ResizableStorage, -                                    InstOperand> { +                                    OpOperand> {  public:    OperandStorage(unsigned numOperands, bool resizable)        : numOperands(numOperands), resizable(resizable) {      // Initialize the resizable storage.      if (resizable) {        new (&getResizableStorage()) -          ResizableStorage(getTrailingObjects<InstOperand>(), numOperands); +          ResizableStorage(getTrailingObjects<OpOperand>(), numOperands);      }    }    ~OperandStorage() {      // Manually destruct the operands. -    for (auto &operand : getInstOperands()) -      operand.~InstOperand(); +    for (auto &operand : getOperands()) +      operand.~OpOperand();      // If the storage is resizable then destruct the utility.      if (resizable) @@ -369,10 +366,7 @@ public:    void eraseOperand(unsigned index);    /// Get the operation operands held by the storage. -  ArrayRef<InstOperand> getInstOperands() const { -    return {getRawOperands(), size()}; -  } -  MutableArrayRef<InstOperand> getInstOperands() { +  MutableArrayRef<OpOperand> getOperands() {      return {getRawOperands(), size()};    } @@ -381,8 +375,8 @@ public:    /// Returns the additional size necessary for allocating this object.    static size_t additionalAllocSize(unsigned numOperands, bool resizable) { -    return additionalSizeToAlloc<ResizableStorage, InstOperand>( -        resizable ? 1 : 0, numOperands); +    return additionalSizeToAlloc<ResizableStorage, OpOperand>(resizable ? 1 : 0, +                                                              numOperands);    }    /// Returns if this storage is resizable. @@ -393,13 +387,9 @@ private:    void clear() { numOperands = 0; }    /// Returns the current pointer for the raw operands array. -  InstOperand *getRawOperands() { -    return resizable ? getResizableStorage().getPointer() -                     : getTrailingObjects<InstOperand>(); -  } -  const InstOperand *getRawOperands() const { +  OpOperand *getRawOperands() {      return resizable ? getResizableStorage().getPointer() -                     : getTrailingObjects<InstOperand>(); +                     : getTrailingObjects<OpOperand>();    }    /// Returns the resizable operand utility class. @@ -407,10 +397,6 @@ private:      assert(resizable);      return *getTrailingObjects<ResizableStorage>();    } -  const ResizableStorage &getResizableStorage() const { -    assert(resizable); -    return *getTrailingObjects<ResizableStorage>(); -  }    /// Grow the internal resizable operand storage.    void grow(ResizableStorage &resizeUtil, size_t minSize); @@ -422,7 +408,7 @@ private:    bool resizable : 1;    // This stuff is used by the TrailingObjects template. -  friend llvm::TrailingObjects<OperandStorage, ResizableStorage, InstOperand>; +  friend llvm::TrailingObjects<OperandStorage, ResizableStorage, OpOperand>;    size_t numTrailingObjects(OverloadToken<ResizableStorage>) const {      return resizable ? 1 : 0;    } diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 0e17ac37ffd..948870b4bd7 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -33,7 +33,7 @@ class Operation;  class Value;  /// Operands contain a Value. -using InstOperand = IROperandImpl<Value>; +using OpOperand = IROperandImpl<Value>;  /// This is the common base class for all SSA values in the MLIR system,  /// representing a computable value that has a type and a set of users. @@ -74,7 +74,7 @@ public:    /// defines it.    Operation *getDefiningOp(); -  using use_iterator = ValueUseIterator<InstOperand>; +  using use_iterator = ValueUseIterator<OpOperand>;    using use_range = llvm::iterator_range<use_iterator>;    inline use_iterator use_begin(); @@ -100,7 +100,7 @@ inline raw_ostream &operator<<(raw_ostream &os, Value &value) {  // Utility functions for iterating through Value uses.  inline auto Value::use_begin() -> use_iterator { -  return use_iterator((InstOperand *)getFirstUse()); +  return use_iterator((OpOperand *)getFirstUse());  }  inline auto Value::use_end() -> use_iterator { return use_iterator(nullptr); } diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 689ed04b8e0..f7052feac23 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -371,7 +371,7 @@ bool mlir::isInstwiseShiftValid(AffineForOp forOp, ArrayRef<uint64_t> shifts) {      // Validate the results of this operation if it were to be shifted.      for (unsigned i = 0, e = op.getNumResults(); i < e; ++i) {        Value *result = op.getResult(i); -      for (const InstOperand &use : result->getUses()) { +      for (const auto &use : result->getUses()) {          // If an ancestor operation doesn't lie in the block of forOp,          // there is no shift to check.          if (auto *ancInst = forBody->findAncestorInstInBlock(*use.getOwner())) { diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp index 455f2a0b5fe..4057afd18e4 100644 --- a/mlir/lib/IR/Block.cpp +++ b/mlir/lib/IR/Block.cpp @@ -336,9 +336,9 @@ void Region::cloneInto(Region *dest, BlockAndValueMapping &mapper,    // Now that each of the blocks have been cloned, go through and remap the    // operands of each of the operations.    auto remapOperands = [&](Operation *op) { -    for (auto &instOp : op->getInstOperands()) -      if (auto *mappedOp = mapper.lookupOrNull(instOp.get())) -        instOp.set(mappedOp); +    for (auto &operand : op->getOpOperands()) +      if (auto *mappedOp = mapper.lookupOrNull(operand.get())) +        operand.set(mappedOp);      for (auto &succOp : op->getBlockOperands())        if (auto *mappedOp = mapper.lookupOrNull(succOp.get()))          succOp.set(mappedOp); diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index bb82f322e70..3581038c54d 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -65,12 +65,12 @@ unsigned OpResult::getResultNumber() {  }  //===----------------------------------------------------------------------===// -// InstOperand +// OpOperand  //===----------------------------------------------------------------------===//  /// Return which operand this is in the operand list. -template <> unsigned InstOperand::getOperandNumber() { -  return this - &getOwner()->getInstOperands()[0]; +template <> unsigned OpOperand::getOperandNumber() { +  return this - &getOwner()->getOpOperands()[0];  }  //===----------------------------------------------------------------------===// @@ -154,7 +154,7 @@ Operation *Operation::create(Location location, OperationName name,    for (unsigned i = 0, e = resultTypes.size(); i != e; ++i)      new (&instResults[i]) OpResult(resultTypes[i], op); -  auto InstOperands = op->getInstOperands(); +  auto opOperands = op->getOpOperands();    // Initialize normal operands.    unsigned operandIt = 0, operandE = operands.size(); @@ -165,7 +165,7 @@ Operation *Operation::create(Location location, OperationName name,      // separately below.      if (!operands[operandIt])        break; -    new (&InstOperands[nextOperand++]) InstOperand(op, operands[operandIt]); +    new (&opOperands[nextOperand++]) OpOperand(op, operands[operandIt]);    }    unsigned currentSuccNum = 0; @@ -203,7 +203,7 @@ Operation *Operation::create(Location location, OperationName name,        ++currentSuccNum;        continue;      } -    new (&InstOperands[nextOperand++]) InstOperand(op, operands[operandIt]); +    new (&opOperands[nextOperand++]) OpOperand(op, operands[operandIt]);      ++(*succOperandCountIt);    } @@ -449,7 +449,7 @@ void Operation::moveBefore(Block *block,  /// step in breaking cyclic dependences between references when they are to  /// be deleted.  void Operation::dropAllReferences() { -  for (auto &op : getInstOperands()) +  for (auto &op : getOpOperands())      op.drop();    for (auto ®ion : getRegions()) @@ -578,11 +578,11 @@ Operation *Operation::clone(BlockAndValueMapping &mapper,      // We add the operands separated by nullptr's for each successor.      unsigned firstSuccOperand =          getNumSuccessors() ? getSuccessorOperandIndex(0) : getNumOperands(); -    auto InstOperands = getInstOperands(); +    auto opOperands = getOpOperands();      unsigned i = 0;      for (; i != firstSuccOperand; ++i) -      operands.push_back(mapper.lookupOrDefault(InstOperands[i].get())); +      operands.push_back(mapper.lookupOrDefault(opOperands[i].get()));      successors.reserve(getNumSuccessors());      for (unsigned succ = 0, e = getNumSuccessors(); succ != e; ++succ) { diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp index c3029b03222..0e306eead2e 100644 --- a/mlir/lib/IR/OperationSupport.cpp +++ b/mlir/lib/IR/OperationSupport.cpp @@ -74,17 +74,17 @@ void detail::OperandStorage::setOperands(Operation *owner,    // If the number of operands is less than or equal to the current amount, we    // can just update in place.    if (operands.size() <= numOperands) { -    auto instOperands = getInstOperands(); +    auto opOperands = getOperands();      // If the number of new operands is less than the current count, then remove      // any extra operands.      for (unsigned i = operands.size(); i != numOperands; ++i) -      instOperands[i].~InstOperand(); +      opOperands[i].~OpOperand();      // Set the operands in place.      numOperands = operands.size();      for (unsigned i = 0; i != numOperands; ++i) -      instOperands[i].set(operands[i]); +      opOperands[i].set(operands[i]);      return;    } @@ -97,23 +97,23 @@ void detail::OperandStorage::setOperands(Operation *owner,      grow(resizeUtil, operands.size());    // Set the operands. -  InstOperand *opBegin = getRawOperands(); +  OpOperand *opBegin = getRawOperands();    for (unsigned i = 0; i != numOperands; ++i)      opBegin[i].set(operands[i]);    for (unsigned e = operands.size(); numOperands != e; ++numOperands) -    new (&opBegin[numOperands]) InstOperand(owner, operands[numOperands]); +    new (&opBegin[numOperands]) OpOperand(owner, operands[numOperands]);  }  /// Erase an operand held by the storage.  void detail::OperandStorage::eraseOperand(unsigned index) {    assert(index < size()); -  auto Operands = getInstOperands(); +  auto operands = getOperands();    --numOperands;    // Shift all operands down by 1 if the operand to remove is not at the end.    if (index != numOperands) -    std::rotate(&Operands[index], &Operands[index + 1], &Operands[numOperands]); -  Operands[numOperands].~InstOperand(); +    std::rotate(&operands[index], &operands[index + 1], &operands[numOperands]); +  operands[numOperands].~OpOperand();  }  /// Grow the internal operand storage. @@ -122,16 +122,16 @@ void detail::OperandStorage::grow(ResizableStorage &resizeUtil,    // Allocate a new storage array.    resizeUtil.capacity =        std::max(size_t(llvm::NextPowerOf2(resizeUtil.capacity + 2)), minSize); -  InstOperand *newStorage = static_cast<InstOperand *>( -      llvm::safe_malloc(resizeUtil.capacity * sizeof(InstOperand))); +  OpOperand *newStorage = static_cast<OpOperand *>( +      llvm::safe_malloc(resizeUtil.capacity * sizeof(OpOperand)));    // Move the current operands to the new storage. -  auto operands = getInstOperands(); +  auto operands = getOperands();    std::uninitialized_copy(std::make_move_iterator(operands.begin()),                            std::make_move_iterator(operands.end()), newStorage);    // Destroy the original operands and update the resizable storage pointer.    for (auto &operand : operands) -    operand.~InstOperand(); +    operand.~OpOperand();    resizeUtil.setDynamicStorage(newStorage);  } diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp index a579d439368..a63d462c4a9 100644 --- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp +++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp @@ -102,7 +102,7 @@ void MemRefDataFlowOpt::forwardStoreToLoad(LoadOp loadOp) {    // all store ops.    SmallVector<Operation *, 8> storeOps;    unsigned minSurroundingLoops = getNestingDepth(*loadOpInst); -  for (InstOperand &use : loadOp.getMemRef()->getUses()) { +  for (auto &use : loadOp.getMemRef()->getUses()) {      auto storeOp = use.getOwner()->dyn_cast<StoreOp>();      if (!storeOp)        continue; @@ -242,7 +242,7 @@ void MemRefDataFlowOpt::runOnFunction() {        // could still erase it if the call had no side-effects.        continue;      if (std::any_of(memref->use_begin(), memref->use_end(), -                    [&](InstOperand &use) { +                    [&](OpOperand &use) {                        auto *ownerInst = use.getOwner();                        return (!ownerInst->isa<StoreOp>() &&                                !ownerInst->isa<DeallocOp>()); diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index b01b8dba598..3505ed1c9cc 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -209,7 +209,7 @@ void GreedyPatternRewriteDriver::simplifyFunction() {      // side move it to the right side.      if (operandConstants.size() == 2 && operandConstants[0] &&          !operandConstants[1] && op->isCommutative()) { -      std::swap(op->getInstOperand(0), op->getInstOperand(1)); +      std::swap(op->getOpOperand(0), op->getOpOperand(1));        std::swap(operandConstants[0], operandConstants[1]);      }  | 

