diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h index 8bedb348cfaa..4e840409a27f 100644 --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -66,12 +66,12 @@ public: OpType *operator->() { return &value; } - operator bool() const { return value.getOperation(); } + operator bool() const { return value.getInstruction(); } /// OpPointer can be implicitly converted to OpType*. /// Return `nullptr` if there is no associated OperationInst*. operator OpType *() { - if (!value.getOperation()) + if (!value.getInstruction()) return nullptr; return &value; } @@ -102,12 +102,12 @@ public: const OpType *operator->() const { return &value; } /// Return true if non-null. - operator bool() const { return value.getOperation(); } + operator bool() const { return value.getInstruction(); } /// ConstOpPointer can always be implicitly converted to const OpType*. /// Return `nullptr` if there is no associated OperationInst*. operator const OpType *() const { - if (!value.getOperation()) + if (!value.getInstruction()) return nullptr; return &value; } @@ -137,8 +137,8 @@ private: class OpState { public: /// Return the operation that this refers to. - const OperationInst *getOperation() const { return state; } - OperationInst *getOperation() { return state; } + const OperationInst *getInstruction() const { return state; } + OperationInst *getInstruction() { return state; } /// The source location the operation was defined or derived from. Location getLoc() const { return state->getLoc(); } @@ -303,7 +303,7 @@ template class TraitType> class TraitBase { protected: /// Return the ultimate OperationInst being worked on. - OperationInst *getOperation() { + OperationInst *getInstruction() { // We have to cast up to the trait type, then to the concrete type, then to // the BaseState class in explicit hops because the concrete type will // multiply derive from the (content free) TraitBase class, and we need to @@ -311,10 +311,10 @@ protected: auto *trait = static_cast *>(this); auto *concrete = static_cast(trait); auto *base = static_cast(concrete); - return base->getOperation(); + return base->getInstruction(); } - const OperationInst *getOperation() const { - return const_cast(this)->getOperation(); + const OperationInst *getInstruction() const { + return const_cast(this)->getInstruction(); } /// Provide default implementations of trait hooks. This allows traits to @@ -346,12 +346,14 @@ template class OneOperand : public TraitBase { public: const Value *getOperand() const { - return this->getOperation()->getOperand(0); + return this->getInstruction()->getOperand(0); } - Value *getOperand() { return this->getOperation()->getOperand(0); } + Value *getOperand() { return this->getInstruction()->getOperand(0); } - void setOperand(Value *value) { this->getOperation()->setOperand(0, value); } + void setOperand(Value *value) { + this->getInstruction()->setOperand(0, value); + } static bool verifyTrait(const OperationInst *op) { return impl::verifyOneOperand(op); @@ -369,15 +371,15 @@ public: class Impl : public TraitBase::Impl> { public: const Value *getOperand(unsigned i) const { - return this->getOperation()->getOperand(i); + return this->getInstruction()->getOperand(i); } Value *getOperand(unsigned i) { - return this->getOperation()->getOperand(i); + return this->getInstruction()->getOperand(i); } void setOperand(unsigned i, Value *value) { - this->getOperation()->setOperand(i, value); + this->getInstruction()->setOperand(i, value); } static bool verifyTrait(const OperationInst *op) { @@ -397,42 +399,42 @@ public: class Impl : public TraitBase::Impl> { public: unsigned getNumOperands() const { - return this->getOperation()->getNumOperands(); + return this->getInstruction()->getNumOperands(); } const Value *getOperand(unsigned i) const { - return this->getOperation()->getOperand(i); + return this->getInstruction()->getOperand(i); } Value *getOperand(unsigned i) { - return this->getOperation()->getOperand(i); + return this->getInstruction()->getOperand(i); } void setOperand(unsigned i, Value *value) { - this->getOperation()->setOperand(i, value); + this->getInstruction()->setOperand(i, value); } // Support non-const operand iteration. using operand_iterator = OperationInst::operand_iterator; operand_iterator operand_begin() { - return this->getOperation()->operand_begin(); + return this->getInstruction()->operand_begin(); } operand_iterator operand_end() { - return this->getOperation()->operand_end(); + return this->getInstruction()->operand_end(); } llvm::iterator_range getOperands() { - return this->getOperation()->getOperands(); + return this->getInstruction()->getOperands(); } // Support const operand iteration. using const_operand_iterator = OperationInst::const_operand_iterator; const_operand_iterator operand_begin() const { - return this->getOperation()->operand_begin(); + return this->getInstruction()->operand_begin(); } const_operand_iterator operand_end() const { - return this->getOperation()->operand_end(); + return this->getInstruction()->operand_end(); } llvm::iterator_range getOperands() const { - return this->getOperation()->getOperands(); + return this->getInstruction()->getOperands(); } static bool verifyTrait(const OperationInst *op) { @@ -447,39 +449,43 @@ template class VariadicOperands : public TraitBase { public: unsigned getNumOperands() const { - return this->getOperation()->getNumOperands(); + return this->getInstruction()->getNumOperands(); } const Value *getOperand(unsigned i) const { - return this->getOperation()->getOperand(i); + return this->getInstruction()->getOperand(i); } - Value *getOperand(unsigned i) { return this->getOperation()->getOperand(i); } + Value *getOperand(unsigned i) { + return this->getInstruction()->getOperand(i); + } void setOperand(unsigned i, Value *value) { - this->getOperation()->setOperand(i, value); + this->getInstruction()->setOperand(i, value); } // Support non-const operand iteration. using operand_iterator = OperationInst::operand_iterator; operand_iterator operand_begin() { - return this->getOperation()->operand_begin(); + return this->getInstruction()->operand_begin(); + } + operand_iterator operand_end() { + return this->getInstruction()->operand_end(); } - operand_iterator operand_end() { return this->getOperation()->operand_end(); } llvm::iterator_range getOperands() { - return this->getOperation()->getOperands(); + return this->getInstruction()->getOperands(); } // Support const operand iteration. using const_operand_iterator = OperationInst::const_operand_iterator; const_operand_iterator operand_begin() const { - return this->getOperation()->operand_begin(); + return this->getInstruction()->operand_begin(); } const_operand_iterator operand_end() const { - return this->getOperation()->operand_end(); + return this->getInstruction()->operand_end(); } llvm::iterator_range getOperands() const { - return this->getOperation()->getOperands(); + return this->getInstruction()->getOperands(); } }; @@ -498,8 +504,10 @@ public: template class OneResult : public TraitBase { public: - Value *getResult() { return this->getOperation()->getResult(0); } - const Value *getResult() const { return this->getOperation()->getResult(0); } + Value *getResult() { return this->getInstruction()->getResult(0); } + const Value *getResult() const { + return this->getInstruction()->getResult(0); + } Type getType() const { return getResult()->getType(); } @@ -542,10 +550,12 @@ public: static unsigned getNumResults() { return N; } const Value *getResult(unsigned i) const { - return this->getOperation()->getResult(i); + return this->getInstruction()->getResult(i); } - Value *getResult(unsigned i) { return this->getOperation()->getResult(i); } + Value *getResult(unsigned i) { + return this->getInstruction()->getResult(i); + } Type getType(unsigned i) const { return getResult(i)->getType(); } @@ -566,10 +576,12 @@ public: class Impl : public TraitBase::Impl> { public: const Value *getResult(unsigned i) const { - return this->getOperation()->getResult(i); + return this->getInstruction()->getResult(i); } - Value *getResult(unsigned i) { return this->getOperation()->getResult(i); } + Value *getResult(unsigned i) { + return this->getInstruction()->getResult(i); + } Type getType(unsigned i) const { return getResult(i)->getType(); } @@ -585,39 +597,39 @@ template class VariadicResults : public TraitBase { public: unsigned getNumResults() const { - return this->getOperation()->getNumResults(); + return this->getInstruction()->getNumResults(); } const Value *getResult(unsigned i) const { - return this->getOperation()->getResult(i); + return this->getInstruction()->getResult(i); } - Value *getResult(unsigned i) { return this->getOperation()->getResult(i); } + Value *getResult(unsigned i) { return this->getInstruction()->getResult(i); } void setResult(unsigned i, Value *value) { - this->getOperation()->setResult(i, value); + this->getInstruction()->setResult(i, value); } // Support non-const result iteration. using result_iterator = OperationInst::result_iterator; result_iterator result_begin() { - return this->getOperation()->result_begin(); + return this->getInstruction()->result_begin(); } - result_iterator result_end() { return this->getOperation()->result_end(); } + result_iterator result_end() { return this->getInstruction()->result_end(); } llvm::iterator_range getResults() { - return this->getOperation()->getResults(); + return this->getInstruction()->getResults(); } // Support const result iteration. using const_result_iterator = OperationInst::const_result_iterator; const_result_iterator result_begin() const { - return this->getOperation()->result_begin(); + return this->getInstruction()->result_begin(); } const_result_iterator result_end() const { - return this->getOperation()->result_end(); + return this->getInstruction()->result_end(); } llvm::iterator_range getResults() const { - return this->getOperation()->getResults(); + return this->getInstruction()->getResults(); } }; @@ -734,28 +746,28 @@ public: } unsigned getNumSuccessors() const { - return this->getOperation()->getNumSuccessors(); + return this->getInstruction()->getNumSuccessors(); } unsigned getNumSuccessorOperands(unsigned index) const { - return this->getOperation()->getNumSuccessorOperands(index); + return this->getInstruction()->getNumSuccessorOperands(index); } const BasicBlock *getSuccessor(unsigned index) const { - return this->getOperation()->getSuccessor(index); + return this->getInstruction()->getSuccessor(index); } BasicBlock *getSuccessor(unsigned index) { - return this->getOperation()->getSuccessor(index); + return this->getInstruction()->getSuccessor(index); } void setSuccessor(BasicBlock *block, unsigned index) { - return this->getOperation()->setSuccessor(block, index); + return this->getInstruction()->setSuccessor(block, index); } void addSuccessorOperand(unsigned index, Value *value) { - return this->getOperation()->addSuccessorOperand(index, value); + return this->getInstruction()->addSuccessorOperand(index, value); } void addSuccessorOperands(unsigned index, ArrayRef values) { - return this->getOperation()->addSuccessorOperand(index, values); + return this->getInstruction()->addSuccessorOperand(index, values); } }; @@ -777,8 +789,10 @@ class Op : public OpState, Traits...>::value> { public: /// Return the operation that this refers to. - const OperationInst *getOperation() const { return OpState::getOperation(); } - OperationInst *getOperation() { return OpState::getOperation(); } + const OperationInst *getInstruction() const { + return OpState::getInstruction(); + } + OperationInst *getInstruction() { return OpState::getInstruction(); } /// Return true if this "op class" can match against the specified operation. /// This hook can be overridden with a more specific implementation in @@ -903,7 +917,7 @@ public: return impl::parseBinaryOp(parser, result); } void print(OpAsmPrinter *p) const { - return impl::printBinaryOp(this->getOperation(), p); + return impl::printBinaryOp(this->getInstruction(), p); } protected: @@ -939,7 +953,7 @@ public: return impl::parseCastOp(parser, result); } void print(OpAsmPrinter *p) const { - return impl::printCastOp(this->getOperation(), p); + return impl::printCastOp(this->getInstruction(), p); } protected: diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h index 1a467131cab5..aa5a14e75d6f 100644 --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -230,7 +230,7 @@ public: template void replaceOpWithNewOp(OperationInst *op, Args... args) { auto newOp = create(op->getLoc(), args...); - replaceOpWithResultsOfAnotherOp(op, newOp->getOperation(), {}); + replaceOpWithResultsOfAnotherOp(op, newOp->getInstruction(), {}); } /// Replaces the result op with a new op that is created without verification. @@ -241,7 +241,7 @@ public: ArrayRef valuesToRemoveIfDead, Args... args) { auto newOp = create(op->getLoc(), args...); - replaceOpWithResultsOfAnotherOp(op, newOp->getOperation(), + replaceOpWithResultsOfAnotherOp(op, newOp->getInstruction(), valuesToRemoveIfDead); } diff --git a/mlir/include/mlir/IR/Statement.h b/mlir/include/mlir/IR/Statement.h index d03d1daaa88e..1e2e1103c984 100644 --- a/mlir/include/mlir/IR/Statement.h +++ b/mlir/include/mlir/IR/Statement.h @@ -160,14 +160,14 @@ public: /// Returns a const iterator on the underlying Values. llvm::iterator_range getOperands() const; - MutableArrayRef getStmtOperands(); - ArrayRef getStmtOperands() const { - return const_cast(this)->getStmtOperands(); + MutableArrayRef getInstOperands(); + ArrayRef getInstOperands() const { + return const_cast(this)->getInstOperands(); } - StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; } - const StmtOperand &getStmtOperand(unsigned idx) const { - return getStmtOperands()[idx]; + InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } + const InstOperand &getInstOperand(unsigned idx) const { + return getInstOperands()[idx]; } /// Emit an error about fatal conditions with this operation, reporting up to diff --git a/mlir/include/mlir/IR/Statements.h b/mlir/include/mlir/IR/Statements.h index 7b94486e42cd..d04ebd776b9b 100644 --- a/mlir/include/mlir/IR/Statements.h +++ b/mlir/include/mlir/IR/Statements.h @@ -46,8 +46,8 @@ class Function; /// class OperationInst final : public Statement, - private llvm::TrailingObjects { + private llvm::TrailingObjects { public: /// Create a new OperationInst with the specific fields. static OperationInst * @@ -76,12 +76,12 @@ public: unsigned getNumOperands() const { return numOperands; } - Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); } + Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); } const Value *getOperand(unsigned idx) const { - return getStmtOperand(idx).get(); + return getInstOperand(idx).get(); } void setOperand(unsigned idx, Value *value) { - return getStmtOperand(idx).set(value); + return getInstOperand(idx).set(value); } // Support non-const operand iteration. @@ -115,16 +115,16 @@ public: return {operand_begin(), operand_end()}; } - ArrayRef getStmtOperands() const { - return {getTrailingObjects(), numOperands}; + ArrayRef getInstOperands() const { + return {getTrailingObjects(), numOperands}; } - MutableArrayRef getStmtOperands() { - return {getTrailingObjects(), numOperands}; + MutableArrayRef getInstOperands() { + return {getTrailingObjects(), numOperands}; } - StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; } - const StmtOperand &getStmtOperand(unsigned idx) const { - return getStmtOperands()[idx]; + InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } + const InstOperand &getInstOperand(unsigned idx) const { + return getInstOperands()[idx]; } //===--------------------------------------------------------------------===// @@ -136,8 +136,8 @@ public: unsigned getNumResults() const { return numResults; } - Value *getResult(unsigned idx) { return &getStmtResult(idx); } - const Value *getResult(unsigned idx) const { return &getStmtResult(idx); } + Value *getResult(unsigned idx) { return &getInstResult(idx); } + const Value *getResult(unsigned idx) const { return &getInstResult(idx); } // Support non-const result iteration. using result_iterator = ResultIterator; @@ -154,18 +154,18 @@ public: llvm::iterator_range getResults() const; - ArrayRef getStmtResults() const { - return {getTrailingObjects(), numResults}; + ArrayRef getInstResults() const { + return {getTrailingObjects(), numResults}; } - MutableArrayRef getStmtResults() { - return {getTrailingObjects(), numResults}; + MutableArrayRef getInstResults() { + return {getTrailingObjects(), numResults}; } - StmtResult &getStmtResult(unsigned idx) { return getStmtResults()[idx]; } + InstResult &getInstResult(unsigned idx) { return getInstResults()[idx]; } - const StmtResult &getStmtResult(unsigned idx) const { - return getStmtResults()[idx]; + const InstResult &getInstResult(unsigned idx) const { + return getInstResults()[idx]; } // Support result type iteration. @@ -404,12 +404,12 @@ private: void eraseOperand(unsigned index); // This stuff is used by the TrailingObjects template. - friend llvm::TrailingObjects; - size_t numTrailingObjects(OverloadToken) const { + friend llvm::TrailingObjects; + size_t numTrailingObjects(OverloadToken) const { return numOperands; } - size_t numTrailingObjects(OverloadToken) const { + size_t numTrailingObjects(OverloadToken) const { return numResults; } size_t numTrailingObjects(OverloadToken) const { @@ -603,12 +603,12 @@ public: unsigned getNumOperands() const { return operands.size(); } - Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); } + Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); } const Value *getOperand(unsigned idx) const { - return getStmtOperand(idx).get(); + return getInstOperand(idx).get(); } void setOperand(unsigned idx, Value *value) { - getStmtOperand(idx).set(value); + getInstOperand(idx).set(value); } operand_iterator operand_begin() { return operand_iterator(this, 0); } @@ -623,11 +623,11 @@ public: return const_operand_iterator(this, getNumOperands()); } - ArrayRef getStmtOperands() const { return operands; } - MutableArrayRef getStmtOperands() { return operands; } - StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; } - const StmtOperand &getStmtOperand(unsigned idx) const { - return getStmtOperands()[idx]; + ArrayRef getInstOperands() const { return operands; } + MutableArrayRef getInstOperands() { return operands; } + InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } + const InstOperand &getInstOperand(unsigned idx) const { + return getInstOperands()[idx]; } // TODO: provide iterators for the lower and upper bound operands @@ -677,7 +677,7 @@ private: // Operands for the lower and upper bounds, with the former followed by the // latter. Dimensional operands are followed by symbolic operands for each // bound. - std::vector operands; + std::vector operands; explicit ForStmt(Location location, unsigned numOperands, AffineMap lbMap, AffineMap ubMap, int64_t step); @@ -696,8 +696,8 @@ public: const Value *getOperand(unsigned idx) const { return stmt.getOperand(opStart + idx); } - const StmtOperand &getStmtOperand(unsigned idx) const { - return stmt.getStmtOperand(opStart + idx); + const InstOperand &getInstOperand(unsigned idx) const { + return stmt.getInstOperand(opStart + idx); } using operand_iterator = ForStmt::operand_iterator; @@ -714,9 +714,9 @@ public: /// Returns an iterator on the underlying Value's (Value *). operand_range getOperands() const { return {operand_begin(), operand_end()}; } - ArrayRef getStmtOperands() const { - auto ops = stmt.getStmtOperands(); - return ArrayRef(ops.begin() + opStart, ops.begin() + opEnd); + ArrayRef getInstOperands() const { + auto ops = stmt.getInstOperands(); + return ArrayRef(ops.begin() + opStart, ops.begin() + opEnd); } private: @@ -783,12 +783,12 @@ public: unsigned getNumOperands() const { return operands.size(); } - Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); } + Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); } const Value *getOperand(unsigned idx) const { - return getStmtOperand(idx).get(); + return getInstOperand(idx).get(); } void setOperand(unsigned idx, Value *value) { - getStmtOperand(idx).set(value); + getInstOperand(idx).set(value); } operand_iterator operand_begin() { return operand_iterator(this, 0); } @@ -803,11 +803,11 @@ public: return const_operand_iterator(this, getNumOperands()); } - ArrayRef getStmtOperands() const { return operands; } - MutableArrayRef getStmtOperands() { return operands; } - StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; } - const StmtOperand &getStmtOperand(unsigned idx) const { - return getStmtOperands()[idx]; + ArrayRef getInstOperands() const { return operands; } + MutableArrayRef getInstOperands() { return operands; } + InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; } + const InstOperand &getInstOperand(unsigned idx) const { + return getInstOperands()[idx]; } //===--------------------------------------------------------------------===// @@ -831,7 +831,7 @@ private: IntegerSet set; // Condition operands. - std::vector operands; + std::vector operands; explicit IfStmt(Location location, unsigned numOperands, IntegerSet set); }; diff --git a/mlir/include/mlir/IR/UseDefLists.h b/mlir/include/mlir/IR/UseDefLists.h index 08b0898342cc..4b6ad287a877 100644 --- a/mlir/include/mlir/IR/UseDefLists.h +++ b/mlir/include/mlir/IR/UseDefLists.h @@ -128,7 +128,7 @@ public: } /// Return the owner of this operand, for example, the OperationInst that - /// contains a StmtOperand. + /// contains an InstOperand. IROperandOwner *getOwner() { return owner; } const IROperandOwner *getOwner() const { return owner; } @@ -175,8 +175,8 @@ private: /// This points to the previous link in the use-chain. IROperand **back = nullptr; - /// The owner of this operand, for example, the OperationInst that contains a - /// StmtOperand. + /// The owner of this operand, for example, the OperationInst that contains an + /// InstOperand. IROperandOwner *const owner; /// Operands are not copyable or assignable. diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index 3d8f1590371d..75184dc7a3f4 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -33,10 +33,9 @@ class Statement; class StmtBlock; class Value; using Instruction = Statement; -using OperationInst = OperationInst; /// Operands contain a Value. -using StmtOperand = IROperandImpl; +using InstOperand = IROperandImpl; /// 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. @@ -46,7 +45,7 @@ public: /// This enumerates all of the SSA value kinds in the MLIR system. enum class Kind { BlockArgument, // block argument - StmtResult, // statement result + InstResult, // operation instruction result ForStmt, // 'for' statement induction variable }; @@ -87,7 +86,7 @@ public: return const_cast(this)->getDefiningInst(); } - using use_iterator = ValueUseIterator; + using use_iterator = ValueUseIterator; using use_range = llvm::iterator_range; inline use_iterator use_begin() const; @@ -113,7 +112,7 @@ inline raw_ostream &operator<<(raw_ostream &os, const Value &value) { // Utility functions for iterating through Value uses. inline auto Value::use_begin() const -> use_iterator { - return use_iterator((StmtOperand *)getFirstUse()); + return use_iterator((InstOperand *)getFirstUse()); } inline auto Value::use_end() const -> use_iterator { @@ -152,13 +151,13 @@ private: }; /// This is a value defined by a result of an operation instruction. -class StmtResult : public Value { +class InstResult : public Value { public: - StmtResult(Type type, OperationInst *owner) - : Value(Value::Kind::StmtResult, type), owner(owner) {} + InstResult(Type type, OperationInst *owner) + : Value(Value::Kind::InstResult, type), owner(owner) {} static bool classof(const Value *value) { - return value->getKind() == Kind::StmtResult; + return value->getKind() == Kind::InstResult; } OperationInst *getOwner() { return owner; } @@ -174,10 +173,6 @@ private: OperationInst *const owner; }; -// TODO(clattner) clean all this up. -using BBArgument = BlockArgument; -using InstResult = StmtResult; - } // namespace mlir #endif diff --git a/mlir/include/mlir/StandardOps/StandardOps.h b/mlir/include/mlir/StandardOps/StandardOps.h index 33e08bae2fc4..e6e37ccfb81b 100644 --- a/mlir/include/mlir/StandardOps/StandardOps.h +++ b/mlir/include/mlir/StandardOps/StandardOps.h @@ -369,8 +369,8 @@ public: // Returns the source memerf indices for this DMA operation. llvm::iterator_range getSrcIndices() const { - return {getOperation()->operand_begin() + 1, - getOperation()->operand_begin() + 1 + getSrcMemRefRank()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_begin() + 1 + getSrcMemRefRank()}; } // Returns the destination MemRefType for this DMA operations. @@ -391,8 +391,8 @@ public: // Returns the destination memref indices for this DMA operation. llvm::iterator_range getDstIndices() const { - return {getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1, - getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1 + + return {getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1, + getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1 + getDstMemRefRank()}; } @@ -415,8 +415,8 @@ public: getTagIndices() const { unsigned tagIndexStartPos = 1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1 + 1; - return {getOperation()->operand_begin() + tagIndexStartPos, - getOperation()->operand_begin() + tagIndexStartPos + + return {getInstruction()->operand_begin() + tagIndexStartPos, + getInstruction()->operand_begin() + tagIndexStartPos + getTagMemRefRank()}; } @@ -504,8 +504,8 @@ public: // Returns the tag memref index for this DMA operation. llvm::iterator_range getTagIndices() const { - return {getOperation()->operand_begin() + 1, - getOperation()->operand_begin() + 1 + getTagMemRefRank()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_begin() + 1 + getTagMemRefRank()}; } // Returns the rank (number of indices) of the tag memref. @@ -550,12 +550,14 @@ public: const Value *getAggregate() const { return getOperand(0); } llvm::iterator_range getIndices() { - return {getOperation()->operand_begin() + 1, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_end()}; } llvm::iterator_range getIndices() const { - return {getOperation()->operand_begin() + 1, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_end()}; } static StringRef getOperationName() { return "extract_element"; } @@ -593,12 +595,14 @@ public: } llvm::iterator_range getIndices() { - return {getOperation()->operand_begin() + 1, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_end()}; } llvm::iterator_range getIndices() const { - return {getOperation()->operand_begin() + 1, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 1, + getInstruction()->operand_end()}; } static StringRef getOperationName() { return "load"; } @@ -755,12 +759,14 @@ public: } llvm::iterator_range getIndices() { - return {getOperation()->operand_begin() + 2, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 2, + getInstruction()->operand_end()}; } llvm::iterator_range getIndices() const { - return {getOperation()->operand_begin() + 2, getOperation()->operand_end()}; + return {getInstruction()->operand_begin() + 2, + getInstruction()->operand_end()}; } static StringRef getOperationName() { return "store"; } diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp index 1a28eb138f40..c796bb8cd00e 100644 --- a/mlir/lib/Analysis/Dominance.cpp +++ b/mlir/lib/Analysis/Dominance.cpp @@ -76,5 +76,5 @@ bool DominanceInfo::properlyDominates(const Value *a, const Instruction *b) { // bbarguments properly dominate all instructions in their own block, so we // use a dominates check here, not a properlyDominates check. - return dominates(cast(a)->getOwner(), b->getBlock()); + return dominates(cast(a)->getOwner(), b->getBlock()); } diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp index 85af39222c4f..caeeccb677f5 100644 --- a/mlir/lib/Analysis/LoopAnalysis.cpp +++ b/mlir/lib/Analysis/LoopAnalysis.cpp @@ -205,7 +205,7 @@ static bool isContiguousAccess(const Value &iv, const LoadOrStoreOp &memoryOp, auto layoutMap = memRefType.getAffineMaps(); // TODO(ntv): remove dependence on Builder once we support non-identity // layout map. - Builder b(memoryOp.getOperation()->getContext()); + Builder b(memoryOp.getInstruction()->getContext()); if (layoutMap.size() >= 2 || (layoutMap.size() == 1 && !(layoutMap[0] == @@ -317,7 +317,7 @@ bool mlir::isStmtwiseShiftValid(const ForStmt &forStmt, if (const auto *opStmt = dyn_cast(&stmt)) { for (unsigned i = 0, e = opStmt->getNumResults(); i < e; ++i) { const Value *result = opStmt->getResult(i); - for (const StmtOperand &use : result->getUses()) { + for (const InstOperand &use : result->getUses()) { // If an ancestor statement doesn't lie in the block of forStmt, there // is no shift to check. // This is a naive way. If performance becomes an issue, a map can diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp index a63723b333cf..80adb369aef4 100644 --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -282,7 +282,7 @@ bool mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp, std::is_same>::value, "function argument should be either a LoadOp or a StoreOp"); - OperationInst *opStmt = cast(loadOrStoreOp->getOperation()); + OperationInst *opStmt = loadOrStoreOp->getInstruction(); MemRefRegion region; if (!getMemRefRegion(opStmt, /*loopDepth=*/0, ®ion)) return false; diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 9f465ab85072..c6b731aac572 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1014,7 +1014,7 @@ protected: // Otherwise number it normally. valueIDs[value] = nextValueID++; return; - case Value::Kind::StmtResult: + case Value::Kind::InstResult: // This is an uninteresting result, give it a boring number and be // done with it. valueIDs[value] = nextValueID++; @@ -1063,7 +1063,7 @@ protected: resultNo = result->getResultNumber(); lookupValue = result->getOwner()->getResult(0); } - } else if (auto *result = dyn_cast(value)) { + } else if (auto *result = dyn_cast(value)) { if (result->getOwner()->getNumResults() != 1) { resultNo = result->getResultNumber(); lookupValue = result->getOwner()->getResult(0); @@ -1235,7 +1235,7 @@ void CFGFunctionPrinter::print(const BasicBlock *block) { if (!block->args_empty()) { os << '('; - interleaveComma(block->getArguments(), [&](const BBArgument *arg) { + interleaveComma(block->getArguments(), [&](const BlockArgument *arg) { printValueID(arg); os << ": "; printType(arg->getType()); @@ -1340,7 +1340,7 @@ public: } // Print loop bounds. - void printDimAndSymbolList(ArrayRef ops, unsigned numDims); + void printDimAndSymbolList(ArrayRef ops, unsigned numDims); void printBound(AffineBound bound, const char *prefix); // Number of spaces used for indenting nested statements. @@ -1451,19 +1451,20 @@ void MLFunctionPrinter::print(const ForStmt *stmt) { os.indent(numSpaces) << "}"; } -void MLFunctionPrinter::printDimAndSymbolList(ArrayRef ops, +void MLFunctionPrinter::printDimAndSymbolList(ArrayRef ops, unsigned numDims) { auto printComma = [&]() { os << ", "; }; os << '('; - interleave(ops.begin(), ops.begin() + numDims, - [&](const StmtOperand &v) { printOperand(v.get()); }, printComma); + interleave( + ops.begin(), ops.begin() + numDims, + [&](const InstOperand &v) { printOperand(v.get()); }, printComma); os << ')'; if (numDims < ops.size()) { os << '['; - interleave(ops.begin() + numDims, ops.end(), - [&](const StmtOperand &v) { printOperand(v.get()); }, - printComma); + interleave( + ops.begin() + numDims, ops.end(), + [&](const InstOperand &v) { printOperand(v.get()); }, printComma); os << ']'; } } @@ -1503,14 +1504,14 @@ void MLFunctionPrinter::printBound(AffineBound bound, const char *prefix) { // Print the map and its operands. printAffineMapReference(map); - printDimAndSymbolList(bound.getStmtOperands(), map.getNumDims()); + printDimAndSymbolList(bound.getInstOperands(), map.getNumDims()); } void MLFunctionPrinter::print(const IfStmt *stmt) { os.indent(numSpaces) << "if "; IntegerSet set = stmt->getIntegerSet(); printIntegerSetReference(set); - printDimAndSymbolList(stmt->getStmtOperands(), set.getNumDims()); + printDimAndSymbolList(stmt->getInstOperands(), set.getNumDims()); os << " {\n"; print(stmt->getThen()); os.indent(numSpaces) << "}"; @@ -1579,7 +1580,7 @@ void Value::print(raw_ostream &os) const { // TODO: Improve this. os << "\n"; return; - case Value::Kind::StmtResult: + case Value::Kind::InstResult: return getDefiningInst()->print(os); case Value::Kind::ForStmt: return cast(this)->print(os); diff --git a/mlir/lib/IR/BuiltinOps.cpp b/mlir/lib/IR/BuiltinOps.cpp index a87ae6b85f07..51596a9f09eb 100644 --- a/mlir/lib/IR/BuiltinOps.cpp +++ b/mlir/lib/IR/BuiltinOps.cpp @@ -183,24 +183,24 @@ bool BranchOp::parse(OpAsmParser *parser, OperationState *result) { void BranchOp::print(OpAsmPrinter *p) const { *p << "br "; - p->printSuccessorAndUseList(getOperation(), 0); + p->printSuccessorAndUseList(getInstruction(), 0); } bool BranchOp::verify() const { // ML functions do not have branching terminators. - if (getOperation()->getFunction()->isML()) + if (getInstruction()->getFunction()->isML()) return (emitOpError("cannot occur in a ML function"), true); return false; } -BasicBlock *BranchOp::getDest() { return getOperation()->getSuccessor(0); } +BasicBlock *BranchOp::getDest() { return getInstruction()->getSuccessor(0); } void BranchOp::setDest(BasicBlock *block) { - return getOperation()->setSuccessor(block, 0); + return getInstruction()->setSuccessor(block, 0); } void BranchOp::eraseOperand(unsigned index) { - getOperation()->eraseSuccessorOperand(0, index); + getInstruction()->eraseSuccessorOperand(0, index); } //===----------------------------------------------------------------------===// @@ -249,14 +249,14 @@ void CondBranchOp::print(OpAsmPrinter *p) const { *p << "cond_br "; p->printOperand(getCondition()); *p << ", "; - p->printSuccessorAndUseList(getOperation(), trueIndex); + p->printSuccessorAndUseList(getInstruction(), trueIndex); *p << ", "; - p->printSuccessorAndUseList(getOperation(), falseIndex); + p->printSuccessorAndUseList(getInstruction(), falseIndex); } bool CondBranchOp::verify() const { // ML functions do not have branching terminators. - if (getOperation()->getFunction()->isML()) + if (getInstruction()->getFunction()->isML()) return (emitOpError("cannot occur in a ML function"), true); if (!getCondition()->getType().isInteger(1)) return emitOpError("expected condition type was boolean (i1)"); @@ -264,27 +264,27 @@ bool CondBranchOp::verify() const { } BasicBlock *CondBranchOp::getTrueDest() { - return getOperation()->getSuccessor(trueIndex); + return getInstruction()->getSuccessor(trueIndex); } BasicBlock *CondBranchOp::getFalseDest() { - return getOperation()->getSuccessor(falseIndex); + return getInstruction()->getSuccessor(falseIndex); } unsigned CondBranchOp::getNumTrueOperands() const { - return getOperation()->getNumSuccessorOperands(trueIndex); + return getInstruction()->getNumSuccessorOperands(trueIndex); } void CondBranchOp::eraseTrueOperand(unsigned index) { - getOperation()->eraseSuccessorOperand(trueIndex, index); + getInstruction()->eraseSuccessorOperand(trueIndex, index); } unsigned CondBranchOp::getNumFalseOperands() const { - return getOperation()->getNumSuccessorOperands(falseIndex); + return getInstruction()->getNumSuccessorOperands(falseIndex); } void CondBranchOp::eraseFalseOperand(unsigned index) { - getOperation()->eraseSuccessorOperand(falseIndex, index); + getInstruction()->eraseSuccessorOperand(falseIndex, index); } //===----------------------------------------------------------------------===// @@ -468,7 +468,7 @@ void ReturnOp::print(OpAsmPrinter *p) const { } bool ReturnOp::verify() const { - auto *function = cast(getOperation())->getFunction(); + auto *function = getInstruction()->getFunction(); // The operand number and types must match the function signature. const auto &results = function->getType().getResults(); diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 6a9b37560db4..23e54b3638e8 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -61,7 +61,7 @@ bool OpState::parse(OpAsmParser *parser, OperationState *result) { // The fallback for the printer is to print it the longhand form. void OpState::print(OpAsmPrinter *p) const { - p->printDefaultOp(getOperation()); + p->printDefaultOp(getInstruction()); } /// Emit an error about fatal conditions with this operation, reporting up to @@ -69,25 +69,25 @@ void OpState::print(OpAsmPrinter *p) const { /// the containing application, only use when the IR is in an inconsistent /// state. bool OpState::emitError(const Twine &message) const { - return getOperation()->emitError(message); + return getInstruction()->emitError(message); } /// Emit an error with the op name prefixed, like "'dim' op " which is /// convenient for verifiers. bool OpState::emitOpError(const Twine &message) const { - return getOperation()->emitOpError(message); + return getInstruction()->emitOpError(message); } /// Emit a warning about this operation, reporting up to any diagnostic /// handlers that may be listening. void OpState::emitWarning(const Twine &message) const { - getOperation()->emitWarning(message); + getInstruction()->emitWarning(message); } /// Emit a note about this operation, reporting up to any diagnostic /// handlers that may be listening. void OpState::emitNote(const Twine &message) const { - getOperation()->emitNote(message); + getInstruction()->emitNote(message); } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/IR/Statement.cpp b/mlir/lib/IR/Statement.cpp index 19457efa8c3d..649bb9c4f783 100644 --- a/mlir/lib/IR/Statement.cpp +++ b/mlir/lib/IR/Statement.cpp @@ -29,23 +29,23 @@ using namespace mlir; //===----------------------------------------------------------------------===// -// StmtResult +// InstResult //===----------------------------------------------------------------------===// /// Return the result number of this result. -unsigned StmtResult::getResultNumber() const { +unsigned InstResult::getResultNumber() const { // Results are always stored consecutively, so use pointer subtraction to // figure out what number this is. - return this - &getOwner()->getStmtResults()[0]; + return this - &getOwner()->getInstResults()[0]; } //===----------------------------------------------------------------------===// -// StmtOperand +// InstOperand //===----------------------------------------------------------------------===// /// Return which operand this is in the operand list. -template <> unsigned StmtOperand::getOperandNumber() const { - return this - &getOwner()->getStmtOperands()[0]; +template <> unsigned InstOperand::getOperandNumber() const { + return this - &getOwner()->getInstOperands()[0]; } /// Return which operand this is in the operand list. @@ -86,10 +86,10 @@ MLFunction *Statement::getFunction() const { return block ? block->getFunction() : nullptr; } -Value *Statement::getOperand(unsigned idx) { return getStmtOperand(idx).get(); } +Value *Statement::getOperand(unsigned idx) { return getInstOperand(idx).get(); } const Value *Statement::getOperand(unsigned idx) const { - return getStmtOperand(idx).get(); + return getInstOperand(idx).get(); } // Value can be used as a dimension id if it is valid as a symbol, or @@ -129,7 +129,7 @@ bool Value::isValidSymbol() const { } void Statement::setOperand(unsigned idx, Value *value) { - getStmtOperand(idx).set(value); + getInstOperand(idx).set(value); } unsigned Statement::getNumOperands() const { @@ -143,14 +143,14 @@ unsigned Statement::getNumOperands() const { } } -MutableArrayRef Statement::getStmtOperands() { +MutableArrayRef Statement::getInstOperands() { switch (getKind()) { case Kind::OperationInst: - return cast(this)->getStmtOperands(); + return cast(this)->getInstOperands(); case Kind::For: - return cast(this)->getStmtOperands(); + return cast(this)->getInstOperands(); case Kind::If: - return cast(this)->getStmtOperands(); + return cast(this)->getInstOperands(); } } @@ -256,7 +256,7 @@ void Statement::moveBefore(StmtBlock *block, /// step in breaking cyclic dependences between references when they are to /// be deleted. void Statement::dropAllReferences() { - for (auto &op : getStmtOperands()) + for (auto &op : getInstOperands()) op.drop(); if (isTerminator()) @@ -282,7 +282,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, unsigned numOperands = operands.size() - numSuccessors; auto byteSize = - totalSizeToAlloc( + totalSizeToAlloc( resultTypes.size(), numSuccessors, numSuccessors, numOperands); void *rawMem = malloc(byteSize); @@ -292,11 +292,11 @@ OperationInst *OperationInst::create(Location location, OperationName name, numSuccessors, attributes, context); // Initialize the results and operands. - auto stmtResults = stmt->getStmtResults(); + auto instResults = stmt->getInstResults(); for (unsigned i = 0, e = resultTypes.size(); i != e; ++i) - new (&stmtResults[i]) StmtResult(resultTypes[i], stmt); + new (&instResults[i]) InstResult(resultTypes[i], stmt); - auto stmtOperands = stmt->getStmtOperands(); + auto InstOperands = stmt->getInstOperands(); // Initialize normal operands. unsigned operandIt = 0, operandE = operands.size(); @@ -307,7 +307,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, // separately below. if (!operands[operandIt]) break; - new (&stmtOperands[nextOperand++]) StmtOperand(stmt, operands[operandIt]); + new (&InstOperands[nextOperand++]) InstOperand(stmt, operands[operandIt]); } unsigned currentSuccNum = 0; @@ -345,7 +345,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, ++currentSuccNum; continue; } - new (&stmtOperands[nextOperand++]) StmtOperand(stmt, operands[operandIt]); + new (&InstOperands[nextOperand++]) InstOperand(stmt, operands[operandIt]); ++(*succOperandCountIt); } @@ -373,11 +373,11 @@ OperationInst::OperationInst(Location location, OperationName name, OperationInst::~OperationInst() { // Explicitly run the destructors for the operands and results. - for (auto &operand : getStmtOperands()) - operand.~StmtOperand(); + for (auto &operand : getInstOperands()) + operand.~InstOperand(); - for (auto &result : getStmtResults()) - result.~StmtResult(); + for (auto &result : getInstResults()) + result.~InstResult(); // Explicitly run the destructors for the successors. if (isTerminator()) @@ -427,12 +427,12 @@ void OperationInst::setSuccessor(BasicBlock *block, unsigned index) { void OperationInst::eraseOperand(unsigned index) { assert(index < getNumOperands()); - auto Operands = getStmtOperands(); + auto Operands = getInstOperands(); // Shift all operands down by 1. std::rotate(&Operands[index], &Operands[index + 1], &Operands[numOperands - 1]); --numOperands; - Operands[getNumOperands()].~StmtOperand(); + Operands[getNumOperands()].~InstOperand(); } auto OperationInst::getSuccessorOperands(unsigned index) const @@ -543,10 +543,10 @@ ForStmt *ForStmt::create(Location location, ArrayRef lbOperands, unsigned i = 0; for (unsigned e = lbOperands.size(); i != e; ++i) - stmt->operands.emplace_back(StmtOperand(stmt, lbOperands[i])); + stmt->operands.emplace_back(InstOperand(stmt, lbOperands[i])); for (unsigned j = 0, e = ubOperands.size(); j != e; ++i, ++j) - stmt->operands.emplace_back(StmtOperand(stmt, ubOperands[j])); + stmt->operands.emplace_back(InstOperand(stmt, ubOperands[j])); return stmt; } @@ -580,10 +580,10 @@ void ForStmt::setLowerBound(ArrayRef lbOperands, AffineMap map) { operands.clear(); operands.reserve(lbOperands.size() + ubMap.getNumInputs()); for (auto *operand : lbOperands) { - operands.emplace_back(StmtOperand(this, operand)); + operands.emplace_back(InstOperand(this, operand)); } for (auto *operand : ubOperands) { - operands.emplace_back(StmtOperand(this, operand)); + operands.emplace_back(InstOperand(this, operand)); } this->lbMap = map; } @@ -597,10 +597,10 @@ void ForStmt::setUpperBound(ArrayRef ubOperands, AffineMap map) { operands.clear(); operands.reserve(lbOperands.size() + ubOperands.size()); for (auto *operand : lbOperands) { - operands.emplace_back(StmtOperand(this, operand)); + operands.emplace_back(InstOperand(this, operand)); } for (auto *operand : ubOperands) { - operands.emplace_back(StmtOperand(this, operand)); + operands.emplace_back(InstOperand(this, operand)); } this->ubMap = map; } @@ -699,7 +699,7 @@ IfStmt *IfStmt::create(Location location, ArrayRef operands, IfStmt *stmt = new IfStmt(location, numOperands, set); for (auto *op : operands) - stmt->operands.emplace_back(StmtOperand(stmt, op)); + stmt->operands.emplace_back(InstOperand(stmt, op)); return stmt; } @@ -749,11 +749,11 @@ Statement *Statement::clone(DenseMap &operandMap, unsigned firstSuccOperand = opStmt->getNumSuccessors() ? opStmt->getSuccessorOperandIndex(0) : opStmt->getNumOperands(); - auto stmtOperands = opStmt->getStmtOperands(); + auto InstOperands = opStmt->getInstOperands(); unsigned i = 0; for (; i != firstSuccOperand; ++i) - operands.push_back(remapOperand(stmtOperands[i].get())); + operands.push_back(remapOperand(InstOperands[i].get())); successors.reserve(opStmt->getNumSuccessors()); for (unsigned succ = 0, e = opStmt->getNumSuccessors(); succ != e; diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp index 41a6d80e2a23..830da558d9e8 100644 --- a/mlir/lib/IR/Value.cpp +++ b/mlir/lib/IR/Value.cpp @@ -33,7 +33,7 @@ Function *Value::getFunction() { switch (getKind()) { case Value::Kind::BlockArgument: return cast(this)->getFunction(); - case Value::Kind::StmtResult: + case Value::Kind::InstResult: return getDefiningInst()->getFunction(); case Value::Kind::ForStmt: return cast(this)->getFunction(); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp index 35891f5784bb..c5cbb0716dea 100644 --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -2621,7 +2621,7 @@ private: } ParseResult - parseOptionalBasicBlockArgList(SmallVectorImpl &results, + parseOptionalBasicBlockArgList(SmallVectorImpl &results, BasicBlock *owner); ParseResult parseBasicBlock(); @@ -2657,14 +2657,14 @@ bool CFGFunctionParser::parseSuccessorAndUseList( /// ssa-id-and-type-list ::= ssa-id-and-type (`,` ssa-id-and-type)* /// ParseResult CFGFunctionParser::parseOptionalBasicBlockArgList( - SmallVectorImpl &results, BasicBlock *owner) { + SmallVectorImpl &results, BasicBlock *owner) { if (getToken().is(Token::r_brace)) return ParseSuccess; return parseCommaSeparatedList([&]() -> ParseResult { auto type = parseSSADefOrUseAndType( [&](SSAUseInfo useInfo, Type type) -> Type { - BBArgument *arg = owner->addArgument(type); + BlockArgument *arg = owner->addArgument(type); if (addDefinition(useInfo, arg)) return {}; return type; @@ -2735,7 +2735,7 @@ ParseResult CFGFunctionParser::parseBasicBlock() { // If an argument list is present, parse it. if (consumeIf(Token::l_paren)) { - SmallVector bbArgs; + SmallVector bbArgs; if (parseOptionalBasicBlockArgList(bbArgs, block) || parseToken(Token::r_paren, "expected ')' to end argument list")) return ParseFailure; diff --git a/mlir/lib/StandardOps/StandardOps.cpp b/mlir/lib/StandardOps/StandardOps.cpp index 19a4c8d1afe7..8b57dadf3c6e 100644 --- a/mlir/lib/StandardOps/StandardOps.cpp +++ b/mlir/lib/StandardOps/StandardOps.cpp @@ -210,7 +210,7 @@ bool AllocOp::verify() const { // Check that the total number of operands matches the number of symbols in // the affine map, plus the number of dynamic dimensions specified in the // memref type. - if (getOperation()->getNumOperands() != numDynamicDims + numSymbols) { + if (getInstruction()->getNumOperands() != numDynamicDims + numSymbols) { return emitOpError( "operand count does not equal dimension plus symbol operand count"); } @@ -550,7 +550,7 @@ void CmpIOp::print(OpAsmPrinter *p) const { assert(predicateValue >= static_cast(CmpIPredicate::FirstValidValue) && predicateValue < static_cast(CmpIPredicate::NumPredicates) && "unknown predicate index"); - Builder b(getOperation()->getContext()); + Builder b(getInstruction()->getContext()); auto predicateStringAttr = b.getStringAttr(getPredicateNames()[predicateValue]); p->printAttribute(predicateStringAttr); @@ -1153,7 +1153,7 @@ bool SelectOp::parse(OpAsmParser *parser, OperationState *result) { void SelectOp::print(OpAsmPrinter *p) const { *p << getOperationName() << ' '; - p->printOperands(getOperation()->getOperands()); + p->printOperands(getInstruction()->getOperands()); *p << " : " << getTrueValue()->getType(); p->printOptionalAttrDict(getAttrs()); } diff --git a/mlir/lib/SuperVectorOps/SuperVectorOps.cpp b/mlir/lib/SuperVectorOps/SuperVectorOps.cpp index e4243a6de259..ab72ac3d7a3a 100644 --- a/mlir/lib/SuperVectorOps/SuperVectorOps.cpp +++ b/mlir/lib/SuperVectorOps/SuperVectorOps.cpp @@ -88,14 +88,14 @@ void VectorTransferReadOp::build(Builder *builder, OperationState *result, llvm::iterator_range VectorTransferReadOp::getIndices() { - auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset; + auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset; auto end = begin + getMemRefType().getRank(); return {begin, end}; } llvm::iterator_range VectorTransferReadOp::getIndices() const { - auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset; + auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset; auto end = begin + getMemRefType().getRank(); return {begin, end}; } @@ -305,14 +305,14 @@ void VectorTransferWriteOp::build(Builder *builder, OperationState *result, llvm::iterator_range VectorTransferWriteOp::getIndices() { - auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset; + auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset; auto end = begin + getMemRefType().getRank(); return {begin, end}; } llvm::iterator_range VectorTransferWriteOp::getIndices() const { - auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset; + auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset; auto end = begin + getMemRefType().getRank(); return {begin, end}; } diff --git a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp index 713aa0b1791c..7c22f274e3a9 100644 --- a/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToLLVMIR.cpp @@ -352,7 +352,7 @@ llvm::Value *ModuleLowerer::emitMemRefElementAccess( llvm::Value *ModuleLowerer::emitMemRefAlloc(ConstOpPointer allocOp) { MemRefType type = allocOp->getType(); - if (checkSupportedMemRefType(type, *allocOp->getOperation())) + if (checkSupportedMemRefType(type, *allocOp->getInstruction())) return nullptr; // Get actual sizes of the memref as values: static sizes are constant @@ -450,8 +450,8 @@ llvm::Value *ModuleLowerer::emitConstantSplat(const ConstantOp &op) { return op.emitError("NYI: only float splats are currently supported"), nullptr; - llvm::Constant *cst = - getFloatConstant(floatAttr.getValue(), *op.getOperation(), &llvmContext); + llvm::Constant *cst = getFloatConstant(floatAttr.getValue(), + *op.getInstruction(), &llvmContext); if (!cst) return nullptr; @@ -623,7 +623,7 @@ bool ModuleLowerer::convertInstruction(const OperationInst &inst) { if (auto loadOp = inst.dyn_cast()) { llvm::Value *element = emitMemRefElementAccess( - loadOp->getMemRef(), *loadOp->getOperation(), loadOp->getIndices()); + loadOp->getMemRef(), *loadOp->getInstruction(), loadOp->getIndices()); if (!element) return true; @@ -631,8 +631,9 @@ bool ModuleLowerer::convertInstruction(const OperationInst &inst) { return false; } if (auto storeOp = inst.dyn_cast()) { - llvm::Value *element = emitMemRefElementAccess( - storeOp->getMemRef(), *storeOp->getOperation(), storeOp->getIndices()); + llvm::Value *element = emitMemRefElementAccess(storeOp->getMemRef(), + *storeOp->getInstruction(), + storeOp->getIndices()); if (!element) return true; diff --git a/mlir/lib/Transforms/ComposeAffineMaps.cpp b/mlir/lib/Transforms/ComposeAffineMaps.cpp index 365533561f9d..a1ecf38dabd7 100644 --- a/mlir/lib/Transforms/ComposeAffineMaps.cpp +++ b/mlir/lib/Transforms/ComposeAffineMaps.cpp @@ -76,7 +76,7 @@ void ComposeAffineMaps::visitOperationInst(OperationInst *opStmt) { if (auto affineApplyOp = opStmt->dyn_cast()) { forwardSubstitute(affineApplyOp); bool allUsesEmpty = true; - for (auto *result : affineApplyOp->getOperation()->getResults()) { + for (auto *result : affineApplyOp->getInstruction()->getResults()) { if (!result->use_empty()) { allUsesEmpty = false; break; diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp index e2fd8b66e34a..6907c3228563 100644 --- a/mlir/lib/Transforms/LowerVectorTransfers.cpp +++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp @@ -185,7 +185,7 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer, // case of GPUs. llvm::SmallVector newResults = {}; if (std::is_same::value) { - b.setInsertionPoint(cast(transfer->getOperation())); + b.setInsertionPoint(cast(transfer->getInstruction())); auto *vector = b.create(transfer->getLoc(), vecView->getResult(), ArrayRef{state->zero}) ->getResult(); @@ -193,11 +193,11 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer, } // 6. Free the local buffer. - b.setInsertionPoint(cast(transfer->getOperation())); + b.setInsertionPoint(transfer->getInstruction()); b.create(transfer->getLoc(), tmpScalarAlloc); // 7. It is now safe to erase the statement. - rewriter->replaceOp(transfer->getOperation(), newResults); + rewriter->replaceOp(transfer->getInstruction(), newResults); } namespace { diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp index 6f033710798c..93fec70b8a75 100644 --- a/mlir/lib/Transforms/MaterializeVectors.cpp +++ b/mlir/lib/Transforms/MaterializeVectors.cpp @@ -263,7 +263,7 @@ static Value *substitute(Value *v, VectorType hwVectorType, DenseMap *substitutionsMap) { auto it = substitutionsMap->find(v); if (it == substitutionsMap->end()) { - auto *opStmt = cast(v->getDefiningInst()); + auto *opStmt = v->getDefiningInst(); if (opStmt->isa()) { FuncBuilder b(opStmt); auto *inst = instantiate(&b, opStmt, hwVectorType, substitutionsMap); @@ -451,7 +451,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy *transfer, "Shape and ratio not of the same size"); unsigned dim = 0; SmallVector keep; - MLIRContext *context = transfer->getOperation()->getContext(); + MLIRContext *context = transfer->getInstruction()->getContext(); functional::zipApply( [&dim, &keep, context](int shape, int ratio) { assert(shape >= ratio && "shape dim must be greater than ratio dim"); @@ -486,7 +486,7 @@ instantiate(FuncBuilder *b, VectorTransferReadOp *read, VectorType hwVectorType, auto cloned = b->create( read->getLoc(), hwVectorType, read->getMemRef(), affineIndices, projectedPermutationMap(read, hwVectorType), read->getPaddingValue()); - return cast(cloned->getOperation()); + return cloned->getInstruction(); } /// Creates an instantiated version of `write` for the instance of @@ -508,7 +508,7 @@ instantiate(FuncBuilder *b, VectorTransferWriteOp *write, substitute(write->getVector(), hwVectorType, substitutionsMap), write->getMemRef(), affineIndices, projectedPermutationMap(write, hwVectorType)); - return cast(cloned->getOperation()); + return cloned->getInstruction(); } /// Returns `true` if stmt instance is properly cloned and inserted, false diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp index 0096cd7be2d0..9798225f90bb 100644 --- a/mlir/lib/Transforms/PipelineDataTransfer.cpp +++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp @@ -130,7 +130,7 @@ static bool doubleBuffer(Value *oldMemRef, ForStmt *forStmt) { &*forStmt->getBody()->begin())) { LLVM_DEBUG(llvm::dbgs() << "memref replacement for double buffering failed\n";); - ivModTwoOp->getOperation()->erase(); + ivModTwoOp->getInstruction()->erase(); return false; } return true; diff --git a/mlir/lib/Transforms/Utils/LoweringUtils.cpp b/mlir/lib/Transforms/Utils/LoweringUtils.cpp index 6fca54a99720..599bcfbc4ff2 100644 --- a/mlir/lib/Transforms/Utils/LoweringUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoweringUtils.cpp @@ -124,7 +124,7 @@ bool mlir::expandAffineApply(AffineApplyOp *op) { if (!op) return true; - FuncBuilder builder(cast(op->getOperation())); + FuncBuilder builder(op->getInstruction()); auto affineMap = op->getAffineMap(); for (auto numberedExpr : llvm::enumerate(affineMap.getResults())) { Value *expanded = expandAffineExpr(&builder, numberedExpr.value(), op); diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp index c8317c27f744..a0556c43c7fd 100644 --- a/mlir/lib/Transforms/Utils/Utils.cpp +++ b/mlir/lib/Transforms/Utils/Utils.cpp @@ -84,7 +84,7 @@ bool mlir::replaceAllMemRefUsesWith(const Value *oldMemRef, Value *newMemRef, // Walk all uses of old memref. Operation using the memref gets replaced. for (auto it = oldMemRef->use_begin(); it != oldMemRef->use_end();) { - StmtOperand &use = *(it++); + InstOperand &use = *(it++); auto *opStmt = cast(use.getOwner()); // Skip this use if it's not dominated by domStmtFilter. @@ -145,7 +145,7 @@ bool mlir::replaceAllMemRefUsesWith(const Value *oldMemRef, Value *newMemRef, auto remapOp = builder.create(opStmt->getLoc(), indexRemap, remapOperands); // Remapped indices. - for (auto *index : remapOp->getOperation()->getResults()) + for (auto *index : remapOp->getInstruction()->getResults()) state.operands.push_back(index); } else { // No remapping specified. @@ -216,7 +216,7 @@ mlir::createComposedAffineApplyOp(FuncBuilder *builder, Location loc, for (unsigned i = 0, e = operands.size(); i < e; ++i) { (*results)[i] = affineApplyOp->getResult(i); } - return cast(affineApplyOp->getOperation()); + return affineApplyOp->getInstruction(); } /// Given an operation statement, inserts a new single affine apply operation, @@ -313,18 +313,18 @@ OperationInst *mlir::createAffineComputationSlice(OperationInst *opStmt) { } void mlir::forwardSubstitute(OpPointer affineApplyOp) { - if (!affineApplyOp->getOperation()->getFunction()->isML()) { + if (!affineApplyOp->getInstruction()->getFunction()->isML()) { // TODO: Support forward substitution for CFG style functions. return; } - auto *opStmt = cast(affineApplyOp->getOperation()); + auto *opStmt = affineApplyOp->getInstruction(); // Iterate through all uses of all results of 'opStmt', forward substituting // into any uses which are AffineApplyOps. for (unsigned resultIndex = 0, e = opStmt->getNumResults(); resultIndex < e; ++resultIndex) { const Value *result = opStmt->getResult(resultIndex); for (auto it = result->use_begin(); it != result->use_end();) { - StmtOperand &use = *(it++); + InstOperand &use = *(it++); auto *useStmt = use.getOwner(); auto *useOpStmt = dyn_cast(useStmt); // Skip if use is not AffineApplyOp. @@ -356,7 +356,7 @@ void mlir::forwardSubstitute(OpPointer affineApplyOp) { newAffineApplyOp->getResult(i)); } // Erase 'oldAffineApplyOp'. - oldAffineApplyOp->getOperation()->erase(); + oldAffineApplyOp->getInstruction()->erase(); } } } diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp index 0efe727f5b4e..762a09ea0480 100644 --- a/mlir/lib/Transforms/Vectorize.cpp +++ b/mlir/lib/Transforms/Vectorize.cpp @@ -832,7 +832,7 @@ static bool vectorizeRootOrTerminal(Value *iv, LoadOrStoreOpPointer memoryOp, auto vectorType = VectorType::get(state->strategy->vectorSizes, elementType); // Materialize a MemRef with 1 vector. - auto *opStmt = cast(memoryOp->getOperation()); + auto *opStmt = memoryOp->getInstruction(); // For now, vector_transfers must be aligned, operate only on indices with an // identity subset of AffineMap and do not change layout. // TODO(ntv): increase the expressiveness power of vector_transfer operations @@ -846,8 +846,7 @@ static bool vectorizeRootOrTerminal(Value *iv, LoadOrStoreOpPointer memoryOp, auto transfer = b.create( opStmt->getLoc(), vectorType, memoryOp->getMemRef(), map(makePtrDynCaster(), memoryOp->getIndices()), permutationMap); - state->registerReplacement(opStmt, - cast(transfer->getOperation())); + state->registerReplacement(opStmt, transfer->getInstruction()); } else { state->registerTerminator(opStmt); } @@ -974,7 +973,7 @@ static Value *vectorizeConstant(Statement *stmt, const ConstantOp &constant, Location loc = stmt->getLoc(); auto vectorType = type.cast(); auto attr = SplatElementsAttr::get(vectorType, constant.getValue()); - auto *constantOpStmt = cast(constant.getOperation()); + auto *constantOpStmt = cast(constant.getInstruction()); OperationState state( b.getContext(), loc, constantOpStmt->getName().getStringRef(), {}, @@ -1091,7 +1090,7 @@ static OperationInst *vectorizeOneOperationInst(FuncBuilder *b, LLVM_DEBUG(permutationMap.print(dbgs())); auto transfer = b.create( opStmt->getLoc(), vectorValue, memRef, indices, permutationMap); - auto *res = cast(transfer->getOperation()); + auto *res = cast(transfer->getInstruction()); LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ vectorized store: " << *res); // "Terminators" (i.e. StoreOps) are erased on the spot. opStmt->erase(); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index 68174cb99d4f..a07ef384c3d4 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -289,10 +289,10 @@ void OpEmitter::emitAttrGetters() { void OpEmitter::emitNamedOperands() { const auto operandMethods = R"( Value *{0}() { - return this->getOperation()->getOperand({1}); + return this->getInstruction()->getOperand({1}); } const Value *{0}() const { - return this->getOperation()->getOperand({1}); + return this->getInstruction()->getOperand({1}); } )"; for (int i = 0, e = operands.size(); i != e; ++i) {