summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-03-26 17:05:09 -0700
committerjpienaar <jpienaar@google.com>2019-03-29 17:43:37 -0700
commitf9d91531df58a561a2c6e197dfb7cb796f7e44e3 (patch)
treed05d629f447360470856187ac47197695e915af3
parentd5259edefdc3d02eaf35970689f2c9cb17a0f855 (diff)
downloadbcm5719-llvm-f9d91531df58a561a2c6e197dfb7cb796f7e44e3.tar.gz
bcm5719-llvm-f9d91531df58a561a2c6e197dfb7cb796f7e44e3.zip
Replace usages of Instruction with Operation in the /IR directory.
This is step 2/N to renaming Instruction to Operation. PiperOrigin-RevId: 240459216
-rw-r--r--mlir/include/mlir/AffineOps/AffineOps.h4
-rw-r--r--mlir/include/mlir/Analysis/Dominance.h2
-rw-r--r--mlir/include/mlir/EDSC/Builders.h6
-rw-r--r--mlir/include/mlir/IR/Block.h134
-rw-r--r--mlir/include/mlir/IR/Builders.h40
-rw-r--r--mlir/include/mlir/IR/Dialect.h8
-rw-r--r--mlir/include/mlir/IR/Function.h18
-rw-r--r--mlir/include/mlir/IR/IntegerSet.h4
-rw-r--r--mlir/include/mlir/IR/MLIRContext.h4
-rw-r--r--mlir/include/mlir/IR/Matchers.h10
-rw-r--r--mlir/include/mlir/IR/OpDefinition.h214
-rw-r--r--mlir/include/mlir/IR/OpImplementation.h4
-rw-r--r--mlir/include/mlir/IR/Operation.h16
-rw-r--r--mlir/include/mlir/IR/PatternMatch.h41
-rw-r--r--mlir/include/mlir/IR/UseDefLists.h26
-rw-r--r--mlir/include/mlir/IR/Value.h23
-rw-r--r--mlir/include/mlir/StandardOps/Ops.h25
-rw-r--r--mlir/include/mlir/StandardOps/Ops.td2
-rw-r--r--mlir/lib/AffineOps/AffineOps.cpp36
-rw-r--r--mlir/lib/Analysis/AffineAnalysis.cpp10
-rw-r--r--mlir/lib/Analysis/AffineStructures.cpp2
-rw-r--r--mlir/lib/Analysis/Dominance.cpp4
-rw-r--r--mlir/lib/Analysis/LoopAnalysis.cpp10
-rw-r--r--mlir/lib/Analysis/SliceAnalysis.cpp2
-rw-r--r--mlir/lib/Analysis/Utils.cpp22
-rw-r--r--mlir/lib/Analysis/Verifier.cpp6
-rw-r--r--mlir/lib/EDSC/Builders.cpp8
-rw-r--r--mlir/lib/EDSC/MLIREmitter.cpp13
-rw-r--r--mlir/lib/IR/AsmPrinter.cpp40
-rw-r--r--mlir/lib/IR/Block.cpp119
-rw-r--r--mlir/lib/IR/Builders.cpp12
-rw-r--r--mlir/lib/IR/Function.cpp9
-rw-r--r--mlir/lib/IR/MLIRContext.cpp2
-rw-r--r--mlir/lib/IR/Operation.cpp39
-rw-r--r--mlir/lib/IR/PatternMatch.cpp18
-rw-r--r--mlir/lib/IR/Value.cpp12
-rw-r--r--mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp4
-rw-r--r--mlir/lib/Parser/Parser.cpp4
-rw-r--r--mlir/lib/StandardOps/Ops.cpp36
-rw-r--r--mlir/lib/SuperVectorOps/SuperVectorOps.cpp4
-rw-r--r--mlir/lib/Transforms/ConstantFold.cpp4
-rw-r--r--mlir/lib/Transforms/DmaGeneration.cpp12
-rw-r--r--mlir/lib/Transforms/LoopFusion.cpp58
-rw-r--r--mlir/lib/Transforms/LoopTiling.cpp27
-rw-r--r--mlir/lib/Transforms/LoopUnrollAndJam.cpp2
-rw-r--r--mlir/lib/Transforms/LowerAffine.cpp24
-rw-r--r--mlir/lib/Transforms/LowerVectorTransfers.cpp6
-rw-r--r--mlir/lib/Transforms/MaterializeVectors.cpp8
-rw-r--r--mlir/lib/Transforms/MemRefDataFlowOpt.cpp6
-rw-r--r--mlir/lib/Transforms/PipelineDataTransfer.cpp12
-rw-r--r--mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp2
-rw-r--r--mlir/lib/Transforms/Utils/LoopUtils.cpp38
-rw-r--r--mlir/lib/Transforms/Utils/Utils.cpp4
-rw-r--r--mlir/lib/Transforms/Vectorize.cpp16
-rw-r--r--mlir/test/EDSC/builder-api-test.cpp4
-rw-r--r--mlir/test/mlir-tblgen/op-operand.td2
-rw-r--r--mlir/test/mlir-tblgen/op-result.td2
-rw-r--r--mlir/test/mlir-tblgen/predicate.td8
-rw-r--r--mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp10
-rw-r--r--mlir/tools/mlir-tblgen/RewriterGen.cpp6
60 files changed, 606 insertions, 638 deletions
diff --git a/mlir/include/mlir/AffineOps/AffineOps.h b/mlir/include/mlir/AffineOps/AffineOps.h
index 4f949231674..65467677bd6 100644
--- a/mlir/include/mlir/AffineOps/AffineOps.h
+++ b/mlir/include/mlir/AffineOps/AffineOps.h
@@ -144,7 +144,7 @@ public:
Block *getBody() { return &getRegion().front(); }
/// Get the body region of the AffineForOp.
- Region &getRegion() { return getInstruction()->getRegion(0); }
+ Region &getRegion() { return getOperation()->getRegion(0); }
/// Returns the induction variable for this loop.
Value *getInductionVar();
@@ -253,7 +253,7 @@ public:
unsigned getNumOperands() { return opEnd - opStart; }
Value *getOperand(unsigned idx) {
- return inst.getInstruction()->getOperand(opStart + idx);
+ return inst.getOperation()->getOperand(opStart + idx);
}
using operand_iterator = AffineForOp::operand_iterator;
diff --git a/mlir/include/mlir/Analysis/Dominance.h b/mlir/include/mlir/Analysis/Dominance.h
index 4aa8c0463d4..1c3ca02e41c 100644
--- a/mlir/include/mlir/Analysis/Dominance.h
+++ b/mlir/include/mlir/Analysis/Dominance.h
@@ -78,7 +78,7 @@ public:
/// Return true if instruction A dominates instruction B.
bool dominates(Value *a, Instruction *b) {
- return (Instruction *)a->getDefiningInst() == b || properlyDominates(a, b);
+ return (Instruction *)a->getDefiningOp() == b || properlyDominates(a, b);
}
/// Return true if the specified block A dominates block B.
diff --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h
index b7b3b1f1844..4b0e5b938b5 100644
--- a/mlir/include/mlir/EDSC/Builders.h
+++ b/mlir/include/mlir/EDSC/Builders.h
@@ -359,7 +359,7 @@ struct InstructionHandle : public CapturableHandle {
ArrayRef<NamedAttribute> attributes = {});
operator Instruction *() { return inst; }
- Instruction *getInstruction() { return inst; }
+ Instruction *getOperation() { return inst; }
private:
Instruction *inst;
@@ -421,14 +421,14 @@ InstructionHandle InstructionHandle::create(Args... args) {
return InstructionHandle(
ScopedContext::getBuilder()
->create<Op>(ScopedContext::getLocation(), args...)
- .getInstruction());
+ .getOperation());
}
template <typename Op, typename... Args>
ValueHandle ValueHandle::create(Args... args) {
Instruction *inst = ScopedContext::getBuilder()
->create<Op>(ScopedContext::getLocation(), args...)
- .getInstruction();
+ .getOperation();
if (inst->getNumResults() == 1) {
return ValueHandle(inst->getResult(0));
} else if (inst->getNumResults() == 0) {
diff --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 57a61606719..fd318525e2b 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -28,20 +28,20 @@
#include "llvm/ADT/ilist_node.h"
//===----------------------------------------------------------------------===//
-// ilist_traits for Instruction
+// ilist_traits for Operation
//===----------------------------------------------------------------------===//
namespace llvm {
namespace ilist_detail {
-// Explicitly define the node access for the instruction list so that we can
-// break the dependence on the Instruction class in this header. This allows for
-// instructions to have trailing Regions without a circular include
+// Explicitly define the node access for the operation list so that we can
+// break the dependence on the Operation class in this header. This allows for
+// operations to have trailing Regions without a circular include
// dependence.
template <>
struct SpecificNodeAccess<
- typename compute_node_options<::mlir::Instruction>::type> : NodeAccess {
+ typename compute_node_options<::mlir::Operation>::type> : NodeAccess {
protected:
- using OptionsT = typename compute_node_options<mlir::Instruction>::type;
+ using OptionsT = typename compute_node_options<mlir::Operation>::type;
using pointer = typename OptionsT::pointer;
using const_pointer = typename OptionsT::const_pointer;
using node_type = ilist_node_impl<OptionsT>;
@@ -54,15 +54,15 @@ protected:
};
} // end namespace ilist_detail
-template <> struct ilist_traits<::mlir::Instruction> {
- using Instruction = ::mlir::Instruction;
- using inst_iterator = simple_ilist<Instruction>::iterator;
+template <> struct ilist_traits<::mlir::Operation> {
+ using Operation = ::mlir::Operation;
+ using op_iterator = simple_ilist<Operation>::iterator;
- static void deleteNode(Instruction *inst);
- void addNodeToList(Instruction *inst);
- void removeNodeFromList(Instruction *inst);
- void transferNodesFromList(ilist_traits<Instruction> &otherList,
- inst_iterator first, inst_iterator last);
+ static void deleteNode(Operation *op);
+ void addNodeToList(Operation *op);
+ void removeNodeFromList(Operation *op);
+ void transferNodesFromList(ilist_traits<Operation> &otherList,
+ op_iterator first, op_iterator last);
private:
mlir::Block *getContainingBlock();
@@ -79,7 +79,7 @@ using BlockOperand = IROperandImpl<Block>;
class PredecessorIterator;
class SuccessorIterator;
-/// `Block` represents an ordered list of `Instruction`s.
+/// `Block` represents an ordered list of `Operation`s.
class Block : public IRObjectWithUseList,
public llvm::ilist_node_with_parent<Block, Region> {
public:
@@ -90,18 +90,18 @@ public:
// Drop all references from within this block.
dropAllReferences();
- // Clear instructions in the reverse order so that uses are destroyed
+ // Clear operations in the reverse order so that uses are destroyed
// before their defs.
while (!empty())
- instructions.pop_back();
+ operations.pop_back();
}
/// Blocks are maintained in a Region.
Region *getParent() { return parentValidInstOrderPair.getPointer(); }
- /// Returns the closest surrounding instruction that contains this block or
+ /// Returns the closest surrounding operation that contains this block or
/// nullptr if this is a top-level block.
- Instruction *getContainingInst();
+ Operation *getContainingOp();
/// Returns the function that this block is part of, even if the block is
/// nested under an operation region.
@@ -145,37 +145,37 @@ public:
BlockArgument *getArgument(unsigned i) { return arguments[i]; }
//===--------------------------------------------------------------------===//
- // Instruction list management
+ // Operation list management
//===--------------------------------------------------------------------===//
- /// This is the list of instructions in the block.
- using InstListType = llvm::iplist<Instruction>;
- InstListType &getInstructions() { return instructions; }
+ /// This is the list of operations in the block.
+ using InstListType = llvm::iplist<Operation>;
+ InstListType &getOperations() { return operations; }
- // Iteration over the instructions in the block.
+ // Iteration over the operations in the block.
using iterator = InstListType::iterator;
using reverse_iterator = InstListType::reverse_iterator;
- iterator begin() { return instructions.begin(); }
- iterator end() { return instructions.end(); }
- reverse_iterator rbegin() { return instructions.rbegin(); }
- reverse_iterator rend() { return instructions.rend(); }
+ iterator begin() { return operations.begin(); }
+ iterator end() { return operations.end(); }
+ reverse_iterator rbegin() { return operations.rbegin(); }
+ reverse_iterator rend() { return operations.rend(); }
- bool empty() { return instructions.empty(); }
- void push_back(Instruction *inst) { instructions.push_back(inst); }
- void push_front(Instruction *inst) { instructions.push_front(inst); }
+ bool empty() { return operations.empty(); }
+ void push_back(Operation *op) { operations.push_back(op); }
+ void push_front(Operation *op) { operations.push_front(op); }
- Instruction &back() { return instructions.back(); }
- Instruction &front() { return instructions.front(); }
+ Operation &back() { return operations.back(); }
+ Operation &front() { return operations.front(); }
- /// Returns 'inst' if 'inst' lies in this block, or otherwise finds the
- /// ancestor instruction of 'inst' that lies in this block. Returns nullptr if
+ /// Returns 'op' if 'op' lies in this block, or otherwise finds the
+ /// ancestor operation of 'op' that lies in this block. Returns nullptr if
/// the latter fails.
/// TODO: This is very specific functionality that should live somewhere else,
/// probably in Dominance.cpp.
- Instruction *findAncestorInstInBlock(Instruction &inst);
+ Operation *findAncestorInstInBlock(Operation &op);
- /// This drops all operand uses from instructions within this block, which is
+ /// This drops all operand uses from operations within this block, which is
/// an essential step in breaking cyclic dependences between references when
/// they are to be deleted.
void dropAllReferences();
@@ -184,31 +184,31 @@ public:
/// nested regions wherever the uses are located.
void dropAllDefinedValueUses();
- /// Returns true if the ordering of the child instructions is valid, false
+ /// Returns true if the ordering of the child operations is valid, false
/// otherwise.
bool isInstOrderValid() { return parentValidInstOrderPair.getInt(); }
- /// Invalidates the current ordering of instructions.
+ /// Invalidates the current ordering of operations.
void invalidateInstOrder() {
// Validate the current ordering.
assert(!verifyInstOrder());
parentValidInstOrderPair.setInt(false);
}
- /// Verifies the current ordering of child instructions matches the
+ /// Verifies the current ordering of child operations matches the
/// validInstOrder flag. Returns false if the order is valid, true otherwise.
bool verifyInstOrder();
- /// Recomputes the ordering of child instructions within the block.
+ /// Recomputes the ordering of child operations within the block.
void recomputeInstOrder();
//===--------------------------------------------------------------------===//
// Terminator management
//===--------------------------------------------------------------------===//
- /// Get the terminator instruction of this block. This function asserts that
- /// the block has a valid terminator instruction.
- Instruction *getTerminator();
+ /// Get the terminator operation of this block. This function asserts that
+ /// the block has a valid terminator operation.
+ Operation *getTerminator();
//===--------------------------------------------------------------------===//
// Predecessors and successors.
@@ -242,49 +242,49 @@ public:
llvm::iterator_range<succ_iterator> getSuccessors();
//===--------------------------------------------------------------------===//
- // Instruction Walkers
+ // Operation Walkers
//===--------------------------------------------------------------------===//
- /// Walk the instructions of this block in preorder, calling the callback for
+ /// Walk the operations of this block in preorder, calling the callback for
/// each operation.
- void walk(const std::function<void(Instruction *)> &callback);
+ void walk(const std::function<void(Operation *)> &callback);
- /// Walk the instructions in the specified [begin, end) range of
+ /// Walk the operations in the specified [begin, end) range of
/// this block, calling the callback for each operation.
void walk(Block::iterator begin, Block::iterator end,
- const std::function<void(Instruction *)> &callback);
+ const std::function<void(Operation *)> &callback);
- /// Walk the instructions in this block in postorder, calling the callback for
+ /// Walk the operations in this block in postorder, calling the callback for
/// each operation.
- void walkPostOrder(const std::function<void(Instruction *)> &callback);
+ void walkPostOrder(const std::function<void(Operation *)> &callback);
- /// Walk the instructions in the specified [begin, end) range of this block
+ /// Walk the operations in the specified [begin, end) range of this block
/// in postorder, calling the callback for each operation.
void walkPostOrder(Block::iterator begin, Block::iterator end,
- const std::function<void(Instruction *)> &callback);
+ const std::function<void(Operation *)> &callback);
//===--------------------------------------------------------------------===//
// Other
//===--------------------------------------------------------------------===//
- /// Split the block into two blocks before the specified instruction or
+ /// Split the block into two blocks before the specified operation or
/// iterator.
///
- /// Note that all instructions BEFORE the specified iterator stay as part of
- /// the original basic block, and the rest of the instructions in the original
+ /// Note that all operations BEFORE the specified iterator stay as part of
+ /// the original basic block, and the rest of the operations in the original
/// block are moved to the new block, including the old terminator. The
/// original block is left without a terminator.
///
/// The newly formed Block is returned, and the specified iterator is
/// invalidated.
Block *splitBlock(iterator splitBefore);
- Block *splitBlock(Instruction *splitBeforeInst) {
+ Block *splitBlock(Operation *splitBeforeInst) {
return splitBlock(iterator(splitBeforeInst));
}
- /// Returns pointer to member of instruction list.
- static InstListType Block::*getSublistAccess(Instruction *) {
- return &Block::instructions;
+ /// Returns pointer to member of operation list.
+ static InstListType Block::*getSublistAccess(Operation *) {
+ return &Block::operations;
}
void print(raw_ostream &os);
@@ -297,11 +297,11 @@ public:
private:
/// Pair of the parent object that owns this block and a bit that signifies if
- /// the instructions within this block have a valid ordering.
+ /// the operations within this block have a valid ordering.
llvm::PointerIntPair<Region *, /*IntBits=*/1, bool> parentValidInstOrderPair;
- /// This is the list of instructions in the block.
- InstListType instructions;
+ /// This is the list of operations in the block.
+ InstListType operations;
/// This is the list of arguments to the block.
std::vector<BlockArgument *> arguments;
@@ -342,7 +342,7 @@ namespace mlir {
class Region {
public:
explicit Region(Function *container = nullptr);
- explicit Region(Instruction *container);
+ explicit Region(Operation *container);
~Region();
using RegionType = llvm::iplist<Block>;
@@ -371,7 +371,7 @@ public:
/// A Region is either a function body or a part of an operation. If it is
/// part of an operation, then return the operation, otherwise return null.
- Instruction *getContainingInst();
+ Operation *getContainingOp();
/// A Region is either a function body or a part of an operation. If it is
/// a Function body, then return this function, otherwise return null.
@@ -395,7 +395,7 @@ private:
RegionType blocks;
/// This is the object we are part of.
- llvm::PointerUnion<Function *, Instruction *> container;
+ llvm::PointerUnion<Function *, Operation *> container;
};
//===----------------------------------------------------------------------===//
@@ -404,7 +404,7 @@ private:
/// Implement a predecessor iterator as a forward iterator. This works by
/// walking the use lists of the blocks. The entries on this list are the
-/// BlockOperands that are embedded into terminator instructions. From the
+/// BlockOperands that are embedded into terminator operations. From the
/// operand, we can get the terminator that contains it, and it's parent block
/// is the predecessor.
class PredecessorIterator
diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 1cf18cc2f4c..65f986b1257 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -171,7 +171,7 @@ protected:
MLIRContext *context;
};
-/// This class helps build a Function. Instructions that are created are
+/// This class helps build a Function. Operations that are created are
/// automatically inserted at an insertion point. The builder is copyable.
class FuncBuilder : public Builder {
public:
@@ -188,9 +188,9 @@ public:
explicit FuncBuilder(Function &func) : FuncBuilder(&func) {}
/// Create a function builder and set insertion point to the given
- /// instruction, which will cause subsequent insertions to go right before it.
- FuncBuilder(Instruction *inst) : FuncBuilder(inst->getFunction()) {
- setInsertionPoint(inst);
+ /// operation, which will cause subsequent insertions to go right before it.
+ FuncBuilder(Operation *op) : FuncBuilder(op->getFunction()) {
+ setInsertionPoint(op);
}
FuncBuilder(Block *block) : FuncBuilder(block->getFunction()) {
@@ -222,8 +222,8 @@ public:
/// Sets the insertion point to the specified operation, which will cause
/// subsequent insertions to go right before it.
- void setInsertionPoint(Instruction *inst) {
- setInsertionPoint(inst->getBlock(), Block::iterator(inst));
+ void setInsertionPoint(Operation *op) {
+ setInsertionPoint(op->getBlock(), Block::iterator(op));
}
/// Sets the insertion point to the start of the specified block.
@@ -253,33 +253,33 @@ public:
Block *getBlock() const { return block; }
/// Creates an operation given the fields represented as an OperationState.
- Instruction *createOperation(const OperationState &state);
+ Operation *createOperation(const OperationState &state);
/// Create operation of specific op type at the current insertion point.
template <typename OpTy, typename... Args>
OpTy create(Location location, Args... args) {
OperationState state(getContext(), location, OpTy::getOperationName());
OpTy::build(this, &state, args...);
- auto *inst = createOperation(state);
- auto result = inst->dyn_cast<OpTy>();
+ auto *op = createOperation(state);
+ auto result = op->dyn_cast<OpTy>();
assert(result && "Builder didn't return the right type");
return result;
}
- /// Creates a deep copy of the specified instruction, remapping any operands
- /// that use values outside of the instruction using the map that is provided
+ /// Creates a deep copy of the specified operation, remapping any operands
+ /// that use values outside of the operation using the map that is provided
/// ( leaving them alone if no entry is present). Replaces references to
- /// cloned sub-instructions to the corresponding instruction that is copied,
+ /// cloned sub-operations to the corresponding operation that is copied,
/// and adds those mappings to the map.
- Instruction *clone(Instruction &inst, BlockAndValueMapping &mapper) {
- Instruction *cloneInst = inst.clone(mapper, getContext());
- block->getInstructions().insert(insertPoint, cloneInst);
- return cloneInst;
+ Operation *clone(Operation &op, BlockAndValueMapping &mapper) {
+ Operation *cloneOp = op.clone(mapper, getContext());
+ block->getOperations().insert(insertPoint, cloneOp);
+ return cloneOp;
}
- Instruction *clone(Instruction &inst) {
- Instruction *cloneInst = inst.clone(getContext());
- block->getInstructions().insert(insertPoint, cloneInst);
- return cloneInst;
+ Operation *clone(Operation &op) {
+ Operation *cloneOp = op.clone(getContext());
+ block->getOperations().insert(insertPoint, cloneOp);
+ return cloneOp;
}
private:
diff --git a/mlir/include/mlir/IR/Dialect.h b/mlir/include/mlir/IR/Dialect.h
index fe2c79a3e36..b129395d012 100644
--- a/mlir/include/mlir/IR/Dialect.h
+++ b/mlir/include/mlir/IR/Dialect.h
@@ -32,7 +32,7 @@ class Type;
using DialectConstantDecodeHook =
std::function<bool(const OpaqueElementsAttr, ElementsAttr &)>;
using DialectConstantFoldHook = std::function<LogicalResult(
- Instruction *, ArrayRef<Attribute>, SmallVectorImpl<Attribute> &)>;
+ Operation *, ArrayRef<Attribute>, SmallVectorImpl<Attribute> &)>;
using DialectExtractElementHook =
std::function<Attribute(const OpaqueElementsAttr, ArrayRef<uint64_t>)>;
@@ -57,7 +57,7 @@ public:
/// `results` vector. If not, this returns failure and `results` is
/// unspecified.
DialectConstantFoldHook constantFoldHook =
- [](Instruction *op, ArrayRef<Attribute> operands,
+ [](Operation *op, ArrayRef<Attribute> operands,
SmallVectorImpl<Attribute> &results) { return failure(); };
/// Registered hook to decode opaque constants associated with this
@@ -115,9 +115,9 @@ public:
return false;
}
- /// Verify an attribute from this dialect on the given instruction. Returns
+ /// Verify an attribute from this dialect on the given operation. Returns
/// true if the verification failed, false otherwise.
- virtual bool verifyInstructionAttribute(Instruction *, NamedAttribute) {
+ virtual bool verifyOperationAttribute(Operation *, NamedAttribute) {
return false;
}
diff --git a/mlir/include/mlir/IR/Function.h b/mlir/include/mlir/IR/Function.h
index 67f9762e7fb..41435add404 100644
--- a/mlir/include/mlir/IR/Function.h
+++ b/mlir/include/mlir/IR/Function.h
@@ -101,29 +101,29 @@ public:
Block &front() { return body.front(); }
//===--------------------------------------------------------------------===//
- // Instruction Walkers
+ // Operation Walkers
//===--------------------------------------------------------------------===//
- /// Walk the instructions in the function in preorder, calling the callback
- /// for each instruction.
- void walk(const std::function<void(Instruction *)> &callback);
+ /// Walk the operations in the function in preorder, calling the callback
+ /// for each operation.
+ void walk(const std::function<void(Operation *)> &callback);
/// Specialization of walk to only visit operations of 'OpTy'.
template <typename OpTy> void walk(std::function<void(OpTy)> callback) {
- walk([&](Instruction *inst) {
+ walk([&](Operation *inst) {
if (auto op = inst->dyn_cast<OpTy>())
callback(op);
});
}
- /// Walk the instructions in the function in postorder, calling the callback
- /// for each instruction.
- void walkPostOrder(const std::function<void(Instruction *)> &callback);
+ /// Walk the operations in the function in postorder, calling the callback
+ /// for each operation.
+ void walkPostOrder(const std::function<void(Operation *)> &callback);
/// Specialization of walkPostOrder to only visit operations of 'OpTy'.
template <typename OpTy>
void walkPostOrder(std::function<void(OpTy)> callback) {
- walkPostOrder([&](Instruction *inst) {
+ walkPostOrder([&](Operation *inst) {
if (auto op = inst->dyn_cast<OpTy>())
callback(op);
});
diff --git a/mlir/include/mlir/IR/IntegerSet.h b/mlir/include/mlir/IR/IntegerSet.h
index db417db69c9..b7662f095a5 100644
--- a/mlir/include/mlir/IR/IntegerSet.h
+++ b/mlir/include/mlir/IR/IntegerSet.h
@@ -17,8 +17,8 @@
//
// Integer sets are sets of points from the integer lattice constrained by
// affine equality/inequality constraints. This class is meant to represent
-// integer sets in the IR - for 'affine.if' instructions and as attributes of
-// other instructions. It is typically expected to contain only a handful of
+// integer sets in the IR - for 'affine.if' operations and as attributes of
+// other operations. It is typically expected to contain only a handful of
// affine constraints, and is immutable like an affine map. Integer sets are not
// unique'd - although affine expressions that make up its equalities and
// inequalites are themselves unique.
diff --git a/mlir/include/mlir/IR/MLIRContext.h b/mlir/include/mlir/IR/MLIRContext.h
index 304970166c6..85eb62d229f 100644
--- a/mlir/include/mlir/IR/MLIRContext.h
+++ b/mlir/include/mlir/IR/MLIRContext.h
@@ -61,7 +61,7 @@ public:
// Diagnostic handler registration and use. MLIR supports the ability for the
// IR to carry arbitrary metadata about operation location information. If an
// problem is detected by the compiler, it can invoke the emitError /
- // emitWarning / emitNote method on an Instruction and have it get reported
+ // emitWarning / emitNote method on an Operation and have it get reported
// through this interface.
//
// Tools using MLIR are encouraged to register error handlers and define a
@@ -81,7 +81,7 @@ public:
/// Emit a diagnostic using the registered issue handle if present, or with
/// the default behavior if not. The MLIR compiler should not generally
- /// interact with this, it should use methods on Instruction instead.
+ /// interact with this, it should use methods on Operation instead.
void emitDiagnostic(Location location, const Twine &message,
DiagnosticKind kind);
diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index 9e91e9a8842..2ac334bec94 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -69,7 +69,7 @@ struct constant_op_binder {
/// bind_value if match succeeds.
constant_op_binder(Attribute *bind_value) : bind_value(bind_value) {}
- bool match(Instruction *op) {
+ bool match(Operation *op) {
if (op->getNumOperands() > 0 || op->getNumResults() != 1)
return false;
SmallVector<Attribute, 1> foldedAttr;
@@ -89,7 +89,7 @@ struct constant_int_op_binder {
/// Creates a matcher instance that binds the value to bv if match succeeds.
constant_int_op_binder(IntegerAttr::ValueType *bv) : bind_value(bv) {}
- bool match(Instruction *op) {
+ bool match(Operation *op) {
Attribute attr;
if (!constant_op_binder(&attr).match(op))
return false;
@@ -111,7 +111,7 @@ struct constant_int_op_binder {
// The matcher that matches a given target constant scalar / vector splat /
// tensor splat integer value.
template <int64_t TargetValue> struct constant_int_value_matcher {
- bool match(Instruction *op) {
+ bool match(Operation *op) {
APInt value;
return constant_int_op_binder(&value).match(op) && TargetValue == value;
@@ -120,7 +120,7 @@ template <int64_t TargetValue> struct constant_int_value_matcher {
/// The matcher that matches a certain kind of op.
template <typename OpClass> struct op_matcher {
- bool match(Instruction *op) { return op->isa<OpClass>(); }
+ bool match(Operation *op) { return op->isa<OpClass>(); }
};
} // end namespace detail
@@ -129,7 +129,7 @@ template <typename OpClass> struct op_matcher {
template <typename Pattern>
inline bool matchPattern(Value *value, const Pattern &pattern) {
// TODO: handle other cases
- if (auto *op = value->getDefiningInst())
+ if (auto *op = value->getDefiningOp())
return const_cast<Pattern &>(pattern).match(op);
return false;
}
diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index fabbf9d5767..24fc7fd2740 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -63,16 +63,16 @@ template <typename OpType> struct IsSingleResult {
class OpState {
public:
/// Ops are pointer-like, so we allow implicit conversion to bool.
- operator bool() { return getInstruction() != nullptr; }
+ operator bool() { return getOperation() != nullptr; }
- /// This implicitly converts to Instruction*.
- operator Instruction *() const { return state; }
+ /// This implicitly converts to Operation*.
+ operator Operation *() const { return state; }
/// Return the operation that this refers to.
- Instruction *getInstruction() { return state; }
+ Operation *getOperation() { return state; }
/// Return the context this operation belongs to.
- MLIRContext *getContext() { return getInstruction()->getContext(); }
+ MLIRContext *getContext() { return getOperation()->getContext(); }
/// The source location the operation was defined or derived from.
Location getLoc() { return state->getLoc(); }
@@ -144,18 +144,18 @@ protected:
/// Mutability management is handled by the OpWrapper/OpConstWrapper classes,
/// so we can cast it away here.
- explicit OpState(Instruction *state) : state(state) {}
+ explicit OpState(Operation *state) : state(state) {}
private:
- Instruction *state;
+ Operation *state;
};
// Allow comparing operators.
inline bool operator==(OpState lhs, OpState rhs) {
- return lhs.getInstruction() == rhs.getInstruction();
+ return lhs.getOperation() == rhs.getOperation();
}
inline bool operator!=(OpState lhs, OpState rhs) {
- return lhs.getInstruction() != rhs.getInstruction();
+ return lhs.getOperation() != rhs.getOperation();
}
/// This template defines the constantFoldHook and foldHook as used by
@@ -168,7 +168,7 @@ class FoldingHook {
public:
/// This is an implementation detail of the constant folder hook for
/// AbstractOperation.
- static LogicalResult constantFoldHook(Instruction *op,
+ static LogicalResult constantFoldHook(Operation *op,
ArrayRef<Attribute> operands,
SmallVectorImpl<Attribute> &results) {
return op->cast<ConcreteType>().constantFold(operands, results,
@@ -191,7 +191,7 @@ public:
}
/// This is an implementation detail of the folder hook for AbstractOperation.
- static LogicalResult foldHook(Instruction *op,
+ static LogicalResult foldHook(Operation *op,
SmallVectorImpl<Value *> &results) {
return op->cast<ConcreteType>().fold(results);
}
@@ -232,12 +232,12 @@ public:
/// If the operation returns a single value, then the Op can be implicitly
/// converted to an Value*. This yields the value of the only result.
operator Value *() {
- return static_cast<ConcreteType *>(this)->getInstruction()->getResult(0);
+ return static_cast<ConcreteType *>(this)->getOperation()->getResult(0);
}
/// This is an implementation detail of the constant folder hook for
/// AbstractOperation.
- static LogicalResult constantFoldHook(Instruction *op,
+ static LogicalResult constantFoldHook(Operation *op,
ArrayRef<Attribute> operands,
SmallVectorImpl<Attribute> &results) {
auto result =
@@ -263,7 +263,7 @@ public:
}
/// This is an implementation detail of the folder hook for AbstractOperation.
- static LogicalResult foldHook(Instruction *op,
+ static LogicalResult foldHook(Operation *op,
SmallVectorImpl<Value *> &results) {
auto *result = op->cast<ConcreteType>().fold();
if (!result)
@@ -299,7 +299,7 @@ public:
};
//===----------------------------------------------------------------------===//
-// Instruction Trait Types
+// Operation Trait Types
//===----------------------------------------------------------------------===//
namespace OpTrait {
@@ -308,22 +308,22 @@ namespace OpTrait {
// corresponding trait classes. This avoids them being template
// instantiated/duplicated.
namespace impl {
-bool verifyZeroOperands(Instruction *op);
-bool verifyOneOperand(Instruction *op);
-bool verifyNOperands(Instruction *op, unsigned numOperands);
-bool verifyAtLeastNOperands(Instruction *op, unsigned numOperands);
-bool verifyOperandsAreIntegerLike(Instruction *op);
-bool verifySameTypeOperands(Instruction *op);
-bool verifyZeroResult(Instruction *op);
-bool verifyOneResult(Instruction *op);
-bool verifyNResults(Instruction *op, unsigned numOperands);
-bool verifyAtLeastNResults(Instruction *op, unsigned numOperands);
-bool verifySameOperandsAndResultShape(Instruction *op);
-bool verifySameOperandsAndResultType(Instruction *op);
-bool verifyResultsAreBoolLike(Instruction *op);
-bool verifyResultsAreFloatLike(Instruction *op);
-bool verifyResultsAreIntegerLike(Instruction *op);
-bool verifyIsTerminator(Instruction *op);
+bool verifyZeroOperands(Operation *op);
+bool verifyOneOperand(Operation *op);
+bool verifyNOperands(Operation *op, unsigned numOperands);
+bool verifyAtLeastNOperands(Operation *op, unsigned numOperands);
+bool verifyOperandsAreIntegerLike(Operation *op);
+bool verifySameTypeOperands(Operation *op);
+bool verifyZeroResult(Operation *op);
+bool verifyOneResult(Operation *op);
+bool verifyNResults(Operation *op, unsigned numOperands);
+bool verifyAtLeastNResults(Operation *op, unsigned numOperands);
+bool verifySameOperandsAndResultShape(Operation *op);
+bool verifySameOperandsAndResultType(Operation *op);
+bool verifyResultsAreBoolLike(Operation *op);
+bool verifyResultsAreFloatLike(Operation *op);
+bool verifyResultsAreIntegerLike(Operation *op);
+bool verifyIsTerminator(Operation *op);
} // namespace impl
/// Helper class for implementing traits. Clients are not expected to interact
@@ -331,8 +331,8 @@ bool verifyIsTerminator(Instruction *op);
template <typename ConcreteType, template <typename> class TraitType>
class TraitBase {
protected:
- /// Return the ultimate Instruction being worked on.
- Instruction *getInstruction() {
+ /// Return the ultimate Operation being worked on.
+ Operation *getOperation() {
// 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
@@ -340,12 +340,12 @@ protected:
auto *trait = static_cast<TraitType<ConcreteType> *>(this);
auto *concrete = static_cast<ConcreteType *>(trait);
auto *base = static_cast<OpState *>(concrete);
- return base->getInstruction();
+ return base->getOperation();
}
/// Provide default implementations of trait hooks. This allows traits to
/// provide exactly the overrides they care about.
- static bool verifyTrait(Instruction *op) { return false; }
+ static bool verifyTrait(Operation *op) { return false; }
static AbstractOperation::OperationProperties getTraitProperties() {
return 0;
}
@@ -356,7 +356,7 @@ protected:
template <typename ConcreteType>
class ZeroOperands : public TraitBase<ConcreteType, ZeroOperands> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyZeroOperands(op);
}
@@ -371,15 +371,11 @@ private:
template <typename ConcreteType>
class OneOperand : public TraitBase<ConcreteType, OneOperand> {
public:
- Value *getOperand() { return this->getInstruction()->getOperand(0); }
+ Value *getOperand() { return this->getOperation()->getOperand(0); }
- void setOperand(Value *value) {
- this->getInstruction()->setOperand(0, value);
- }
+ void setOperand(Value *value) { this->getOperation()->setOperand(0, value); }
- static bool verifyTrait(Instruction *op) {
- return impl::verifyOneOperand(op);
- }
+ static bool verifyTrait(Operation *op) { return impl::verifyOneOperand(op); }
};
/// This class provides the API for ops that are known to have a specified
@@ -393,14 +389,14 @@ public:
class Impl : public TraitBase<ConcreteType, NOperands<N>::Impl> {
public:
Value *getOperand(unsigned i) {
- return this->getInstruction()->getOperand(i);
+ return this->getOperation()->getOperand(i);
}
void setOperand(unsigned i, Value *value) {
- this->getInstruction()->setOperand(i, value);
+ this->getOperation()->setOperand(i, value);
}
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyNOperands(op, N);
}
};
@@ -416,30 +412,28 @@ public:
template <typename ConcreteType>
class Impl : public TraitBase<ConcreteType, AtLeastNOperands<N>::Impl> {
public:
- unsigned getNumOperands() {
- return this->getInstruction()->getNumOperands();
- }
+ unsigned getNumOperands() { return this->getOperation()->getNumOperands(); }
Value *getOperand(unsigned i) {
- return this->getInstruction()->getOperand(i);
+ return this->getOperation()->getOperand(i);
}
void setOperand(unsigned i, Value *value) {
- this->getInstruction()->setOperand(i, value);
+ this->getOperation()->setOperand(i, value);
}
- using operand_iterator = Instruction::operand_iterator;
+ using operand_iterator = Operation::operand_iterator;
operand_iterator operand_begin() {
- return this->getInstruction()->operand_begin();
+ return this->getOperation()->operand_begin();
}
operand_iterator operand_end() {
- return this->getInstruction()->operand_end();
+ return this->getOperation()->operand_end();
}
llvm::iterator_range<operand_iterator> getOperands() {
- return this->getInstruction()->getOperands();
+ return this->getOperation()->getOperands();
}
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyAtLeastNOperands(op, N);
}
};
@@ -450,26 +444,22 @@ public:
template <typename ConcreteType>
class VariadicOperands : public TraitBase<ConcreteType, VariadicOperands> {
public:
- unsigned getNumOperands() { return this->getInstruction()->getNumOperands(); }
+ unsigned getNumOperands() { return this->getOperation()->getNumOperands(); }
- Value *getOperand(unsigned i) {
- return this->getInstruction()->getOperand(i);
- }
+ Value *getOperand(unsigned i) { return this->getOperation()->getOperand(i); }
void setOperand(unsigned i, Value *value) {
- this->getInstruction()->setOperand(i, value);
+ this->getOperation()->setOperand(i, value);
}
// Support operand iteration.
- using operand_iterator = Instruction::operand_iterator;
- using operand_range = Instruction::operand_range;
+ using operand_iterator = Operation::operand_iterator;
+ using operand_range = Operation::operand_range;
operand_iterator operand_begin() {
- return this->getInstruction()->operand_begin();
+ return this->getOperation()->operand_begin();
}
- operand_iterator operand_end() {
- return this->getInstruction()->operand_end();
- }
- operand_range getOperands() { return this->getInstruction()->getOperands(); }
+ operand_iterator operand_end() { return this->getOperation()->operand_end(); }
+ operand_range getOperands() { return this->getOperation()->getOperands(); }
};
/// This class provides return value APIs for ops that are known to have
@@ -477,9 +467,7 @@ public:
template <typename ConcreteType>
class ZeroResult : public TraitBase<ConcreteType, ZeroResult> {
public:
- static bool verifyTrait(Instruction *op) {
- return impl::verifyZeroResult(op);
- }
+ static bool verifyTrait(Operation *op) { return impl::verifyZeroResult(op); }
};
/// This class provides return value APIs for ops that are known to have a
@@ -487,7 +475,7 @@ public:
template <typename ConcreteType>
class OneResult : public TraitBase<ConcreteType, OneResult> {
public:
- Value *getResult() { return this->getInstruction()->getResult(0); }
+ Value *getResult() { return this->getOperation()->getResult(0); }
Type getType() { return getResult()->getType(); }
@@ -498,7 +486,7 @@ public:
getResult()->replaceAllUsesWith(newValue);
}
- static bool verifyTrait(Instruction *op) { return impl::verifyOneResult(op); }
+ static bool verifyTrait(Operation *op) { return impl::verifyOneResult(op); }
};
/// This class provides the API for ops that are known to have a specified
@@ -513,13 +501,11 @@ public:
public:
static unsigned getNumResults() { return N; }
- Value *getResult(unsigned i) {
- return this->getInstruction()->getResult(i);
- }
+ Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
Type getType(unsigned i) { return getResult(i)->getType(); }
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyNResults(op, N);
}
};
@@ -535,13 +521,11 @@ public:
template <typename ConcreteType>
class Impl : public TraitBase<ConcreteType, AtLeastNResults<N>::Impl> {
public:
- Value *getResult(unsigned i) {
- return this->getInstruction()->getResult(i);
- }
+ Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
Type getType(unsigned i) { return getResult(i)->getType(); }
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyAtLeastNResults(op, N);
}
};
@@ -552,22 +536,22 @@ public:
template <typename ConcreteType>
class VariadicResults : public TraitBase<ConcreteType, VariadicResults> {
public:
- unsigned getNumResults() { return this->getInstruction()->getNumResults(); }
+ unsigned getNumResults() { return this->getOperation()->getNumResults(); }
- Value *getResult(unsigned i) { return this->getInstruction()->getResult(i); }
+ Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
void setResult(unsigned i, Value *value) {
- this->getInstruction()->setResult(i, value);
+ this->getOperation()->setResult(i, value);
}
// Support result iteration.
- using result_iterator = Instruction::result_iterator;
+ using result_iterator = Operation::result_iterator;
result_iterator result_begin() {
- return this->getInstruction()->result_begin();
+ return this->getOperation()->result_begin();
}
- result_iterator result_end() { return this->getInstruction()->result_end(); }
+ result_iterator result_end() { return this->getOperation()->result_end(); }
llvm::iterator_range<result_iterator> getResults() {
- return this->getInstruction()->getResults();
+ return this->getOperation()->getResults();
}
};
@@ -578,7 +562,7 @@ template <typename ConcreteType>
class SameOperandsAndResultShape
: public TraitBase<ConcreteType, SameOperandsAndResultShape> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifySameOperandsAndResultShape(op);
}
};
@@ -593,7 +577,7 @@ template <typename ConcreteType>
class SameOperandsAndResultType
: public TraitBase<ConcreteType, SameOperandsAndResultType> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifySameOperandsAndResultType(op);
}
};
@@ -603,7 +587,7 @@ public:
template <typename ConcreteType>
class ResultsAreBoolLike : public TraitBase<ConcreteType, ResultsAreBoolLike> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyResultsAreBoolLike(op);
}
};
@@ -614,7 +598,7 @@ template <typename ConcreteType>
class ResultsAreFloatLike
: public TraitBase<ConcreteType, ResultsAreFloatLike> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyResultsAreFloatLike(op);
}
};
@@ -625,7 +609,7 @@ template <typename ConcreteType>
class ResultsAreIntegerLike
: public TraitBase<ConcreteType, ResultsAreIntegerLike> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyResultsAreIntegerLike(op);
}
};
@@ -656,7 +640,7 @@ template <typename ConcreteType>
class OperandsAreIntegerLike
: public TraitBase<ConcreteType, OperandsAreIntegerLike> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyOperandsAreIntegerLike(op);
}
};
@@ -666,7 +650,7 @@ public:
template <typename ConcreteType>
class SameTypeOperands : public TraitBase<ConcreteType, SameTypeOperands> {
public:
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifySameTypeOperands(op);
}
};
@@ -679,37 +663,37 @@ public:
return static_cast<AbstractOperation::OperationProperties>(
OperationProperty::Terminator);
}
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return impl::verifyIsTerminator(op);
}
unsigned getNumSuccessors() {
- return this->getInstruction()->getNumSuccessors();
+ return this->getOperation()->getNumSuccessors();
}
unsigned getNumSuccessorOperands(unsigned index) {
- return this->getInstruction()->getNumSuccessorOperands(index);
+ return this->getOperation()->getNumSuccessorOperands(index);
}
Block *getSuccessor(unsigned index) {
- return this->getInstruction()->getSuccessor(index);
+ return this->getOperation()->getSuccessor(index);
}
void setSuccessor(Block *block, unsigned index) {
- return this->getInstruction()->setSuccessor(block, index);
+ return this->getOperation()->setSuccessor(block, index);
}
void addSuccessorOperand(unsigned index, Value *value) {
- return this->getInstruction()->addSuccessorOperand(index, value);
+ return this->getOperation()->addSuccessorOperand(index, value);
}
void addSuccessorOperands(unsigned index, ArrayRef<Value *> values) {
- return this->getInstruction()->addSuccessorOperand(index, values);
+ return this->getOperation()->addSuccessorOperand(index, values);
}
};
} // end namespace OpTrait
//===----------------------------------------------------------------------===//
-// Instruction Definition classes
+// Operation Definition classes
//===----------------------------------------------------------------------===//
/// This provides public APIs that all operations should have. The template
@@ -724,13 +708,13 @@ class Op : public OpState,
Traits<ConcreteType>...>::value> {
public:
/// Return the operation that this refers to.
- Instruction *getInstruction() { return OpState::getInstruction(); }
+ Operation *getOperation() { return OpState::getOperation(); }
/// Return true if this "op class" can match against the specified operation.
/// This hook can be overridden with a more specific implementation in
/// the subclass of Base.
///
- static bool isClassFor(Instruction *op) {
+ static bool isClassFor(Operation *op) {
return op->getName().getStringRef() == ConcreteType::getOperationName();
}
@@ -744,21 +728,21 @@ public:
/// This is the hook used by the AsmPrinter to emit this to the .mlir file.
/// Op implementations should provide a print method.
- static void printAssembly(Instruction *op, OpAsmPrinter *p) {
+ static void printAssembly(Operation *op, OpAsmPrinter *p) {
auto opPointer = op->dyn_cast<ConcreteType>();
assert(opPointer &&
"op's name does not match name of concrete type instantiated with");
opPointer.print(p);
}
- /// This is the hook that checks whether or not this instruction is well
+ /// This is the hook that checks whether or not this operation is well
/// formed according to the invariants of its opcode. It delegates to the
/// Traits for their policy implementations, and allows the user to specify
/// their own verify() method.
///
/// On success this returns false; on failure it emits an error to the
/// diagnostic subsystem and returns true.
- static bool verifyInvariants(Instruction *op) {
+ static bool verifyInvariants(Operation *op) {
return BaseVerifier<Traits<ConcreteType>...>::verifyTrait(op) ||
op->cast<ConcreteType>().verify();
}
@@ -780,8 +764,8 @@ public:
protected:
/// This is a private constructor only accessible through the
- /// Instruction::cast family of methods.
- explicit Op(Instruction *state) : OpState(state) {}
+ /// Operation::cast family of methods.
+ explicit Op(Operation *state) : OpState(state) {}
friend class Operation;
private:
@@ -789,13 +773,13 @@ private:
template <typename First, typename... Rest>
struct BaseVerifier<First, Rest...> {
- static bool verifyTrait(Instruction *op) {
+ static bool verifyTrait(Operation *op) {
return First::verifyTrait(op) || BaseVerifier<Rest...>::verifyTrait(op);
}
};
template <typename...> struct BaseVerifier {
- static bool verifyTrait(Instruction *op) { return false; }
+ static bool verifyTrait(Operation *op) { return false; }
};
template <typename... Types> struct BaseProperties;
@@ -824,7 +808,7 @@ bool parseBinaryOp(OpAsmParser *parser, OperationState *result);
// Prints the given binary `op` in custom assembly form if both the two operands
// and the result have the same time. Otherwise, prints the generic assembly
// form.
-void printBinaryOp(Instruction *op, OpAsmPrinter *p);
+void printBinaryOp(Operation *op, OpAsmPrinter *p);
} // namespace impl
// These functions are out-of-line implementations of the methods in CastOp,
@@ -833,7 +817,7 @@ namespace impl {
void buildCastOp(Builder *builder, OperationState *result, Value *source,
Type destType);
bool parseCastOp(OpAsmParser *parser, OperationState *result);
-void printCastOp(Instruction *op, OpAsmPrinter *p);
+void printCastOp(Operation *op, OpAsmPrinter *p);
} // namespace impl
/// This template is used for operations that are cast operations, that have a
@@ -857,7 +841,7 @@ public:
return impl::parseCastOp(parser, result);
}
void print(OpAsmPrinter *p) {
- return impl::printCastOp(this->getInstruction(), p);
+ return impl::printCastOp(this->getOperation(), p);
}
};
diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index ffa26828e8b..eeb35b2d51a 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -76,7 +76,7 @@ public:
/// Print a successor, and use list, of a terminator operation given the
/// terminator and the successor index.
- virtual void printSuccessorAndUseList(Instruction *term, unsigned index) = 0;
+ virtual void printSuccessorAndUseList(Operation *term, unsigned index) = 0;
/// If the specified operation has attributes, print out an attribute
/// dictionary with their values. elidedAttrs allows the client to ignore
@@ -86,7 +86,7 @@ public:
ArrayRef<StringRef> elidedAttrs = {}) = 0;
/// Print the entire operation with the default generic assembly form.
- virtual void printGenericOp(Instruction *op) = 0;
+ virtual void printGenericOp(Operation *op) = 0;
/// Prints a region.
virtual void printRegion(Region &blocks, bool printEntryBlockArgs = true) = 0;
diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index 0baceb3fe0d..0fae3fc495f 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -46,8 +46,8 @@ using BlockOperand = IROperandImpl<Block>;
/// class.
class Operation final
: public llvm::ilist_node_with_parent<Operation, Block>,
- private llvm::TrailingObjects<Operation, InstResult, BlockOperand,
- unsigned, Region, detail::OperandStorage> {
+ private llvm::TrailingObjects<Operation, OpResult, BlockOperand, unsigned,
+ Region, detail::OperandStorage> {
public:
/// Create a new Operation with the specific fields.
static Operation *create(Location location, OperationName name,
@@ -188,7 +188,7 @@ public:
unsigned getNumResults() { return numResults; }
- Value *getResult(unsigned idx) { return &getInstResult(idx); }
+ Value *getResult(unsigned idx) { return &getOpResult(idx); }
// Support result iteration.
using result_iterator = ResultIterator;
@@ -196,11 +196,11 @@ public:
result_iterator result_end();
llvm::iterator_range<result_iterator> getResults();
- MutableArrayRef<InstResult> getInstResults() {
- return {getTrailingObjects<InstResult>(), numResults};
+ MutableArrayRef<OpResult> getOpResults() {
+ return {getTrailingObjects<OpResult>(), numResults};
}
- InstResult &getInstResult(unsigned idx) { return getInstResults()[idx]; }
+ OpResult &getOpResult(unsigned idx) { return getOpResults()[idx]; }
// Support result type iteration.
using result_type_iterator = ResultTypeIterator;
@@ -486,9 +486,9 @@ private:
friend class llvm::ilist_node_with_parent<Operation, Block>;
// This stuff is used by the TrailingObjects template.
- friend llvm::TrailingObjects<Operation, InstResult, BlockOperand, unsigned,
+ friend llvm::TrailingObjects<Operation, OpResult, BlockOperand, unsigned,
Region, detail::OperandStorage>;
- size_t numTrailingObjects(OverloadToken<InstResult>) const {
+ size_t numTrailingObjects(OverloadToken<OpResult>) const {
return numResults;
}
size_t numTrailingObjects(OverloadToken<BlockOperand>) const {
diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h
index 2e8aba2aedd..0b35bb32a68 100644
--- a/mlir/include/mlir/IR/PatternMatch.h
+++ b/mlir/include/mlir/IR/PatternMatch.h
@@ -109,7 +109,7 @@ public:
/// which is the same operation code as getRootKind(). On failure, this
/// returns a None value. On success it returns a (possibly null)
/// pattern-specific state wrapped in an Optional.
- virtual PatternMatchResult match(Instruction *op) const = 0;
+ virtual PatternMatchResult match(Operation *op) const = 0;
virtual ~Pattern() {}
@@ -155,7 +155,7 @@ public:
/// rewriter. If an unexpected error is encountered (an internal
/// compiler error), it is emitted through the normal MLIR diagnostic
/// hooks and the IR is left in a valid state.
- virtual void rewrite(Instruction *op, std::unique_ptr<PatternState> state,
+ virtual void rewrite(Operation *op, std::unique_ptr<PatternState> state,
PatternRewriter &rewriter) const;
/// Rewrite the IR rooted at the specified operation with the result of
@@ -163,19 +163,19 @@ public:
/// builder. If an unexpected error is encountered (an internal
/// compiler error), it is emitted through the normal MLIR diagnostic
/// hooks and the IR is left in a valid state.
- virtual void rewrite(Instruction *op, PatternRewriter &rewriter) const;
+ virtual void rewrite(Operation *op, PatternRewriter &rewriter) const;
/// Attempt to match against code rooted at the specified operation,
/// which is the same operation code as getRootKind(). On failure, this
/// returns a None value. On success, it returns a (possibly null)
/// pattern-specific state wrapped in an Optional. This state is passed back
/// into the rewrite function if this match is selected.
- PatternMatchResult match(Instruction *op) const override;
+ PatternMatchResult match(Operation *op) const override;
/// Attempt to match against code rooted at the specified operation,
/// which is the same operation code as getRootKind(). If successful, this
/// function will automatically perform the rewrite.
- virtual PatternMatchResult matchAndRewrite(Instruction *op,
+ virtual PatternMatchResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const {
if (auto matchResult = match(op)) {
rewrite(op, std::move(*matchResult), rewriter);
@@ -229,14 +229,14 @@ public:
OpTy::build(this, &state, args...);
auto *op = createOperation(state);
- // If the Instruction we produce is valid, return it.
+ // If the Operation we produce is valid, return it.
if (!OpTy::verifyInvariants(op)) {
auto result = op->dyn_cast<OpTy>();
assert(result && "Builder didn't return the right type");
return result;
}
- // Otherwise, the error message got emitted. Just remove the instruction
+ // Otherwise, the error message got emitted. Just remove the operation
// we made.
op->erase();
return OpTy();
@@ -248,38 +248,37 @@ public:
/// clients can specify a list of other nodes that this replacement may make
/// (perhaps transitively) dead. If any of those values are dead, this will
/// remove them as well.
- void replaceOp(Instruction *op, ArrayRef<Value *> newValues,
+ void replaceOp(Operation *op, ArrayRef<Value *> newValues,
ArrayRef<Value *> valuesToRemoveIfDead = {});
/// Replaces the result op with a new op that is created without verification.
/// The result values of the two ops must be the same types.
template <typename OpTy, typename... Args>
- void replaceOpWithNewOp(Instruction *op, Args... args) {
+ void replaceOpWithNewOp(Operation *op, Args... args) {
auto newOp = create<OpTy>(op->getLoc(), args...);
- replaceOpWithResultsOfAnotherOp(op, newOp.getInstruction(), {});
+ replaceOpWithResultsOfAnotherOp(op, newOp.getOperation(), {});
}
/// Replaces the result op with a new op that is created without verification.
/// The result values of the two ops must be the same types. This allows
/// specifying a list of ops that may be removed if dead.
template <typename OpTy, typename... Args>
- void replaceOpWithNewOp(Instruction *op,
- ArrayRef<Value *> valuesToRemoveIfDead,
+ void replaceOpWithNewOp(Operation *op, ArrayRef<Value *> valuesToRemoveIfDead,
Args... args) {
auto newOp = create<OpTy>(op->getLoc(), args...);
- replaceOpWithResultsOfAnotherOp(op, newOp.getInstruction(),
+ replaceOpWithResultsOfAnotherOp(op, newOp.getOperation(),
valuesToRemoveIfDead);
}
/// This method is used as the final notification hook for patterns that end
/// up modifying the pattern root in place, by changing its operands. This is
- /// a minor efficiency win (it avoids creating a new instruction and removing
+ /// a minor efficiency win (it avoids creating a new operation and removing
/// the old one) but also often allows simpler code in the client.
///
/// The valuesToRemoveIfDead list is an optional list of values that the
/// rewriter should remove if they are dead at this point.
///
- void updatedRootInPlace(Instruction *op,
+ void updatedRootInPlace(Operation *op,
ArrayRef<Value *> valuesToRemoveIfDead = {});
protected:
@@ -291,26 +290,26 @@ protected:
/// This is implemented to create the specified operations and serves as a
/// notification hook for rewriters that want to know about new operations.
- virtual Instruction *createOperation(const OperationState &state) = 0;
+ virtual Operation *createOperation(const OperationState &state) = 0;
/// Notify the pattern rewriter that the specified operation has been mutated
/// in place. This is called after the mutation is done.
- virtual void notifyRootUpdated(Instruction *op) {}
+ virtual void notifyRootUpdated(Operation *op) {}
/// Notify the pattern rewriter that the specified operation is about to be
/// replaced with another set of operations. This is called before the uses
/// of the operation have been changed.
- virtual void notifyRootReplaced(Instruction *op) {}
+ virtual void notifyRootReplaced(Operation *op) {}
/// This is called on an operation that a pattern match is removing, right
/// before the operation is deleted. At this point, the operation has zero
/// uses.
- virtual void notifyOperationRemoved(Instruction *op) {}
+ virtual void notifyOperationRemoved(Operation *op) {}
private:
/// op and newOp are known to have the same number of results, replace the
/// uses of op with uses of newOp
- void replaceOpWithResultsOfAnotherOp(Instruction *op, Instruction *newOp,
+ void replaceOpWithResultsOfAnotherOp(Operation *op, Operation *newOp,
ArrayRef<Value *> valuesToRemoveIfDead);
};
@@ -333,7 +332,7 @@ public:
PatternRewriter &rewriter);
/// Try to match the given operation to a pattern and rewrite it.
- void matchAndRewrite(Instruction *op);
+ void matchAndRewrite(Operation *op);
private:
RewritePatternMatcher(const RewritePatternMatcher &) = delete;
diff --git a/mlir/include/mlir/IR/UseDefLists.h b/mlir/include/mlir/IR/UseDefLists.h
index 761cd6fa45d..623fd9cd64e 100644
--- a/mlir/include/mlir/IR/UseDefLists.h
+++ b/mlir/include/mlir/IR/UseDefLists.h
@@ -30,7 +30,6 @@ namespace mlir {
class IROperand;
class Operation;
-using Instruction = Operation;
template <typename OperandType> class ValueUseIterator;
class IRObjectWithUseList {
@@ -75,11 +74,11 @@ private:
IROperand *firstUse = nullptr;
};
-/// A reference to a value, suitable for use as an operand of an instruction.
+/// A reference to a value, suitable for use as an operand of an operation.
class IROperand {
public:
- IROperand(Instruction *owner) : owner(owner) {}
- IROperand(Instruction *owner, IRObjectWithUseList *value)
+ IROperand(Operation *owner) : owner(owner) {}
+ IROperand(Operation *owner, IRObjectWithUseList *value)
: value(value), owner(owner) {
insertIntoCurrent();
}
@@ -97,8 +96,8 @@ public:
}
/// Return the owner of this operand.
- Instruction *getOwner() { return owner; }
- Instruction *getOwner() const { return owner; }
+ Operation *getOwner() { return owner; }
+ Operation *getOwner() const { return owner; }
/// \brief Remove this use of the operand.
void drop() {
@@ -143,8 +142,8 @@ private:
/// This points to the previous link in the use-chain.
IROperand **back = nullptr;
- /// The instruction owner of this operand.
- Instruction *const owner;
+ /// The operation owner of this operand.
+ Operation *const owner;
/// Operands are not copyable or assignable.
IROperand(const IROperand &use) = delete;
@@ -167,14 +166,13 @@ private:
}
};
-/// A reference to a value, suitable for use as an operand of an instruction,
-/// instruction, etc. IRValueTy is the root type to use for values this tracks,
+/// A reference to a value, suitable for use as an operand of an operation,
+/// operation, etc. IRValueTy is the root type to use for values this tracks,
/// and SSAUserTy is the type that will contain operands.
template <typename IRValueTy> class IROperandImpl : public IROperand {
public:
- IROperandImpl(Instruction *owner) : IROperand(owner) {}
- IROperandImpl(Instruction *owner, IRValueTy *value)
- : IROperand(owner, value) {}
+ IROperandImpl(Operation *owner) : IROperand(owner) {}
+ IROperandImpl(Operation *owner, IRValueTy *value) : IROperand(owner, value) {}
/// Return the current value being used by this operand.
IRValueTy *get() { return (IRValueTy *)IROperand::get(); }
@@ -196,7 +194,7 @@ public:
OperandType *operator->() const { return current; }
OperandType &operator*() const { return *current; }
- Instruction *getUser() const { return current->getOwner(); }
+ Operation *getUser() const { return current->getOwner(); }
ValueUseIterator &operator++() {
assert(current && "incrementing past end()!");
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index ef3d7c47ce8..04ba9cd2788 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -30,7 +30,6 @@ namespace mlir {
class Block;
class Function;
class Operation;
-using Instruction = Operation;
class Value;
/// Operands contain a Value.
@@ -44,7 +43,7 @@ public:
/// This enumerates all of the SSA value kinds in the MLIR system.
enum class Kind {
BlockArgument, // block argument
- InstResult, // operation instruction result
+ OpResult, // operation result
};
~Value() {}
@@ -63,9 +62,9 @@ public:
/// Return the function that this Value is defined in.
Function *getFunction();
- /// If this value is the result of an operation, return the instruction
- /// that defines it.
- Instruction *getDefiningInst();
+ /// If this value is the result of an operation, return the operation that
+ /// defines it.
+ Operation *getDefiningOp();
using use_iterator = ValueUseIterator<InstOperand>;
using use_range = llvm::iterator_range<use_iterator>;
@@ -131,17 +130,17 @@ private:
Block *const owner;
};
-/// This is a value defined by a result of an operation instruction.
-class InstResult : public Value {
+/// This is a value defined by a result of an operation.
+class OpResult : public Value {
public:
- InstResult(Type type, Instruction *owner)
- : Value(Value::Kind::InstResult, type), owner(owner) {}
+ OpResult(Type type, Operation *owner)
+ : Value(Value::Kind::OpResult, type), owner(owner) {}
static bool classof(const Value *value) {
- return const_cast<Value *>(value)->getKind() == Kind::InstResult;
+ return const_cast<Value *>(value)->getKind() == Kind::OpResult;
}
- Instruction *getOwner() { return owner; }
+ Operation *getOwner() { return owner; }
/// Returns the number of this result.
unsigned getResultNumber();
@@ -150,7 +149,7 @@ private:
/// The owner of this operand.
/// TODO: can encode this more efficiently to avoid the space hit of this
/// through bitpacking shenanigans.
- Instruction *const owner;
+ Operation *const owner;
};
/// This is a helper template used to implement an iterator that contains a
diff --git a/mlir/include/mlir/StandardOps/Ops.h b/mlir/include/mlir/StandardOps/Ops.h
index b3e0f9daccf..eb0a3ec644f 100644
--- a/mlir/include/mlir/StandardOps/Ops.h
+++ b/mlir/include/mlir/StandardOps/Ops.h
@@ -558,8 +558,8 @@ public:
}
// Returns the source memerf indices for this DMA operation.
llvm::iterator_range<Instruction::operand_iterator> getSrcIndices() {
- return {getInstruction()->operand_begin() + 1,
- getInstruction()->operand_begin() + 1 + getSrcMemRefRank()};
+ return {getOperation()->operand_begin() + 1,
+ getOperation()->operand_begin() + 1 + getSrcMemRefRank()};
}
// Returns the destination MemRefType for this DMA operations.
@@ -577,8 +577,8 @@ public:
// Returns the destination memref indices for this DMA operation.
llvm::iterator_range<Instruction::operand_iterator> getDstIndices() {
- return {getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1,
- getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1 +
+ return {getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1,
+ getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1 +
getDstMemRefRank()};
}
@@ -600,8 +600,8 @@ public:
llvm::iterator_range<Instruction::operand_iterator> getTagIndices() {
unsigned tagIndexStartPos =
1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1 + 1;
- return {getInstruction()->operand_begin() + tagIndexStartPos,
- getInstruction()->operand_begin() + tagIndexStartPos +
+ return {getOperation()->operand_begin() + tagIndexStartPos,
+ getOperation()->operand_begin() + tagIndexStartPos +
getTagMemRefRank()};
}
@@ -678,8 +678,8 @@ public:
// Returns the tag memref index for this DMA operation.
llvm::iterator_range<Instruction::operand_iterator> getTagIndices() {
- return {getInstruction()->operand_begin() + 1,
- getInstruction()->operand_begin() + 1 + getTagMemRefRank()};
+ return {getOperation()->operand_begin() + 1,
+ getOperation()->operand_begin() + 1 + getTagMemRefRank()};
}
// Returns the rank (number of indices) of the tag memref.
@@ -719,8 +719,7 @@ public:
Value *getAggregate() { return getOperand(0); }
llvm::iterator_range<Instruction::operand_iterator> getIndices() {
- return {getInstruction()->operand_begin() + 1,
- getInstruction()->operand_end()};
+ return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
}
static StringRef getOperationName() { return "std.extract_element"; }
@@ -756,8 +755,7 @@ public:
}
llvm::iterator_range<Instruction::operand_iterator> getIndices() {
- return {getInstruction()->operand_begin() + 1,
- getInstruction()->operand_end()};
+ return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
}
static StringRef getOperationName() { return "std.load"; }
@@ -881,8 +879,7 @@ public:
}
llvm::iterator_range<Instruction::operand_iterator> getIndices() {
- return {getInstruction()->operand_begin() + 2,
- getInstruction()->operand_end()};
+ return {getOperation()->operand_begin() + 2, getOperation()->operand_end()};
}
static StringRef getOperationName() { return "std.store"; }
diff --git a/mlir/include/mlir/StandardOps/Ops.td b/mlir/include/mlir/StandardOps/Ops.td
index 5024999fc71..fd1e87fd0d8 100644
--- a/mlir/include/mlir/StandardOps/Ops.td
+++ b/mlir/include/mlir/StandardOps/Ops.td
@@ -42,7 +42,7 @@ class ArithmeticOp<string mnemonic, list<OpTrait> traits = []> :
}];
let printer = [{
- return detail::printStandardBinaryOp(this->getInstruction(), p);
+ return detail::printStandardBinaryOp(this->getOperation(), p);
}];
}
diff --git a/mlir/lib/AffineOps/AffineOps.cpp b/mlir/lib/AffineOps/AffineOps.cpp
index a6dd19a418f..c1f9606eba3 100644
--- a/mlir/lib/AffineOps/AffineOps.cpp
+++ b/mlir/lib/AffineOps/AffineOps.cpp
@@ -45,7 +45,7 @@ AffineOpsDialect::AffineOpsDialect(MLIRContext *context)
bool mlir::isTopLevelSymbol(Value *value) {
if (auto *arg = dyn_cast<BlockArgument>(value))
return arg->getOwner()->getParent()->getContainingFunction();
- return value->getDefiningInst()->getParentInst() == nullptr;
+ return value->getDefiningOp()->getParentInst() == nullptr;
}
// Value can be used as a dimension id if it is valid as a symbol, or
@@ -56,7 +56,7 @@ bool mlir::isValidDim(Value *value) {
if (!value->getType().isIndex())
return false;
- if (auto *inst = value->getDefiningInst()) {
+ if (auto *inst = value->getDefiningOp()) {
// Top level instruction or constant operation is ok.
if (inst->getParentInst() == nullptr || inst->isa<ConstantOp>())
return true;
@@ -81,7 +81,7 @@ bool mlir::isValidSymbol(Value *value) {
if (!value->getType().isIndex())
return false;
- if (auto *inst = value->getDefiningInst()) {
+ if (auto *inst = value->getDefiningOp()) {
// Top level instruction or constant operation is ok.
if (inst->getParentInst() == nullptr || inst->isa<ConstantOp>())
return true;
@@ -317,7 +317,7 @@ indicesFromAffineApplyOp(ArrayRef<Value *> operands) {
llvm::SetVector<unsigned> res;
for (auto en : llvm::enumerate(operands)) {
auto *t = en.value();
- if (t->getDefiningInst() && t->getDefiningInst()->isa<AffineApplyOp>()) {
+ if (t->getDefiningOp() && t->getDefiningOp()->isa<AffineApplyOp>()) {
res.insert(en.index());
}
}
@@ -458,12 +458,12 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map,
// 2. Compose AffineApplyOps and dispatch dims or symbols.
for (unsigned i = 0, e = operands.size(); i < e; ++i) {
auto *t = operands[i];
- auto affineApply = t->getDefiningInst()
- ? t->getDefiningInst()->dyn_cast<AffineApplyOp>()
+ auto affineApply = t->getDefiningOp()
+ ? t->getDefiningOp()->dyn_cast<AffineApplyOp>()
: AffineApplyOp();
if (affineApply) {
// a. Compose affine.apply instructions.
- LLVM_DEBUG(affineApply.getInstruction()->print(
+ LLVM_DEBUG(affineApply.getOperation()->print(
dbgs() << "\nCompose AffineApplyOp recursively: "));
AffineMap affineApplyMap = affineApply.getAffineMap();
SmallVector<Value *, 8> affineApplyOperands(
@@ -535,7 +535,7 @@ static void composeAffineMapAndOperands(AffineMap *map,
void mlir::fullyComposeAffineMapAndOperands(
AffineMap *map, SmallVectorImpl<Value *> *operands) {
while (llvm::any_of(*operands, [](Value *v) {
- return v->getDefiningInst() && v->getDefiningInst()->isa<AffineApplyOp>();
+ return v->getDefiningOp() && v->getDefiningOp()->isa<AffineApplyOp>();
})) {
composeAffineMapAndOperands(map, operands);
}
@@ -731,7 +731,7 @@ void AffineForOp::build(Builder *builder, OperationState *result, int64_t lb,
}
bool AffineForOp::verify() {
- auto &bodyRegion = getInstruction()->getRegion(0);
+ auto &bodyRegion = getOperation()->getRegion(0);
// The body region must contain a single basic block.
if (bodyRegion.empty() || std::next(bodyRegion.begin()) != bodyRegion.end())
@@ -955,7 +955,7 @@ void AffineForOp::print(OpAsmPrinter *p) {
if (getStep() != 1)
*p << " step " << getStep();
- p->printRegion(getInstruction()->getRegion(0),
+ p->printRegion(getOperation()->getRegion(0),
/*printEntryBlockArgs=*/false);
p->printOptionalAttrDict(getAttrs(),
/*elidedAttrs=*/{getLowerBoundAttrName(),
@@ -1062,7 +1062,7 @@ void AffineForOp::setLowerBound(ArrayRef<Value *> lbOperands, AffineMap map) {
auto ubOperands = getUpperBoundOperands();
newOperands.append(ubOperands.begin(), ubOperands.end());
- getInstruction()->setOperands(newOperands);
+ getOperation()->setOperands(newOperands);
setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map));
}
@@ -1073,7 +1073,7 @@ void AffineForOp::setUpperBound(ArrayRef<Value *> ubOperands, AffineMap map) {
SmallVector<Value *, 4> newOperands(getLowerBoundOperands());
newOperands.append(ubOperands.begin(), ubOperands.end());
- getInstruction()->setOperands(newOperands);
+ getOperation()->setOperands(newOperands);
setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map));
}
@@ -1158,7 +1158,7 @@ AffineForOp mlir::getForInductionVarOwner(Value *val) {
auto *ivArg = dyn_cast<BlockArgument>(val);
if (!ivArg || !ivArg->getOwner())
return AffineForOp();
- auto *containingInst = ivArg->getOwner()->getParent()->getContainingInst();
+ auto *containingInst = ivArg->getOwner()->getParent()->getContainingOp();
if (!containingInst)
return AffineForOp();
return containingInst->dyn_cast<AffineForOp>();
@@ -1207,7 +1207,7 @@ bool AffineIfOp::verify() {
return true;
// Verify that the entry of each child region does not have arguments.
- for (auto &region : getInstruction()->getRegions()) {
+ for (auto &region : getOperation()->getRegions()) {
if (region.empty())
continue;
@@ -1273,10 +1273,10 @@ void AffineIfOp::print(OpAsmPrinter *p) {
*p << "affine.if " << conditionAttr;
printDimAndSymbolList(operand_begin(), operand_end(),
conditionAttr.getValue().getNumDims(), p);
- p->printRegion(getInstruction()->getRegion(0));
+ p->printRegion(getOperation()->getRegion(0));
// Print the 'else' regions if it has any blocks.
- auto &elseRegion = getInstruction()->getRegion(1);
+ auto &elseRegion = getOperation()->getRegion(1);
if (!elseRegion.empty()) {
*p << " else";
p->printRegion(elseRegion);
@@ -1295,7 +1295,7 @@ void AffineIfOp::setIntegerSet(IntegerSet newSet) {
}
/// Returns the list of 'then' blocks.
-Region &AffineIfOp::getThenBlocks() { return getInstruction()->getRegion(0); }
+Region &AffineIfOp::getThenBlocks() { return getOperation()->getRegion(0); }
/// Returns the list of 'else' blocks.
-Region &AffineIfOp::getElseBlocks() { return getInstruction()->getRegion(1); }
+Region &AffineIfOp::getElseBlocks() { return getOperation()->getRegion(1); }
diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp
index 6b865c40638..b3548f96b29 100644
--- a/mlir/lib/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Analysis/AffineAnalysis.cpp
@@ -62,8 +62,8 @@ void mlir::getReachableAffineApplyOps(
while (!worklist.empty()) {
State &state = worklist.back();
- auto *opInst = state.value->getDefiningInst();
- // Note: getDefiningInst will return nullptr if the operand is not an
+ auto *opInst = state.value->getDefiningOp();
+ // Note: getDefiningOp will return nullptr if the operand is not an
// Instruction (i.e. AffineForOp), which is a terminator for the search.
if (opInst == nullptr || !opInst->isa<AffineApplyOp>()) {
worklist.pop_back();
@@ -458,7 +458,7 @@ addMemRefAccessConstraints(const AffineValueMap &srcAccessMap,
auto *symbol = operands[i];
assert(isValidSymbol(symbol));
// Check if the symbol is a constant.
- if (auto *opInst = symbol->getDefiningInst()) {
+ if (auto *opInst = symbol->getDefiningOp()) {
if (auto constOp = opInst->dyn_cast<ConstantIndexOp>()) {
dependenceDomain->setIdToConstant(valuePosMap.getSymPos(symbol),
constOp.getValue());
@@ -538,8 +538,8 @@ static Block *getCommonBlock(const MemRefAccess &srcAccess,
unsigned numCommonLoops) {
if (numCommonLoops == 0) {
auto *block = srcAccess.opInst->getBlock();
- while (block->getContainingInst()) {
- block = block->getContainingInst()->getBlock();
+ while (block->getContainingOp()) {
+ block = block->getContainingOp()->getBlock();
}
return block;
}
diff --git a/mlir/lib/Analysis/AffineStructures.cpp b/mlir/lib/Analysis/AffineStructures.cpp
index dd254b466e1..483e69f7b1d 100644
--- a/mlir/lib/Analysis/AffineStructures.cpp
+++ b/mlir/lib/Analysis/AffineStructures.cpp
@@ -727,7 +727,7 @@ void FlatAffineConstraints::addInductionVarOrTerminalSymbol(Value *id) {
// Add top level symbol.
addSymbolId(getNumSymbolIds(), id);
// Check if the symbol is a constant.
- if (auto *opInst = id->getDefiningInst()) {
+ if (auto *opInst = id->getDefiningOp()) {
if (auto constOp = opInst->dyn_cast<ConstantIndexOp>()) {
setIdToConstant(*id, constOp.getValue());
}
diff --git a/mlir/lib/Analysis/Dominance.cpp b/mlir/lib/Analysis/Dominance.cpp
index 24828a71204..b8a9e1c0218 100644
--- a/mlir/lib/Analysis/Dominance.cpp
+++ b/mlir/lib/Analysis/Dominance.cpp
@@ -72,7 +72,7 @@ bool DominanceInfoBase<IsPostDom>::properlyDominates(Block *a, Block *b) {
if (regionA != regionB) {
Instruction *bAncestor;
do {
- bAncestor = regionB->getContainingInst();
+ bAncestor = regionB->getContainingOp();
// If 'bAncestor' is the top level function, then 'a' is a block
// that post dominates 'b'.
if (!bAncestor)
@@ -122,7 +122,7 @@ bool DominanceInfo::properlyDominates(Instruction *a, Instruction *b) {
/// Return true if value A properly dominates instruction B.
bool DominanceInfo::properlyDominates(Value *a, Instruction *b) {
- if (auto *aInst = a->getDefiningInst())
+ if (auto *aInst = a->getDefiningOp())
return properlyDominates(aInst, b);
// block arguments properly dominate all instructions in their own block, so
diff --git a/mlir/lib/Analysis/LoopAnalysis.cpp b/mlir/lib/Analysis/LoopAnalysis.cpp
index ab2598985db..eb272389957 100644
--- a/mlir/lib/Analysis/LoopAnalysis.cpp
+++ b/mlir/lib/Analysis/LoopAnalysis.cpp
@@ -54,7 +54,7 @@ void mlir::buildTripCountMapAndOperands(
int64_t loopSpan;
int64_t step = forOp.getStep();
- FuncBuilder b(forOp.getInstruction());
+ FuncBuilder b(forOp.getOperation());
if (forOp.hasConstantBounds()) {
int64_t lb = forOp.getConstantLowerBound();
@@ -101,7 +101,7 @@ void mlir::buildTripCountMapAndOperands(
// simplification, and canonicalization above.
for (auto *v : ubs)
if (v->use_empty())
- v->getDefiningInst()->erase();
+ v->getDefiningOp()->erase();
if (lb.use_empty())
lb.erase();
}
@@ -280,7 +280,7 @@ using VectorizableInstFun = std::function<bool(AffineForOp, Instruction &)>;
static bool isVectorizableLoopWithCond(AffineForOp loop,
VectorizableInstFun isVectorizableInst) {
- auto *forInst = loop.getInstruction();
+ auto *forInst = loop.getOperation();
if (!matcher::isParallelLoop(*forInst) &&
!matcher::isReductionLoop(*forInst)) {
return false;
@@ -361,12 +361,12 @@ bool mlir::isVectorizableLoop(AffineForOp loop) {
// violation when we have the support.
bool mlir::isInstwiseShiftValid(AffineForOp forOp, ArrayRef<uint64_t> shifts) {
auto *forBody = forOp.getBody();
- assert(shifts.size() == forBody->getInstructions().size());
+ assert(shifts.size() == forBody->getOperations().size());
// Work backwards over the body of the block so that the shift of a use's
// ancestor instruction in the block gets recorded before it's looked up.
DenseMap<Instruction *, uint64_t> forBodyShift;
- for (auto it : llvm::enumerate(llvm::reverse(forBody->getInstructions()))) {
+ for (auto it : llvm::enumerate(llvm::reverse(forBody->getOperations()))) {
auto &inst = it.value();
// Get the index of the current instruction, note that we are iterating in
diff --git a/mlir/lib/Analysis/SliceAnalysis.cpp b/mlir/lib/Analysis/SliceAnalysis.cpp
index e1b3c63d08b..82320bd26ff 100644
--- a/mlir/lib/Analysis/SliceAnalysis.cpp
+++ b/mlir/lib/Analysis/SliceAnalysis.cpp
@@ -104,7 +104,7 @@ static void getBackwardSliceImpl(Instruction *inst,
}
for (auto *operand : inst->getOperands()) {
- auto *inst = operand->getDefiningInst();
+ auto *inst = operand->getDefiningOp();
if (backwardSlice->count(inst) == 0) {
getBackwardSliceImpl(inst, backwardSlice, filter);
}
diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index a564592b2dd..a9c22d62f0b 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -73,7 +73,7 @@ ComputationSliceState::getAsConstraints(FlatAffineConstraints *cst) {
assert(cst->containsId(*value) && "value expected to be present");
if (isValidSymbol(value)) {
// Check if the symbol is a constant.
- if (auto *inst = value->getDefiningInst()) {
+ if (auto *inst = value->getDefiningOp()) {
if (auto constOp = inst->dyn_cast<ConstantIndexOp>()) {
cst->setIdToConstant(*value, constOp.getValue());
}
@@ -242,7 +242,7 @@ LogicalResult MemRefRegion::compute(Instruction *inst, unsigned loopDepth,
auto *symbol = operand;
assert(isValidSymbol(symbol));
// Check if the symbol is a constant.
- if (auto *inst = symbol->getDefiningInst()) {
+ if (auto *inst = symbol->getDefiningOp()) {
if (auto constOp = inst->dyn_cast<ConstantIndexOp>()) {
cst.setIdToConstant(*symbol, constOp.getValue());
}
@@ -374,7 +374,7 @@ LogicalResult mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
std::is_same<LoadOrStoreOpPointer, StoreOp>::value,
"argument should be either a LoadOp or a StoreOp");
- Instruction *opInst = loadOrStoreOp.getInstruction();
+ Instruction *opInst = loadOrStoreOp.getOperation();
MemRefRegion region(opInst->getLoc());
if (failed(region.compute(opInst, /*loopDepth=*/0)))
@@ -437,7 +437,7 @@ static void findInstPosition(Instruction *inst, Block *limitBlock,
// rely on linear scans.
int instPosInBlock = std::distance(block->begin(), inst->getIterator());
positions->push_back(instPosInBlock);
- inst = block->getContainingInst();
+ inst = block->getContainingOp();
block = inst->getBlock();
}
std::reverse(positions->begin(), positions->end());
@@ -583,7 +583,7 @@ AffineForOp mlir::insertBackwardComputationSlice(
// Find the inst block positions of 'srcOpInst' within 'srcLoopIVs'.
SmallVector<unsigned, 4> positions;
// TODO(andydavis): This code is incorrect since srcLoopIVs can be 0-d.
- findInstPosition(srcOpInst, srcLoopIVs[0].getInstruction()->getBlock(),
+ findInstPosition(srcOpInst, srcLoopIVs[0].getOperation()->getBlock(),
&positions);
// Clone src loop nest and insert it a the beginning of the instruction block
@@ -591,7 +591,7 @@ AffineForOp mlir::insertBackwardComputationSlice(
auto dstAffineForOp = dstLoopIVs[dstLoopDepth - 1];
FuncBuilder b(dstAffineForOp.getBody(), dstAffineForOp.getBody()->begin());
auto sliceLoopNest =
- b.clone(*srcLoopIVs[0].getInstruction())->cast<AffineForOp>();
+ b.clone(*srcLoopIVs[0].getOperation())->cast<AffineForOp>();
Instruction *sliceInst =
getInstAtPosition(positions, /*level=*/0, sliceLoopNest.getBody());
@@ -670,7 +670,7 @@ unsigned mlir::getNumCommonSurroundingLoops(Instruction &A, Instruction &B) {
unsigned minNumLoops = std::min(loopsA.size(), loopsB.size());
unsigned numCommonLoops = 0;
for (unsigned i = 0; i < minNumLoops; ++i) {
- if (loopsA[i].getInstruction() != loopsB[i].getInstruction())
+ if (loopsA[i].getOperation() != loopsB[i].getOperation())
break;
++numCommonLoops;
}
@@ -727,7 +727,7 @@ static Optional<int64_t> getMemoryFootprintBytes(Block &block,
Optional<int64_t> mlir::getMemoryFootprintBytes(AffineForOp forOp,
int memorySpace) {
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
return ::getMemoryFootprintBytes(
*forInst->getBlock(), Block::iterator(forInst),
std::next(Block::iterator(forInst)), memorySpace);
@@ -737,7 +737,7 @@ Optional<int64_t> mlir::getMemoryFootprintBytes(AffineForOp forOp,
/// at 'forOp'.
void mlir::getSequentialLoops(
AffineForOp forOp, llvm::SmallDenseSet<Value *, 8> *sequentialLoops) {
- forOp.getInstruction()->walk([&](Instruction *inst) {
+ forOp.getOperation()->walk([&](Instruction *inst) {
if (auto innerFor = inst->dyn_cast<AffineForOp>())
if (!isLoopParallel(innerFor))
sequentialLoops->insert(innerFor.getInductionVar());
@@ -748,13 +748,13 @@ void mlir::getSequentialLoops(
bool mlir::isLoopParallel(AffineForOp forOp) {
// Collect all load and store ops in loop nest rooted at 'forOp'.
SmallVector<Instruction *, 8> loadAndStoreOpInsts;
- forOp.getInstruction()->walk([&](Instruction *opInst) {
+ forOp.getOperation()->walk([&](Instruction *opInst) {
if (opInst->isa<LoadOp>() || opInst->isa<StoreOp>())
loadAndStoreOpInsts.push_back(opInst);
});
// Dep check depth would be number of enclosing loops + 1.
- unsigned depth = getNestingDepth(*forOp.getInstruction()) + 1;
+ unsigned depth = getNestingDepth(*forOp.getOperation()) + 1;
// Check dependences between all pairs of ops in 'loadAndStoreOpInsts'.
for (auto *srcOpInst : loadAndStoreOpInsts) {
diff --git a/mlir/lib/Analysis/Verifier.cpp b/mlir/lib/Analysis/Verifier.cpp
index 781a3cde9fe..f211417b798 100644
--- a/mlir/lib/Analysis/Verifier.cpp
+++ b/mlir/lib/Analysis/Verifier.cpp
@@ -225,7 +225,7 @@ static bool canBlockHaveNoTerminator(Block &block) {
// Allow the first block of an operation region to have no terminator if it is
// the only block in the region.
auto *parentList = block.getParent();
- return parentList->getContainingInst() &&
+ return parentList->getContainingOp() &&
std::next(parentList->begin()) == parentList->end();
}
@@ -295,7 +295,7 @@ bool FuncVerifier::verifyOperation(Instruction &op) {
if (!attr.first.strref().contains('.'))
continue;
if (auto *dialect = getDialectForAttribute(attr, op))
- if (dialect->verifyInstructionAttribute(&op, attr))
+ if (dialect->verifyOperationAttribute(&op, attr))
return true;
}
@@ -332,7 +332,7 @@ bool FuncVerifier::verifyInstDominance(Instruction &inst) {
inst.emitError("operand #" + Twine(operandNo) +
" does not dominate this use");
- if (auto *useInst = op->getDefiningInst())
+ if (auto *useInst = op->getDefiningOp())
useInst->emitNote("operand defined here");
return true;
}
diff --git a/mlir/lib/EDSC/Builders.cpp b/mlir/lib/EDSC/Builders.cpp
index 191b789dec6..e991817b6d7 100644
--- a/mlir/lib/EDSC/Builders.cpp
+++ b/mlir/lib/EDSC/Builders.cpp
@@ -87,7 +87,7 @@ mlir::edsc::ValueHandle::createComposedAffineApply(AffineMap map,
Instruction *inst =
makeComposedAffineApply(ScopedContext::getBuilder(),
ScopedContext::getLocation(), map, operands)
- .getInstruction();
+ .getOperation();
assert(inst->getNumResults() == 1 && "Not a single result AffineApply");
return ValueHandle(inst->getResult(0));
}
@@ -145,8 +145,8 @@ static llvm::Optional<ValueHandle> emitStaticFor(ArrayRef<ValueHandle> lbs,
if (lbs.size() != 1 || ubs.size() != 1)
return llvm::Optional<ValueHandle>();
- auto *lbDef = lbs.front().getValue()->getDefiningInst();
- auto *ubDef = ubs.front().getValue()->getDefiningInst();
+ auto *lbDef = lbs.front().getValue()->getDefiningOp();
+ auto *ubDef = ubs.front().getValue()->getDefiningOp();
if (!lbDef || !ubDef)
return llvm::Optional<ValueHandle>();
@@ -267,7 +267,7 @@ categorizeValueByAffineType(MLIRContext *context, Value *val, unsigned &numDims,
unsigned &numSymbols) {
AffineExpr d;
Value *resultVal = nullptr;
- auto *inst = val->getDefiningInst();
+ auto *inst = val->getDefiningOp();
auto constant = inst ? inst->dyn_cast<ConstantIndexOp>() : ConstantIndexOp();
if (constant) {
d = getAffineConstantExpr(constant.getValue(), context);
diff --git a/mlir/lib/EDSC/MLIREmitter.cpp b/mlir/lib/EDSC/MLIREmitter.cpp
index 49b544a9b77..6c6262c2790 100644
--- a/mlir/lib/EDSC/MLIREmitter.cpp
+++ b/mlir/lib/EDSC/MLIREmitter.cpp
@@ -46,13 +46,13 @@ using namespace mlir::edsc;
using namespace mlir::edsc::detail;
static void printDefininingStatement(llvm::raw_ostream &os, Value &v) {
- auto *inst = v.getDefiningInst();
+ auto *inst = v.getDefiningOp();
if (inst) {
inst->print(os);
return;
}
if (auto forInst = getForInductionVarOwner(&v)) {
- forInst.getInstruction()->print(os);
+ forInst.getOperation()->print(os);
} else if (auto *bbArg = dyn_cast<BlockArgument>(&v)) {
os << "block_argument";
} else {
@@ -84,7 +84,7 @@ MLIREmitter &mlir::edsc::MLIREmitter::bind(Bindable e, Value *v) {
static void checkAffineProvenance(ArrayRef<Value *> values) {
for (Value *v : values) {
- auto *def = v->getDefiningInst();
+ auto *def = v->getDefiningOp();
(void)def;
// There may be no defining instruction if the value is a function
// argument. We accept such values.
@@ -100,8 +100,8 @@ static AffineForOp emitStaticFor(FuncBuilder &builder, Location loc,
if (lbs.size() != 1 || ubs.size() != 1)
return AffineForOp();
- auto *lbDef = lbs.front()->getDefiningInst();
- auto *ubDef = ubs.front()->getDefiningInst();
+ auto *lbDef = lbs.front()->getDefiningOp();
+ auto *ubDef = ubs.front()->getDefiningOp();
if (!lbDef || !ubDef)
return AffineForOp();
@@ -165,8 +165,7 @@ Value *mlir::edsc::MLIREmitter::emitExpr(Expr e) {
checkAffineProvenance(ubs);
// Step must be a static constant.
- auto step =
- stepExpr->getDefiningInst()->cast<ConstantIndexOp>().getValue();
+ auto step = stepExpr->getDefiningOp()->cast<ConstantIndexOp>().getValue();
// Special case with more concise emitted code for static bounds.
AffineForOp forOp = emitStaticFor(*builder, location, lbs, ubs, step);
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index a2c259e3377..de6654cf532 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -138,7 +138,7 @@ private:
void recordTypeReference(Type ty) { usedTypes.insert(ty); }
// Visit functions.
- void visitInstruction(Instruction *inst);
+ void visitOperation(Operation *inst);
void visitType(Type type);
void visitAttribute(Attribute attr);
@@ -189,7 +189,7 @@ void ModuleState::visitAttribute(Attribute attr) {
}
}
-void ModuleState::visitInstruction(Instruction *inst) {
+void ModuleState::visitOperation(Operation *inst) {
// Visit all the types used in the operation.
for (auto *operand : inst->getOperands())
visitType(operand->getType());
@@ -270,7 +270,7 @@ void ModuleState::initialize(Module *module) {
for (auto &fn : *module) {
visitType(fn.getType());
- fn.walk([&](Instruction *op) { ModuleState::visitInstruction(op); });
+ fn.walk([&](Operation *op) { ModuleState::visitOperation(op); });
}
// Initialize the symbol aliases.
@@ -1059,11 +1059,11 @@ public:
void printFunctionSignature();
// Methods to print instructions.
- void print(Instruction *inst);
+ void print(Operation *inst);
void print(Block *block, bool printBlockArgs = true);
- void printOperation(Instruction *op);
- void printGenericOp(Instruction *op);
+ void printOperation(Operation *op);
+ void printGenericOp(Operation *op);
// Implement OpAsmPrinter.
raw_ostream &getStream() const { return os; }
@@ -1106,7 +1106,7 @@ public:
return it != blockIDs.end() ? it->second : ~0U;
}
- void printSuccessorAndUseList(Instruction *term, unsigned index) override;
+ void printSuccessorAndUseList(Operation *term, unsigned index) override;
/// Print a region.
void printRegion(Region &blocks, bool printEntryBlockArgs) override {
@@ -1196,7 +1196,7 @@ void FunctionPrinter::numberValueID(Value *value) {
llvm::raw_svector_ostream specialName(specialNameBuffer);
// Give constant integers special names.
- if (auto *op = value->getDefiningInst()) {
+ if (auto *op = value->getDefiningOp()) {
Attribute cst;
if (m_Constant(&cst).match(op)) {
Type type = op->getResult(0)->getType();
@@ -1236,7 +1236,7 @@ void FunctionPrinter::numberValueID(Value *value) {
// Otherwise number it normally.
valueIDs[value] = nextValueID++;
return;
- case Value::Kind::InstResult:
+ case Value::Kind::OpResult:
// This is an uninteresting result, give it a boring number and be
// done with it.
valueIDs[value] = nextValueID++;
@@ -1380,14 +1380,14 @@ void FunctionPrinter::print(Block *block, bool printBlockArgs) {
currentIndent += indentWidth;
- for (auto &inst : block->getInstructions()) {
+ for (auto &inst : block->getOperations()) {
print(&inst);
os << '\n';
}
currentIndent -= indentWidth;
}
-void FunctionPrinter::print(Instruction *inst) {
+void FunctionPrinter::print(Operation *inst) {
os.indent(currentIndent);
printOperation(inst);
printTrailingLocation(inst->getLoc());
@@ -1400,12 +1400,12 @@ void FunctionPrinter::printValueID(Value *value, bool printResultNo) const {
// If this is a reference to the result of a multi-result instruction or
// instruction, print out the # identifier and make sure to map our lookup
// to the first result of the instruction.
- if (auto *result = dyn_cast<InstResult>(value)) {
+ if (auto *result = dyn_cast<OpResult>(value)) {
if (result->getOwner()->getNumResults() != 1) {
resultNo = result->getResultNumber();
lookupValue = result->getOwner()->getResult(0);
}
- } else if (auto *result = dyn_cast<InstResult>(value)) {
+ } else if (auto *result = dyn_cast<OpResult>(value)) {
if (result->getOwner()->getNumResults() != 1) {
resultNo = result->getResultNumber();
lookupValue = result->getOwner()->getResult(0);
@@ -1431,7 +1431,7 @@ void FunctionPrinter::printValueID(Value *value, bool printResultNo) const {
os << '#' << resultNo;
}
-void FunctionPrinter::printOperation(Instruction *op) {
+void FunctionPrinter::printOperation(Operation *op) {
if (op->getNumResults()) {
printValueID(op->getResult(0), /*printResultNo=*/false);
os << " = ";
@@ -1451,7 +1451,7 @@ void FunctionPrinter::printOperation(Instruction *op) {
printGenericOp(op);
}
-void FunctionPrinter::printGenericOp(Instruction *op) {
+void FunctionPrinter::printGenericOp(Operation *op) {
os << '"';
printEscapedString(op->getName().getStringRef(), os);
os << "\"(";
@@ -1504,7 +1504,7 @@ void FunctionPrinter::printGenericOp(Instruction *op) {
printRegion(region, /*printEntryBlockArgs=*/true);
}
-void FunctionPrinter::printSuccessorAndUseList(Instruction *term,
+void FunctionPrinter::printSuccessorAndUseList(Operation *term,
unsigned index) {
printBlockName(term->getSuccessor(index));
@@ -1586,14 +1586,14 @@ void Value::print(raw_ostream &os) {
// TODO: Improve this.
os << "<block argument>\n";
return;
- case Value::Kind::InstResult:
- return getDefiningInst()->print(os);
+ case Value::Kind::OpResult:
+ return getDefiningOp()->print(os);
}
}
void Value::dump() { print(llvm::errs()); }
-void Instruction::print(raw_ostream &os) {
+void Operation::print(raw_ostream &os) {
auto *function = getFunction();
if (!function) {
os << "<<UNLINKED INSTRUCTION>>\n";
@@ -1605,7 +1605,7 @@ void Instruction::print(raw_ostream &os) {
FunctionPrinter(function, modulePrinter).print(this);
}
-void Instruction::dump() {
+void Operation::dump() {
print(llvm::errs());
llvm::errs() << "\n";
}
diff --git a/mlir/lib/IR/Block.cpp b/mlir/lib/IR/Block.cpp
index 2a18260a378..cd5816009a5 100644
--- a/mlir/lib/IR/Block.cpp
+++ b/mlir/lib/IR/Block.cpp
@@ -37,22 +37,22 @@ unsigned BlockArgument::getArgNumber() {
//===----------------------------------------------------------------------===//
Block::~Block() {
- assert(!verifyInstOrder() && "Expected valid instruction ordering.");
+ assert(!verifyInstOrder() && "Expected valid operation ordering.");
clear();
llvm::DeleteContainerPointers(arguments);
}
-/// Returns the closest surrounding instruction that contains this block or
-/// nullptr if this is a top-level instruction block.
-Instruction *Block::getContainingInst() {
- return getParent() ? getParent()->getContainingInst() : nullptr;
+/// Returns the closest surrounding operation that contains this block or
+/// nullptr if this is a top-level operation block.
+Operation *Block::getContainingOp() {
+ return getParent() ? getParent()->getContainingOp() : nullptr;
}
Function *Block::getFunction() {
Block *block = this;
- while (auto *inst = block->getContainingInst()) {
- block = inst->getBlock();
+ while (auto *op = block->getContainingOp()) {
+ block = op->getBlock();
if (!block)
return nullptr;
}
@@ -75,13 +75,13 @@ void Block::eraseFromFunction() {
getFunction()->getBlocks().erase(this);
}
-/// Returns 'inst' if 'inst' lies in this block, or otherwise finds the
-/// ancestor instruction of 'inst' that lies in this block. Returns nullptr if
+/// Returns 'op' if 'op' lies in this block, or otherwise finds the
+/// ancestor operation of 'op' that lies in this block. Returns nullptr if
/// the latter fails.
-Instruction *Block::findAncestorInstInBlock(Instruction &inst) {
- // Traverse up the instruction hierarchy starting from the owner of operand to
- // find the ancestor instruction that resides in the block of 'forInst'.
- auto *currInst = &inst;
+Operation *Block::findAncestorInstInBlock(Operation &op) {
+ // Traverse up the operation hierarchy starting from the owner of operand to
+ // find the ancestor operation that resides in the block of 'forInst'.
+ auto *currInst = &op;
while (currInst->getBlock() != this) {
currInst = currInst->getParentInst();
if (!currInst)
@@ -90,36 +90,35 @@ Instruction *Block::findAncestorInstInBlock(Instruction &inst) {
return currInst;
}
-/// This drops all operand uses from instructions within this block, which is
+/// This drops all operand uses from operations within this block, which is
/// an essential step in breaking cyclic dependences between references when
/// they are to be deleted.
void Block::dropAllReferences() {
- for (Instruction &i : *this)
+ for (Operation &i : *this)
i.dropAllReferences();
}
void Block::dropAllDefinedValueUses() {
for (auto *arg : getArguments())
arg->dropAllUses();
- for (auto &inst : *this)
- inst.dropAllDefinedValueUses();
+ for (auto &op : *this)
+ op.dropAllDefinedValueUses();
dropAllUses();
}
-/// Verifies the current ordering of child instructions. Returns false if the
+/// Verifies the current ordering of child operations. Returns false if the
/// order is valid, true otherwise.
bool Block::verifyInstOrder() {
// The order is already known to be invalid.
if (!isInstOrderValid())
return false;
- // The order is valid if there are less than 2 instructions.
- if (instructions.empty() ||
- std::next(instructions.begin()) == instructions.end())
+ // The order is valid if there are less than 2 operations.
+ if (operations.empty() || std::next(operations.begin()) == operations.end())
return false;
- Instruction *prev = nullptr;
+ Operation *prev = nullptr;
for (auto &i : *this) {
- // The previous instruction must have a smaller order index than the next as
+ // The previous operation must have a smaller order index than the next as
// it appears earlier in the list.
if (prev && prev->orderIndex >= i.orderIndex)
return true;
@@ -128,15 +127,15 @@ bool Block::verifyInstOrder() {
return false;
}
-/// Recomputes the ordering of child instructions within the block.
+/// Recomputes the ordering of child operations within the block.
void Block::recomputeInstOrder() {
parentValidInstOrderPair.setInt(true);
// TODO(riverriddle) Have non-congruent indices to reduce the number of times
// an insert invalidates the list.
unsigned orderIndex = 0;
- for (auto &inst : *this)
- inst.orderIndex = orderIndex++;
+ for (auto &op : *this)
+ op.orderIndex = orderIndex++;
}
Block *PredecessorIterator::operator*() const {
@@ -190,9 +189,9 @@ void Block::eraseArgument(unsigned index) {
// Terminator management
//===----------------------------------------------------------------------===//
-/// Get the terminator instruction of this block. This function asserts that
-/// the block has a valid terminator instruction.
-Instruction *Block::getTerminator() {
+/// Get the terminator operation of this block. This function asserts that
+/// the block has a valid terminator operation.
+Operation *Block::getTerminator() {
assert(!empty() && !back().isKnownNonTerminator());
return &back();
}
@@ -226,42 +225,42 @@ Block *Block::getSinglePredecessor() {
}
//===----------------------------------------------------------------------===//
-// Instruction Walkers
+// Operation Walkers
//===----------------------------------------------------------------------===//
-void Block::walk(const std::function<void(Instruction *)> &callback) {
+void Block::walk(const std::function<void(Operation *)> &callback) {
walk(begin(), end(), callback);
}
void Block::walk(Block::iterator begin, Block::iterator end,
- const std::function<void(Instruction *)> &callback) {
- // Walk the instructions within this block.
- for (auto &inst : llvm::make_early_inc_range(llvm::make_range(begin, end)))
- inst.walk(callback);
+ const std::function<void(Operation *)> &callback) {
+ // Walk the operations within this block.
+ for (auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
+ op.walk(callback);
}
-void Block::walkPostOrder(const std::function<void(Instruction *)> &callback) {
+void Block::walkPostOrder(const std::function<void(Operation *)> &callback) {
walkPostOrder(begin(), end(), callback);
}
-/// Walk the instructions in the specified [begin, end) range of this block
+/// Walk the operations in the specified [begin, end) range of this block
/// in postorder, calling the callback for each operation.
void Block::walkPostOrder(Block::iterator begin, Block::iterator end,
- const std::function<void(Instruction *)> &callback) {
- // Walk the instructions within this block.
- for (auto &inst : llvm::make_early_inc_range(llvm::make_range(begin, end)))
- inst.walkPostOrder(callback);
+ const std::function<void(Operation *)> &callback) {
+ // Walk the operations within this block.
+ for (auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
+ op.walkPostOrder(callback);
}
//===----------------------------------------------------------------------===//
// Other
//===----------------------------------------------------------------------===//
-/// Split the block into two blocks before the specified instruction or
+/// Split the block into two blocks before the specified operation or
/// iterator.
///
-/// Note that all instructions BEFORE the specified iterator stay as part of
-/// the original basic block, and the rest of the instructions in the original
+/// Note that all operations BEFORE the specified iterator stay as part of
+/// the original basic block, and the rest of the operations in the original
/// block are moved to the new block, including the old terminator. The
/// original block is left without a terminator.
///
@@ -275,8 +274,8 @@ Block *Block::splitBlock(iterator splitBefore) {
// Move all of the operations from the split point to the end of the function
// into the new block.
- newBB->getInstructions().splice(newBB->end(), getInstructions(), splitBefore,
- end());
+ newBB->getOperations().splice(newBB->end(), getOperations(), splitBefore,
+ end());
return newBB;
}
@@ -286,18 +285,18 @@ Block *Block::splitBlock(iterator splitBefore) {
Region::Region(Function *container) : container(container) {}
-Region::Region(Instruction *container) : container(container) {}
+Region::Region(Operation *container) : container(container) {}
Region::~Region() {
- // Instructions may have cyclic references, which need to be dropped before we
+ // Operations may have cyclic references, which need to be dropped before we
// can start deleting them.
for (auto &bb : *this)
bb.dropAllReferences();
}
-Instruction *Region::getContainingInst() {
+Operation *Region::getContainingOp() {
assert(!container.isNull() && "no container");
- return container.dyn_cast<Instruction *>();
+ return container.dyn_cast<Operation *>();
}
Function *Region::getContainingFunction() {
@@ -327,20 +326,20 @@ void Region::cloneInto(Region *dest, BlockAndValueMapping &mapper,
if (!mapper.contains(arg))
mapper.map(arg, newBlock->addArgument(arg->getType()));
- // Clone and remap the instructions within this block.
- for (auto &inst : block)
- newBlock->push_back(inst.clone(mapper, context));
+ // Clone and remap the operations within this block.
+ for (auto &op : block)
+ newBlock->push_back(op.clone(mapper, context));
dest->push_back(newBlock);
}
// Now that each of the blocks have been cloned, go through and remap the
- // operands of each of the instructions.
- auto remapOperands = [&](Instruction *inst) {
- for (auto &instOp : inst->getInstOperands())
+ // 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 &succOp : inst->getBlockOperands())
+ for (auto &succOp : op->getBlockOperands())
if (auto *mappedOp = mapper.lookupOrNull(succOp.get()))
succOp.set(mappedOp);
};
@@ -363,18 +362,18 @@ void llvm::ilist_traits<::mlir::Block>::addNodeToList(Block *block) {
block->parentValidInstOrderPair.setPointer(getContainingRegion());
}
-/// This is a trait method invoked when an instruction is removed from a
+/// This is a trait method invoked when an operation is removed from a
/// region. We keep the region pointer up to date.
void llvm::ilist_traits<::mlir::Block>::removeNodeFromList(Block *block) {
assert(block->getParent() && "not already in a region!");
block->parentValidInstOrderPair.setPointer(nullptr);
}
-/// This is a trait method invoked when an instruction is moved from one block
+/// This is a trait method invoked when an operation is moved from one block
/// to another. We keep the block pointer up to date.
void llvm::ilist_traits<::mlir::Block>::transferNodesFromList(
ilist_traits<Block> &otherList, block_iterator first, block_iterator last) {
- // If we are transferring instructions within the same function, the parent
+ // If we are transferring operations within the same function, the parent
// pointer doesn't need to be updated.
auto *curParent = getContainingRegion();
if (curParent == otherList.getContainingRegion())
diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp
index 8ec883ae274..f4d532a482f 100644
--- a/mlir/lib/IR/Builders.cpp
+++ b/mlir/lib/IR/Builders.cpp
@@ -296,7 +296,7 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) {
}
//===----------------------------------------------------------------------===//
-// Instructions.
+// Operations.
//===----------------------------------------------------------------------===//
/// Add new block and set the insertion point to the end of it. If an
@@ -318,18 +318,18 @@ Block *FuncBuilder::createBlock(Block *insertBefore) {
}
/// Create an operation given the fields represented as an OperationState.
-Instruction *FuncBuilder::createOperation(const OperationState &state) {
+Operation *FuncBuilder::createOperation(const OperationState &state) {
assert(block && "createOperation() called without setting builder's block");
unsigned numRegions = state.regions.size();
- auto *op = Instruction::create(
- state.location, state.name, state.operands, state.types, state.attributes,
- state.successors, numRegions, state.resizableOperandList, context);
+ auto *op = Operation::create(state.location, state.name, state.operands,
+ state.types, state.attributes, state.successors,
+ numRegions, state.resizableOperandList, context);
for (unsigned i = 0; i < numRegions; ++i)
if (state.regions[i])
op->getRegion(i).takeBody(*state.regions[i]);
- block->getInstructions().insert(insertPoint, op);
+ block->getOperations().insert(insertPoint, op);
return op;
}
diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp
index 585d01e0fb1..fa9328f869e 100644
--- a/mlir/lib/IR/Function.cpp
+++ b/mlir/lib/IR/Function.cpp
@@ -91,7 +91,7 @@ void llvm::ilist_traits<Function>::removeNodeFromList(Function *function) {
function->module = nullptr;
}
-/// This is a trait method invoked when an instruction is moved from one block
+/// This is a trait method invoked when an operation is moved from one block
/// to another. We keep the block pointer up to date.
void llvm::ilist_traits<Function>::transferNodesFromList(
ilist_traits<Function> &otherList, function_iterator first,
@@ -115,7 +115,7 @@ void Function::erase() {
getModule()->getFunctions().erase(this);
}
-/// Emit a note about this instruction, reporting up to any diagnostic
+/// Emit a note about this operation, reporting up to any diagnostic
/// handlers that may be listening.
void Function::emitNote(const Twine &message) {
getContext()->emitDiagnostic(getLoc(), message,
@@ -209,14 +209,13 @@ void Function::addEntryBlock() {
entry->addArguments(type.getInputs());
}
-void Function::walk(const std::function<void(Instruction *)> &callback) {
+void Function::walk(const std::function<void(Operation *)> &callback) {
// Walk each of the blocks within the function.
for (auto &block : getBlocks())
block.walk(callback);
}
-void Function::walkPostOrder(
- const std::function<void(Instruction *)> &callback) {
+void Function::walkPostOrder(const std::function<void(Operation *)> &callback) {
// Walk each of the blocks within the function.
for (auto &block : llvm::reverse(getBlocks()))
block.walkPostOrder(callback);
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 9db1f6ba964..aee0ac96917 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -624,7 +624,7 @@ auto MLIRContext::getDiagnosticHandler() -> DiagnosticHandlerTy {
/// This emits a diagnostic using the registered issue handle if present, or
/// with the default behavior if not. The MLIR compiler should not generally
-/// interact with this, it should use methods on Instruction instead.
+/// interact with this, it should use methods on Operation instead.
void MLIRContext::emitDiagnostic(Location location, const llvm::Twine &message,
DiagnosticKind kind) {
// Check to see if we are emitting a diagnostic on a fused location.
diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp
index 4d0222e598a..4bc8c3e2508 100644
--- a/mlir/lib/IR/Operation.cpp
+++ b/mlir/lib/IR/Operation.cpp
@@ -53,14 +53,14 @@ OperationName OperationName::getFromOpaquePointer(void *pointer) {
OpAsmParser::~OpAsmParser() {}
//===----------------------------------------------------------------------===//
-// InstResult
+// OpResult
//===----------------------------------------------------------------------===//
/// Return the result number of this result.
-unsigned InstResult::getResultNumber() {
+unsigned OpResult::getResultNumber() {
// Results are always stored consecutively, so use pointer subtraction to
// figure out what number this is.
- return this - &getOwner()->getInstResults()[0];
+ return this - &getOwner()->getOpResults()[0];
}
//===----------------------------------------------------------------------===//
@@ -112,7 +112,7 @@ Operation *Operation::create(Location location, OperationName name,
unsigned numOperands = operands.size() - numSuccessors;
// Compute the byte size for the operation and the operand storage.
- auto byteSize = totalSizeToAlloc<InstResult, BlockOperand, unsigned, Region,
+ auto byteSize = totalSizeToAlloc<OpResult, BlockOperand, unsigned, Region,
detail::OperandStorage>(
resultTypes.size(), numSuccessors, numSuccessors, numRegions,
/*detail::OperandStorage*/ 1);
@@ -137,9 +137,9 @@ Operation *Operation::create(Location location, OperationName name,
new (&op->getOperandStorage())
detail::OperandStorage(numOperands, resizableOperandList);
- auto instResults = op->getInstResults();
+ auto instResults = op->getOpResults();
for (unsigned i = 0, e = resultTypes.size(); i != e; ++i)
- new (&instResults[i]) InstResult(resultTypes[i], op);
+ new (&instResults[i]) OpResult(resultTypes[i], op);
auto InstOperands = op->getInstOperands();
@@ -215,8 +215,8 @@ Operation::~Operation() {
// Explicitly run the destructors for the operands and results.
getOperandStorage().~OperandStorage();
- for (auto &result : getInstResults())
- result.~InstResult();
+ for (auto &result : getOpResults())
+ result.~OpResult();
// Explicitly run the destructors for the successors.
for (auto &successor : getBlockOperands())
@@ -261,7 +261,7 @@ Dialect *Operation::getDialect() {
}
Operation *Operation::getParentInst() {
- return block ? block->getContainingInst() : nullptr;
+ return block ? block->getContainingOp() : nullptr;
}
Function *Operation::getFunction() {
@@ -394,8 +394,7 @@ void llvm::ilist_traits<::mlir::Operation>::removeNodeFromList(Operation *op) {
/// This is a trait method invoked when a operation is moved from one block
/// to another. We keep the block pointer up to date.
void llvm::ilist_traits<::mlir::Operation>::transferNodesFromList(
- ilist_traits<Operation> &otherList, inst_iterator first,
- inst_iterator last) {
+ ilist_traits<Operation> &otherList, op_iterator first, op_iterator last) {
Block *curParent = getContainingBlock();
// Invalidate the ordering of the parent block.
@@ -415,7 +414,7 @@ void llvm::ilist_traits<::mlir::Operation>::transferNodesFromList(
/// all of them.
void Operation::erase() {
assert(getBlock() && "Operation has no block");
- getBlock()->getInstructions().erase(this);
+ getBlock()->getOperations().erase(this);
}
/// Unlink this operation from its current block and insert it right before
@@ -429,8 +428,8 @@ void Operation::moveBefore(Operation *existingInst) {
/// it right before `iterator` in the specified basic block.
void Operation::moveBefore(Block *block,
llvm::iplist<Operation>::iterator iterator) {
- block->getInstructions().splice(iterator, getBlock()->getInstructions(),
- getIterator());
+ block->getOperations().splice(iterator, getBlock()->getOperations(),
+ getIterator());
}
/// This drops all operand uses from this operation, which is an essential
@@ -451,7 +450,7 @@ void Operation::dropAllReferences() {
/// This drops all uses of any values defined by this operation or its nested
/// regions, wherever they are located.
void Operation::dropAllDefinedValueUses() {
- for (auto &val : getInstResults())
+ for (auto &val : getOpResults())
val.dropAllUses();
for (auto &region : getRegions())
@@ -620,32 +619,32 @@ bool OpState::parse(OpAsmParser *parser, OperationState *result) {
}
// The fallback for the printer is to print in the generic assembly form.
-void OpState::print(OpAsmPrinter *p) { p->printGenericOp(getInstruction()); }
+void OpState::print(OpAsmPrinter *p) { p->printGenericOp(getOperation()); }
/// Emit an error about fatal conditions with this operation, reporting up to
/// any diagnostic handlers that may be listening. NOTE: This may terminate
/// the containing application, only use when the IR is in an inconsistent
/// state.
bool OpState::emitError(const Twine &message) {
- return getInstruction()->emitError(message);
+ return getOperation()->emitError(message);
}
/// Emit an error with the op name prefixed, like "'dim' op " which is
/// convenient for verifiers.
bool OpState::emitOpError(const Twine &message) {
- return getInstruction()->emitOpError(message);
+ return getOperation()->emitOpError(message);
}
/// Emit a warning about this operation, reporting up to any diagnostic
/// handlers that may be listening.
void OpState::emitWarning(const Twine &message) {
- getInstruction()->emitWarning(message);
+ getOperation()->emitWarning(message);
}
/// Emit a note about this operation, reporting up to any diagnostic
/// handlers that may be listening.
void OpState::emitNote(const Twine &message) {
- getInstruction()->emitNote(message);
+ getOperation()->emitNote(message);
}
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/IR/PatternMatch.cpp b/mlir/lib/IR/PatternMatch.cpp
index 404a0e9a2cb..7132408bfa5 100644
--- a/mlir/lib/IR/PatternMatch.cpp
+++ b/mlir/lib/IR/PatternMatch.cpp
@@ -46,18 +46,17 @@ void Pattern::anchor() {}
// RewritePattern and PatternRewriter implementation
//===----------------------------------------------------------------------===//
-void RewritePattern::rewrite(Instruction *op,
- std::unique_ptr<PatternState> state,
+void RewritePattern::rewrite(Operation *op, std::unique_ptr<PatternState> state,
PatternRewriter &rewriter) const {
rewrite(op, rewriter);
}
-void RewritePattern::rewrite(Instruction *op, PatternRewriter &rewriter) const {
+void RewritePattern::rewrite(Operation *op, PatternRewriter &rewriter) const {
llvm_unreachable("need to implement either matchAndRewrite or one of the "
"rewrite functions!");
}
-PatternMatchResult RewritePattern::match(Instruction *op) const {
+PatternMatchResult RewritePattern::match(Operation *op) const {
llvm_unreachable("need to implement either match or matchAndRewrite!");
}
@@ -71,7 +70,7 @@ PatternRewriter::~PatternRewriter() {
/// clients can specify a list of other nodes that this replacement may make
/// (perhaps transitively) dead. If any of those ops are dead, this will
/// remove them as well.
-void PatternRewriter::replaceOp(Instruction *op, ArrayRef<Value *> newValues,
+void PatternRewriter::replaceOp(Operation *op, ArrayRef<Value *> newValues,
ArrayRef<Value *> valuesToRemoveIfDead) {
// Notify the rewriter subclass that we're about to replace this root.
notifyRootReplaced(op);
@@ -91,8 +90,7 @@ void PatternRewriter::replaceOp(Instruction *op, ArrayRef<Value *> newValues,
/// op and newOp are known to have the same number of results, replace the
/// uses of op with uses of newOp
void PatternRewriter::replaceOpWithResultsOfAnotherOp(
- Instruction *op, Instruction *newOp,
- ArrayRef<Value *> valuesToRemoveIfDead) {
+ Operation *op, Operation *newOp, ArrayRef<Value *> valuesToRemoveIfDead) {
assert(op->getNumResults() == newOp->getNumResults() &&
"replacement op doesn't match results of original op");
if (op->getNumResults() == 1)
@@ -105,14 +103,14 @@ void PatternRewriter::replaceOpWithResultsOfAnotherOp(
/// This method is used as the final notification hook for patterns that end
/// up modifying the pattern root in place, by changing its operands. This is
-/// a minor efficiency win (it avoids creating a new instruction and removing
+/// a minor efficiency win (it avoids creating a new operation and removing
/// the old one) but also often allows simpler code in the client.
///
/// The opsToRemoveIfDead list is an optional list of nodes that the rewriter
/// should remove if they are dead at this point.
///
void PatternRewriter::updatedRootInPlace(
- Instruction *op, ArrayRef<Value *> valuesToRemoveIfDead) {
+ Operation *op, ArrayRef<Value *> valuesToRemoveIfDead) {
// Notify the rewriter subclass that we're about to replace this root.
notifyRootUpdated(op);
@@ -136,7 +134,7 @@ RewritePatternMatcher::RewritePatternMatcher(
}
/// Try to match the given operation to a pattern and rewrite it.
-void RewritePatternMatcher::matchAndRewrite(Instruction *op) {
+void RewritePatternMatcher::matchAndRewrite(Operation *op) {
for (auto &pattern : patterns) {
// Ignore patterns that are for the wrong root or are impossible to match.
if (pattern->getRootKind() != op->getName() ||
diff --git a/mlir/lib/IR/Value.cpp b/mlir/lib/IR/Value.cpp
index b369794770a..bd81784c512 100644
--- a/mlir/lib/IR/Value.cpp
+++ b/mlir/lib/IR/Value.cpp
@@ -20,10 +20,10 @@
#include "mlir/IR/Operation.h"
using namespace mlir;
-/// If this value is the result of an Instruction, return the instruction
-/// that defines it.
-Instruction *Value::getDefiningInst() {
- if (auto *result = dyn_cast<InstResult>(this))
+/// If this value is the result of an Operation, return the operation that
+/// defines it.
+Operation *Value::getDefiningOp() {
+ if (auto *result = dyn_cast<OpResult>(this))
return result->getOwner();
return nullptr;
}
@@ -33,8 +33,8 @@ Function *Value::getFunction() {
switch (getKind()) {
case Value::Kind::BlockArgument:
return cast<BlockArgument>(this)->getFunction();
- case Value::Kind::InstResult:
- return getDefiningInst()->getFunction();
+ case Value::Kind::OpResult:
+ return getDefiningOp()->getFunction();
}
}
diff --git a/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp b/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp
index 6bf460a5d24..222f4a657bd 100644
--- a/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp
+++ b/mlir/lib/LLVMIR/Transforms/ConvertToLLVMDialect.cpp
@@ -450,7 +450,7 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern<SourceOp> {
if (numResults == 0)
return {};
if (numResults == 1)
- return {newOp.getInstruction()->getResult(0)};
+ return {newOp.getOperation()->getResult(0)};
// Otherwise, it had been converted to an operation producing a structure.
// Extract individual results from the structure and return them as list.
@@ -460,7 +460,7 @@ struct OneToOneLLVMOpLowering : public LLVMLegalizationPattern<SourceOp> {
auto type = TypeConverter::convert(op->getResult(i)->getType(),
this->dialect.getLLVMModule());
results.push_back(rewriter.create<LLVM::ExtractValueOp>(
- op->getLoc(), type, newOp.getInstruction()->getResult(0),
+ op->getLoc(), type, newOp.getOperation()->getResult(0),
this->getIntegerArrayAttr(rewriter, i)));
}
return results;
diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp
index f5d55f73df9..62258595cd7 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -2534,7 +2534,7 @@ FunctionParser::~FunctionParser() {
// Drop all uses of undefined forward declared reference and destroy
// defining instruction.
fwd.first->dropAllUses();
- fwd.first->getDefiningInst()->destroy();
+ fwd.first->getDefiningOp()->destroy();
}
}
@@ -2560,7 +2560,7 @@ ParseResult FunctionParser::addDefinition(SSAUseInfo useInfo, Value *value) {
// the actual definition instead, delete the forward ref, and remove it
// from our set of forward references we track.
existing->replaceAllUsesWith(value);
- existing->getDefiningInst()->destroy();
+ existing->getDefiningOp()->destroy();
forwardReferencePlaceholders.erase(existing);
}
diff --git a/mlir/lib/StandardOps/Ops.cpp b/mlir/lib/StandardOps/Ops.cpp
index 228a4a5acc4..6bbf8c74bbb 100644
--- a/mlir/lib/StandardOps/Ops.cpp
+++ b/mlir/lib/StandardOps/Ops.cpp
@@ -133,7 +133,7 @@ struct MemRefCastFolder : public RewritePattern {
void rewrite(Instruction *op, PatternRewriter &rewriter) const override {
for (unsigned i = 0, e = op->getNumOperands(); i != e; ++i)
- if (auto *memref = op->getOperand(i)->getDefiningInst())
+ if (auto *memref = op->getOperand(i)->getDefiningOp())
if (auto cast = memref->dyn_cast<MemRefCastOp>())
op->setOperand(i, cast.getOperand());
rewriter.updatedRootInPlace(op);
@@ -270,7 +270,7 @@ bool AllocOp::verify() {
// 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 (getInstruction()->getNumOperands() != numDynamicDims + numSymbols) {
+ if (getOperation()->getNumOperands() != numDynamicDims + numSymbols) {
return emitOpError(
"operand count does not equal dimension plus symbol operand count");
}
@@ -318,7 +318,7 @@ struct SimplifyAllocConst : public RewritePattern {
newShapeConstants.push_back(dimSize);
continue;
}
- auto *defOp = allocOp.getOperand(dynamicDimPos)->getDefiningInst();
+ auto *defOp = allocOp.getOperand(dynamicDimPos)->getDefiningOp();
ConstantIndexOp constantIndexOp;
if (defOp && (constantIndexOp = defOp->dyn_cast<ConstantIndexOp>())) {
// Dynamic shape dimension will be folded.
@@ -396,17 +396,17 @@ bool BranchOp::parse(OpAsmParser *parser, OperationState *result) {
void BranchOp::print(OpAsmPrinter *p) {
*p << "br ";
- p->printSuccessorAndUseList(getInstruction(), 0);
+ p->printSuccessorAndUseList(getOperation(), 0);
}
-Block *BranchOp::getDest() { return getInstruction()->getSuccessor(0); }
+Block *BranchOp::getDest() { return getOperation()->getSuccessor(0); }
void BranchOp::setDest(Block *block) {
- return getInstruction()->setSuccessor(block, 0);
+ return getOperation()->setSuccessor(block, 0);
}
void BranchOp::eraseOperand(unsigned index) {
- getInstruction()->eraseSuccessorOperand(0, index);
+ getOperation()->eraseSuccessorOperand(0, index);
}
//===----------------------------------------------------------------------===//
@@ -869,9 +869,9 @@ void CondBranchOp::print(OpAsmPrinter *p) {
*p << "cond_br ";
p->printOperand(getCondition());
*p << ", ";
- p->printSuccessorAndUseList(getInstruction(), trueIndex);
+ p->printSuccessorAndUseList(getOperation(), trueIndex);
*p << ", ";
- p->printSuccessorAndUseList(getInstruction(), falseIndex);
+ p->printSuccessorAndUseList(getOperation(), falseIndex);
}
bool CondBranchOp::verify() {
@@ -886,27 +886,27 @@ void CondBranchOp::getCanonicalizationPatterns(
}
Block *CondBranchOp::getTrueDest() {
- return getInstruction()->getSuccessor(trueIndex);
+ return getOperation()->getSuccessor(trueIndex);
}
Block *CondBranchOp::getFalseDest() {
- return getInstruction()->getSuccessor(falseIndex);
+ return getOperation()->getSuccessor(falseIndex);
}
unsigned CondBranchOp::getNumTrueOperands() {
- return getInstruction()->getNumSuccessorOperands(trueIndex);
+ return getOperation()->getNumSuccessorOperands(trueIndex);
}
void CondBranchOp::eraseTrueOperand(unsigned index) {
- getInstruction()->eraseSuccessorOperand(trueIndex, index);
+ getOperation()->eraseSuccessorOperand(trueIndex, index);
}
unsigned CondBranchOp::getNumFalseOperands() {
- return getInstruction()->getNumSuccessorOperands(falseIndex);
+ return getOperation()->getNumSuccessorOperands(falseIndex);
}
void CondBranchOp::eraseFalseOperand(unsigned index) {
- getInstruction()->eraseSuccessorOperand(falseIndex, index);
+ getOperation()->eraseSuccessorOperand(falseIndex, index);
}
//===----------------------------------------------------------------------===//
@@ -1095,7 +1095,7 @@ struct SimplifyDeadDealloc : public RewritePattern {
// Check that the memref operand's defining instruction is an AllocOp.
Value *memref = dealloc.getMemRef();
- Instruction *defOp = memref->getDefiningInst();
+ Instruction *defOp = memref->getDefiningOp();
if (!defOp || !defOp->isa<AllocOp>())
return matchFailure();
@@ -1802,7 +1802,7 @@ void ReturnOp::print(OpAsmPrinter *p) {
}
bool ReturnOp::verify() {
- auto *function = getInstruction()->getFunction();
+ auto *function = getOperation()->getFunction();
// The operand number and types must match the function signature.
const auto &results = function->getType().getResults();
@@ -1852,7 +1852,7 @@ bool SelectOp::parse(OpAsmParser *parser, OperationState *result) {
void SelectOp::print(OpAsmPrinter *p) {
*p << "select ";
- p->printOperands(getInstruction()->getOperands());
+ p->printOperands(getOperation()->getOperands());
*p << " : " << getTrueValue()->getType();
p->printOptionalAttrDict(getAttrs());
}
diff --git a/mlir/lib/SuperVectorOps/SuperVectorOps.cpp b/mlir/lib/SuperVectorOps/SuperVectorOps.cpp
index 1e0c01a5df1..15bd31f4bff 100644
--- a/mlir/lib/SuperVectorOps/SuperVectorOps.cpp
+++ b/mlir/lib/SuperVectorOps/SuperVectorOps.cpp
@@ -87,7 +87,7 @@ void VectorTransferReadOp::build(Builder *builder, OperationState *result,
llvm::iterator_range<Instruction::operand_iterator>
VectorTransferReadOp::getIndices() {
- auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
+ auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
auto end = begin + getMemRefType().getRank();
return {begin, end};
}
@@ -288,7 +288,7 @@ void VectorTransferWriteOp::build(Builder *builder, OperationState *result,
llvm::iterator_range<Instruction::operand_iterator>
VectorTransferWriteOp::getIndices() {
- auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
+ auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
auto end = begin + getMemRefType().getRank();
return {begin, end};
}
diff --git a/mlir/lib/Transforms/ConstantFold.cpp b/mlir/lib/Transforms/ConstantFold.cpp
index ece87ce6b6c..4c4c8cc4019 100644
--- a/mlir/lib/Transforms/ConstantFold.cpp
+++ b/mlir/lib/Transforms/ConstantFold.cpp
@@ -54,7 +54,7 @@ void ConstantFold::foldInstruction(Instruction *op) {
SmallVector<Attribute, 8> operandConstants;
for (auto *operand : op->getOperands()) {
Attribute operandCst = nullptr;
- if (auto *operandOp = operand->getDefiningInst()) {
+ if (auto *operandOp = operand->getDefiningOp()) {
if (auto operandConstantOp = operandOp->dyn_cast<ConstantOp>())
operandCst = operandConstantOp.getValue();
}
@@ -112,7 +112,7 @@ void ConstantFold::runOnFunction() {
// around dead constants. Check for them now and remove them.
for (auto *cst : existingConstants) {
if (cst->use_empty())
- cst->getDefiningInst()->erase();
+ cst->getDefiningOp()->erase();
}
}
diff --git a/mlir/lib/Transforms/DmaGeneration.cpp b/mlir/lib/Transforms/DmaGeneration.cpp
index e20472770ae..50edcc6e64c 100644
--- a/mlir/lib/Transforms/DmaGeneration.cpp
+++ b/mlir/lib/Transforms/DmaGeneration.cpp
@@ -206,7 +206,7 @@ static bool getFullMemRefAsRegion(Instruction *opInst, unsigned numParamLoopIVs,
}
static void emitNoteForBlock(Block &block, const Twine &message) {
- auto *inst = block.getContainingInst();
+ auto *inst = block.getContainingOp();
if (!inst) {
block.getFunction()->emitNote(message);
} else {
@@ -403,7 +403,7 @@ bool DmaGeneration::generateDma(const MemRefRegion &region, Block *block,
zeroIndex, stride, numEltPerStride);
// Since new ops are being appended (for outgoing DMAs), adjust the end to
// mark end of range of the original.
- *nEnd = Block::iterator(op.getInstruction());
+ *nEnd = Block::iterator(op.getOperation());
}
// Matching DMA wait to block on completion; tag always has a 0 index.
@@ -414,7 +414,7 @@ bool DmaGeneration::generateDma(const MemRefRegion &region, Block *block,
if (*nEnd == end)
// Since new ops are being appended (for outgoing DMAs), adjust the end to
// mark end of range of the original.
- *nEnd = Block::iterator(tagDeallocOp.getInstruction());
+ *nEnd = Block::iterator(tagDeallocOp.getOperation());
// Generate dealloc for the DMA buffer.
if (!existingBuf)
@@ -567,9 +567,9 @@ findHighestBlockForPlacement(const MemRefRegion &region, Block &block,
if (it != enclosingFors.rbegin()) {
auto lastInvariantIV = *std::prev(it);
- *dmaPlacementReadStart = Block::iterator(lastInvariantIV.getInstruction());
+ *dmaPlacementReadStart = Block::iterator(lastInvariantIV.getOperation());
*dmaPlacementWriteStart = std::next(*dmaPlacementReadStart);
- *dmaPlacementBlock = lastInvariantIV.getInstruction()->getBlock();
+ *dmaPlacementBlock = lastInvariantIV.getOperation()->getBlock();
} else {
*dmaPlacementReadStart = begin;
*dmaPlacementWriteStart = end;
@@ -744,7 +744,7 @@ uint64_t DmaGeneration::runOnBlock(Block::iterator begin, Block::iterator end) {
if (totalDmaBuffersSizeInBytes > fastMemCapacityBytes) {
StringRef str = "Total size of all DMA buffers' for this block "
"exceeds fast memory capacity\n";
- if (auto *inst = block->getContainingInst())
+ if (auto *inst = block->getContainingOp())
inst->emitError(str);
else
block->getFunction()->emitError(str);
diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp
index df5005bc7b1..d76aca20b6d 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -301,7 +301,7 @@ public:
Node *node = getNode(id);
for (auto *storeOpInst : node->stores) {
auto *memref = storeOpInst->cast<StoreOp>().getMemRef();
- auto *inst = memref->getDefiningInst();
+ auto *inst = memref->getDefiningOp();
// Return true if 'memref' is a block argument.
if (!inst)
return true;
@@ -696,8 +696,8 @@ bool MemRefDependenceGraph::init(Function &f) {
getLoopIVs(*use.getOwner(), &loops);
if (loops.empty())
continue;
- assert(forToNodeMap.count(loops[0].getInstruction()) > 0);
- unsigned userLoopNestId = forToNodeMap[loops[0].getInstruction()];
+ assert(forToNodeMap.count(loops[0].getOperation()) > 0);
+ unsigned userLoopNestId = forToNodeMap[loops[0].getOperation()];
addEdge(node.id, userLoopNestId, value);
}
}
@@ -745,8 +745,8 @@ struct LoopNestStatsCollector {
void collect(Instruction *inst) {
inst->walk<AffineForOp>([&](AffineForOp forOp) {
- auto *forInst = forOp.getInstruction();
- auto *parentInst = forOp.getInstruction()->getParentInst();
+ auto *forInst = forOp.getOperation();
+ auto *parentInst = forOp.getOperation()->getParentInst();
if (parentInst != nullptr) {
assert(parentInst->isa<AffineForOp>() && "Expected parent AffineForOp");
// Add mapping to 'forOp' from its parent AffineForOp.
@@ -796,7 +796,7 @@ static int64_t getComputeCost(
int64_t opCount = stats->opCountMap[forInst];
if (stats->loopMap.count(forInst) > 0) {
for (auto childForOp : stats->loopMap[forInst]) {
- opCount += getComputeCost(childForOp.getInstruction(), stats,
+ opCount += getComputeCost(childForOp.getOperation(), stats,
tripCountOverrideMap, computeCostMap);
}
}
@@ -856,7 +856,7 @@ static bool buildSliceTripCountMap(
// The iteration of src loop IV 'i' was not sliced. Use full loop bounds.
if (srcLoopIVs[i].hasConstantLowerBound() &&
srcLoopIVs[i].hasConstantUpperBound()) {
- (*tripCountMap)[srcLoopIVs[i].getInstruction()] =
+ (*tripCountMap)[srcLoopIVs[i].getOperation()] =
srcLoopIVs[i].getConstantUpperBound() -
srcLoopIVs[i].getConstantLowerBound();
continue;
@@ -866,7 +866,7 @@ static bool buildSliceTripCountMap(
Optional<uint64_t> tripCount = getConstDifference(lbMap, ubMap);
if (!tripCount.hasValue())
return false;
- (*tripCountMap)[srcLoopIVs[i].getInstruction()] = tripCount.getValue();
+ (*tripCountMap)[srcLoopIVs[i].getOperation()] = tripCount.getValue();
}
return true;
}
@@ -1091,7 +1091,7 @@ static void sinkSequentialLoops(MemRefDependenceGraph::Node *node) {
}
}
assert(loopNestRootIndex != -1 && "invalid root index");
- node->inst = loops[loopNestRootIndex].getInstruction();
+ node->inst = loops[loopNestRootIndex].getOperation();
}
// TODO(mlir-team): improve/complete this when we have target data.
@@ -1119,7 +1119,7 @@ static Value *createPrivateMemRef(AffineForOp forOp,
unsigned dstLoopDepth,
Optional<unsigned> fastMemorySpace,
uint64_t localBufSizeThreshold) {
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
// Create builder to insert alloc op just before 'forOp'.
FuncBuilder b(forInst);
@@ -1437,7 +1437,7 @@ static bool isFusionProfitable(Instruction *srcOpInst,
// Walk src loop nest and collect stats.
LoopNestStats srcLoopNestStats;
LoopNestStatsCollector srcStatsCollector(&srcLoopNestStats);
- srcStatsCollector.collect(srcLoopIVs[0].getInstruction());
+ srcStatsCollector.collect(srcLoopIVs[0].getOperation());
// Currently only constant trip count loop nests are supported.
if (srcStatsCollector.hasLoopWithNonConstTripCount) {
LLVM_DEBUG(llvm::dbgs() << "Non-constant trip count loops unsupported.\n");
@@ -1449,7 +1449,7 @@ static bool isFusionProfitable(Instruction *srcOpInst,
LoopNestStats dstLoopNestStats;
LoopNestStatsCollector dstStatsCollector(&dstLoopNestStats);
- dstStatsCollector.collect(dstLoopIVs[0].getInstruction());
+ dstStatsCollector.collect(dstLoopIVs[0].getOperation());
// Currently only constant trip count loop nests are supported.
if (dstStatsCollector.hasLoopWithNonConstTripCount) {
LLVM_DEBUG(llvm::dbgs() << "Non-constant trip count loops unsupported.\n");
@@ -1484,7 +1484,7 @@ static bool isFusionProfitable(Instruction *srcOpInst,
// Compute op instance count for the src loop nest without iteration slicing.
uint64_t srcLoopNestCost =
- getComputeCost(srcLoopIVs[0].getInstruction(), &srcLoopNestStats,
+ getComputeCost(srcLoopIVs[0].getOperation(), &srcLoopNestStats,
/*tripCountOverrideMap=*/nullptr,
/*computeCostMap=*/nullptr);
@@ -1504,7 +1504,7 @@ static bool isFusionProfitable(Instruction *srcOpInst,
// Compute op instance count for the src loop nest.
uint64_t dstLoopNestCost =
- getComputeCost(dstLoopIVs[0].getInstruction(), &dstLoopNestStats,
+ getComputeCost(dstLoopIVs[0].getOperation(), &dstLoopNestStats,
/*tripCountOverrideMap=*/nullptr,
/*computeCostMap=*/nullptr);
@@ -1543,7 +1543,7 @@ static bool isFusionProfitable(Instruction *srcOpInst,
// TODO(andydavis) Add load coalescing to memref data flow opt pass.
if (storeLoadFwdGuaranteed) {
// A single store disappears: -1 for that.
- computeCostMap[srcLoopIVs[numSrcLoopIVs - 1].getInstruction()] = -1;
+ computeCostMap[srcLoopIVs[numSrcLoopIVs - 1].getOperation()] = -1;
for (auto *loadOp : dstLoadOpInsts) {
auto *parentInst = loadOp->getParentInst();
if (parentInst && parentInst->isa<AffineForOp>())
@@ -1553,15 +1553,15 @@ static bool isFusionProfitable(Instruction *srcOpInst,
// Compute op instance count for the src loop nest with iteration slicing.
int64_t sliceComputeCost =
- getComputeCost(srcLoopIVs[0].getInstruction(), &srcLoopNestStats,
+ getComputeCost(srcLoopIVs[0].getOperation(), &srcLoopNestStats,
/*tripCountOverrideMap=*/&sliceTripCountMap,
/*computeCostMap=*/&computeCostMap);
// Compute cost of fusion for this depth.
- computeCostMap[dstLoopIVs[i - 1].getInstruction()] = sliceComputeCost;
+ computeCostMap[dstLoopIVs[i - 1].getOperation()] = sliceComputeCost;
int64_t fusedLoopNestComputeCost =
- getComputeCost(dstLoopIVs[0].getInstruction(), &dstLoopNestStats,
+ getComputeCost(dstLoopIVs[0].getOperation(), &dstLoopNestStats,
/*tripCountOverrideMap=*/nullptr, &computeCostMap);
double additionalComputeFraction =
@@ -1936,18 +1936,18 @@ public:
srcStoreOpInst, dstLoadOpInsts[0], bestDstLoopDepth, &sliceState);
if (sliceLoopNest) {
LLVM_DEBUG(llvm::dbgs() << "\tslice loop nest:\n"
- << *sliceLoopNest.getInstruction() << "\n");
+ << *sliceLoopNest.getOperation() << "\n");
// Move 'dstAffineForOp' before 'insertPointInst' if needed.
auto dstAffineForOp = dstNode->inst->cast<AffineForOp>();
- if (insertPointInst != dstAffineForOp.getInstruction()) {
- dstAffineForOp.getInstruction()->moveBefore(insertPointInst);
+ if (insertPointInst != dstAffineForOp.getOperation()) {
+ dstAffineForOp.getOperation()->moveBefore(insertPointInst);
}
// Update edges between 'srcNode' and 'dstNode'.
mdg->updateEdges(srcNode->id, dstNode->id, memref);
// Collect slice loop stats.
LoopNestStateCollector sliceCollector;
- sliceCollector.collect(sliceLoopNest.getInstruction());
+ sliceCollector.collect(sliceLoopNest.getOperation());
// Promote single iteration slice loops to single IV value.
for (auto forOp : sliceCollector.forOps) {
promoteIfSingleIteration(forOp);
@@ -1966,14 +1966,14 @@ public:
visitedMemrefs.insert(newMemRef);
// Create new node in dependence graph for 'newMemRef' alloc op.
unsigned newMemRefNodeId =
- mdg->addNode(newMemRef->getDefiningInst());
+ mdg->addNode(newMemRef->getDefiningOp());
// Add edge from 'newMemRef' node to dstNode.
mdg->addEdge(newMemRefNodeId, dstId, newMemRef);
}
// Collect dst loop stats after memref privatizaton transformation.
LoopNestStateCollector dstLoopCollector;
- dstLoopCollector.collect(dstAffineForOp.getInstruction());
+ dstLoopCollector.collect(dstAffineForOp.getOperation());
// Add new load ops to current Node load op list 'loads' to
// continue fusing based on new operands.
@@ -2096,8 +2096,8 @@ public:
if (sliceLoopNest != nullptr) {
auto dstForInst = dstNode->inst->cast<AffineForOp>();
// Update instruction position of fused loop nest (if needed).
- if (insertPointInst != dstForInst.getInstruction()) {
- dstForInst.getInstruction()->moveBefore(insertPointInst);
+ if (insertPointInst != dstForInst.getOperation()) {
+ dstForInst.getOperation()->moveBefore(insertPointInst);
}
// Update data dependence graph state post fusion.
updateStateAfterSiblingFusion(sliceLoopNest, sibNode, dstNode);
@@ -2189,7 +2189,7 @@ public:
// Collect slice loop stats.
LoopNestStateCollector sliceCollector;
- sliceCollector.collect(sliceLoopNest.getInstruction());
+ sliceCollector.collect(sliceLoopNest.getOperation());
// Promote single iteration slice loops to single IV value.
for (auto forOp : sliceCollector.forOps) {
promoteIfSingleIteration(forOp);
@@ -2198,7 +2198,7 @@ public:
// Collect dst loop stats after memref privatizaton transformation.
auto dstForInst = dstNode->inst->cast<AffineForOp>();
LoopNestStateCollector dstLoopCollector;
- dstLoopCollector.collect(dstForInst.getInstruction());
+ dstLoopCollector.collect(dstForInst.getOperation());
// Clear and add back loads and stores
mdg->clearNodeLoadAndStores(dstNode->id);
mdg->addToNode(dstNode->id, dstLoopCollector.loadOpInsts,
@@ -2222,7 +2222,7 @@ public:
if (!memref->use_empty())
continue;
// Use list expected to match the dep graph info.
- auto *inst = memref->getDefiningInst();
+ auto *inst = memref->getDefiningOp();
if (inst && inst->isa<AllocOp>())
inst->erase();
}
diff --git a/mlir/lib/Transforms/LoopTiling.cpp b/mlir/lib/Transforms/LoopTiling.cpp
index eafa7bca4d4..d9f74808ad8 100644
--- a/mlir/lib/Transforms/LoopTiling.cpp
+++ b/mlir/lib/Transforms/LoopTiling.cpp
@@ -92,8 +92,7 @@ FunctionPassBase *mlir::createLoopTilingPass(uint64_t cacheSizeBytes) {
// location in destination's body.
static inline void moveLoopBody(AffineForOp src, AffineForOp dest,
Block::iterator loc) {
- dest.getBody()->getInstructions().splice(loc,
- src.getBody()->getInstructions());
+ dest.getBody()->getOperations().splice(loc, src.getBody()->getOperations());
}
// Move the loop body of AffineForOp 'src' from 'src' to the start of dest's
@@ -114,7 +113,7 @@ constructTiledIndexSetHyperRect(MutableArrayRef<AffineForOp> origLoops,
assert(!origLoops.empty());
assert(origLoops.size() == tileSizes.size());
- FuncBuilder b(origLoops[0].getInstruction());
+ FuncBuilder b(origLoops[0].getOperation());
unsigned width = origLoops.size();
// Bounds for tile space loops.
@@ -181,8 +180,8 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<AffineForOp> band,
// Check if the supplied for inst's are all successively nested.
for (unsigned i = 1, e = band.size(); i < e; i++) {
- assert(band[i].getInstruction()->getParentInst() ==
- band[i - 1].getInstruction());
+ assert(band[i].getOperation()->getParentInst() ==
+ band[i - 1].getOperation());
}
auto origLoops = band;
@@ -196,7 +195,7 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<AffineForOp> band,
AffineForOp innermostPointLoop;
// The outermost among the loops as we add more..
- auto *topLoop = rootAffineForOp.getInstruction();
+ auto *topLoop = rootAffineForOp.getOperation();
// Add intra-tile (or point) loops.
for (unsigned i = 0; i < width; i++) {
@@ -204,11 +203,11 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<AffineForOp> band,
// Loop bounds will be set later.
auto pointLoop = b.create<AffineForOp>(loc, 0, 0);
pointLoop.createBody();
- pointLoop.getBody()->getInstructions().splice(
- pointLoop.getBody()->begin(), topLoop->getBlock()->getInstructions(),
+ pointLoop.getBody()->getOperations().splice(
+ pointLoop.getBody()->begin(), topLoop->getBlock()->getOperations(),
topLoop);
newLoops[2 * width - 1 - i] = pointLoop;
- topLoop = pointLoop.getInstruction();
+ topLoop = pointLoop.getOperation();
if (i == 0)
innermostPointLoop = pointLoop;
}
@@ -219,11 +218,11 @@ LogicalResult mlir::tileCodeGen(MutableArrayRef<AffineForOp> band,
// Loop bounds will be set later.
auto tileSpaceLoop = b.create<AffineForOp>(loc, 0, 0);
tileSpaceLoop.createBody();
- tileSpaceLoop.getBody()->getInstructions().splice(
- tileSpaceLoop.getBody()->begin(),
- topLoop->getBlock()->getInstructions(), topLoop);
+ tileSpaceLoop.getBody()->getOperations().splice(
+ tileSpaceLoop.getBody()->begin(), topLoop->getBlock()->getOperations(),
+ topLoop);
newLoops[2 * width - i - 1] = tileSpaceLoop;
- topLoop = tileSpaceLoop.getInstruction();
+ topLoop = tileSpaceLoop.getOperation();
}
// Move the loop body of the original nest to the new one.
@@ -265,7 +264,7 @@ static void getTileableBands(Function &f,
AffineForOp currInst = root;
do {
band.push_back(currInst);
- } while (currInst.getBody()->getInstructions().size() == 1 &&
+ } while (currInst.getBody()->getOperations().size() == 1 &&
(currInst = currInst.getBody()->front().dyn_cast<AffineForOp>()));
bands->push_back(band);
};
diff --git a/mlir/lib/Transforms/LoopUnrollAndJam.cpp b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
index 174f93e4d2d..3fa4eab93da 100644
--- a/mlir/lib/Transforms/LoopUnrollAndJam.cpp
+++ b/mlir/lib/Transforms/LoopUnrollAndJam.cpp
@@ -173,7 +173,7 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp,
mayBeConstantTripCount.getValue() < unrollJamFactor)
return failure();
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
// Gather all sub-blocks to jam upon the loop being unrolled.
JamBlockGatherer jbg;
diff --git a/mlir/lib/Transforms/LowerAffine.cpp b/mlir/lib/Transforms/LowerAffine.cpp
index 162eed00b6c..5046bf2596b 100644
--- a/mlir/lib/Transforms/LowerAffine.cpp
+++ b/mlir/lib/Transforms/LowerAffine.cpp
@@ -321,7 +321,7 @@ static Value *buildMinMaxReductionSeq(Location loc, CmpIPredicate predicate,
//
bool LowerAffinePass::lowerAffineFor(AffineForOp forOp) {
auto loc = forOp.getLoc();
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
// Start by splitting the block containing the 'affine.for' into two parts.
// The part before will get the init code, the part after will be the end
@@ -340,9 +340,9 @@ bool LowerAffinePass::lowerAffineFor(AffineForOp forOp) {
bodyBlock->insertBefore(endBlock);
auto *oldBody = forOp.getBody();
- bodyBlock->getInstructions().splice(bodyBlock->begin(),
- oldBody->getInstructions(),
- oldBody->begin(), oldBody->end());
+ bodyBlock->getOperations().splice(bodyBlock->begin(),
+ oldBody->getOperations(), oldBody->begin(),
+ oldBody->end());
// The code in the body of the forOp now uses 'iv' as its indvar.
forOp.getInductionVar()->replaceAllUsesWith(iv);
@@ -454,7 +454,7 @@ bool LowerAffinePass::lowerAffineFor(AffineForOp forOp) {
// +--------------------------------+
//
bool LowerAffinePass::lowerAffineIf(AffineIfOp ifOp) {
- auto *ifInst = ifOp.getInstruction();
+ auto *ifInst = ifOp.getOperation();
auto loc = ifInst->getLoc();
// Start by splitting the block containing the 'affine.if' into two parts. The
@@ -478,9 +478,9 @@ bool LowerAffinePass::lowerAffineIf(AffineIfOp ifOp) {
Block *oldThen = &oldThenBlocks.front();
- thenBlock->getInstructions().splice(thenBlock->begin(),
- oldThen->getInstructions(),
- oldThen->begin(), oldThen->end());
+ thenBlock->getOperations().splice(thenBlock->begin(),
+ oldThen->getOperations(),
+ oldThen->begin(), oldThen->end());
}
FuncBuilder builder(thenBlock);
@@ -499,9 +499,9 @@ bool LowerAffinePass::lowerAffineIf(AffineIfOp ifOp) {
elseBlock = new Block();
elseBlock->insertBefore(continueBlock);
- elseBlock->getInstructions().splice(elseBlock->begin(),
- oldElse->getInstructions(),
- oldElse->begin(), oldElse->end());
+ elseBlock->getOperations().splice(elseBlock->begin(),
+ oldElse->getOperations(),
+ oldElse->begin(), oldElse->end());
builder.setInsertionPointToEnd(elseBlock);
builder.create<BranchOp>(loc, continueBlock);
}
@@ -570,7 +570,7 @@ bool LowerAffinePass::lowerAffineIf(AffineIfOp ifOp) {
// Convert an "affine.apply" operation into a sequence of arithmetic
// instructions using the StandardOps dialect. Return true on error.
bool LowerAffinePass::lowerAffineApply(AffineApplyOp op) {
- FuncBuilder builder(op.getInstruction());
+ FuncBuilder builder(op.getOperation());
auto maybeExpandedMap =
expandAffineMap(&builder, op.getLoc(), op.getAffineMap(),
llvm::to_vector<8>(op.getOperands()));
diff --git a/mlir/lib/Transforms/LowerVectorTransfers.cpp b/mlir/lib/Transforms/LowerVectorTransfers.cpp
index e6b1950c222..708ad7d1693 100644
--- a/mlir/lib/Transforms/LowerVectorTransfers.cpp
+++ b/mlir/lib/Transforms/LowerVectorTransfers.cpp
@@ -266,8 +266,7 @@ template <> void VectorTransferRewriter<VectorTransferReadOp>::rewrite() {
using namespace mlir::edsc::intrinsics;
// 1. Setup all the captures.
- ScopedContext scope(FuncBuilder(transfer.getInstruction()),
- transfer.getLoc());
+ ScopedContext scope(FuncBuilder(transfer.getOperation()), transfer.getLoc());
IndexedValue remote(transfer.getMemRef());
MemRefView view(transfer.getMemRef());
VectorView vectorView(transfer.getVector());
@@ -321,8 +320,7 @@ template <> void VectorTransferRewriter<VectorTransferWriteOp>::rewrite() {
using namespace mlir::edsc::intrinsics;
// 1. Setup all the captures.
- ScopedContext scope(FuncBuilder(transfer.getInstruction()),
- transfer.getLoc());
+ ScopedContext scope(FuncBuilder(transfer.getOperation()), transfer.getLoc());
IndexedValue remote(transfer.getMemRef());
MemRefView view(transfer.getMemRef());
ValueHandle vectorValue(transfer.getVector());
diff --git a/mlir/lib/Transforms/MaterializeVectors.cpp b/mlir/lib/Transforms/MaterializeVectors.cpp
index a4deba26d83..8ea9d4e8020 100644
--- a/mlir/lib/Transforms/MaterializeVectors.cpp
+++ b/mlir/lib/Transforms/MaterializeVectors.cpp
@@ -256,7 +256,7 @@ static Value *substitute(Value *v, VectorType hwVectorType,
DenseMap<Value *, Value *> *substitutionsMap) {
auto it = substitutionsMap->find(v);
if (it == substitutionsMap->end()) {
- auto *opInst = v->getDefiningInst();
+ auto *opInst = v->getDefiningOp();
if (opInst->isa<ConstantOp>()) {
FuncBuilder b(opInst);
auto *inst = instantiate(&b, opInst, hwVectorType, substitutionsMap);
@@ -265,7 +265,7 @@ static Value *substitute(Value *v, VectorType hwVectorType,
assert(res.second && "Insertion failed");
return res.first->second;
}
- v->getDefiningInst()->emitError("Missing substitution");
+ v->getDefiningOp()->emitError("Missing substitution");
return nullptr;
}
return it->second;
@@ -496,7 +496,7 @@ static Instruction *instantiate(FuncBuilder *b, VectorTransferReadOp read,
auto cloned = b->create<VectorTransferReadOp>(read.getLoc(), hwVectorType,
read.getMemRef(), affineIndices,
map, read.getPaddingValue());
- return cloned.getInstruction();
+ return cloned.getOperation();
}
/// Creates an instantiated version of `write` for the instance of
@@ -518,7 +518,7 @@ static Instruction *instantiate(FuncBuilder *b, VectorTransferWriteOp write,
substitute(write.getVector(), hwVectorType, substitutionsMap),
write.getMemRef(), affineIndices,
projectedPermutationMap(write, hwVectorType));
- return cloned.getInstruction();
+ return cloned.getOperation();
}
/// Returns `true` if inst instance is properly cloned and inserted, false
diff --git a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
index e1e253d1869..9779ab78a3f 100644
--- a/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
+++ b/mlir/lib/Transforms/MemRefDataFlowOpt.cpp
@@ -95,7 +95,7 @@ FunctionPassBase *mlir::createMemRefDataFlowOptPass() {
// this in the future if needed.
void MemRefDataFlowOpt::forwardStoreToLoad(LoadOp loadOp) {
Instruction *lastWriteStoreOp = nullptr;
- Instruction *loadOpInst = loadOp.getInstruction();
+ Instruction *loadOpInst = loadOp.getOperation();
// First pass over the use list to get minimum number of surrounding
// loops common between the load op and the store op, with min taken across
@@ -106,7 +106,7 @@ void MemRefDataFlowOpt::forwardStoreToLoad(LoadOp loadOp) {
auto storeOp = use.getOwner()->dyn_cast<StoreOp>();
if (!storeOp)
continue;
- auto *storeOpInst = storeOp.getInstruction();
+ auto *storeOpInst = storeOp.getOperation();
unsigned nsLoops = getNumCommonSurroundingLoops(*loadOpInst, *storeOpInst);
minSurroundingLoops = std::min(nsLoops, minSurroundingLoops);
storeOps.push_back(storeOpInst);
@@ -236,7 +236,7 @@ void MemRefDataFlowOpt::runOnFunction() {
// to do this as well, but we'll do it here since we collected these anyway.
for (auto *memref : memrefsToErase) {
// If the memref hasn't been alloc'ed in this function, skip.
- Instruction *defInst = memref->getDefiningInst();
+ Instruction *defInst = memref->getDefiningOp();
if (!defInst || !defInst->isa<AllocOp>())
// TODO(mlir-team): if the memref was returned by a 'call' instruction, we
// could still erase it if the call had no side-effects.
diff --git a/mlir/lib/Transforms/PipelineDataTransfer.cpp b/mlir/lib/Transforms/PipelineDataTransfer.cpp
index 051ac733c14..a7d37161aa1 100644
--- a/mlir/lib/Transforms/PipelineDataTransfer.cpp
+++ b/mlir/lib/Transforms/PipelineDataTransfer.cpp
@@ -93,7 +93,7 @@ static bool doubleBuffer(Value *oldMemRef, AffineForOp forOp) {
auto newMemRefType = doubleShape(oldMemRefType);
// The double buffer is allocated right before 'forInst'.
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
FuncBuilder bOuter(forInst);
// Put together alloc operands for any dynamic dimensions of the memref.
SmallVector<Value *, 4> allocOperands;
@@ -287,14 +287,14 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) {
// order to create the double buffer above.)
// '-canonicalize' does this in a more general way, but we'll anyway do the
// simple/common case so that the output / test cases looks clear.
- if (auto *allocInst = oldMemRef->getDefiningInst()) {
+ if (auto *allocInst = oldMemRef->getDefiningOp()) {
if (oldMemRef->use_empty()) {
allocInst->erase();
} else if (oldMemRef->hasOneUse()) {
auto *singleUse = oldMemRef->use_begin()->getOwner();
if (singleUse->isa<DeallocOp>()) {
singleUse->erase();
- oldMemRef->getDefiningInst()->erase();
+ oldMemRef->getDefiningOp()->erase();
}
}
}
@@ -312,7 +312,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) {
// If the old tag has no more uses, remove its 'dead' alloc if it was
// alloc'ed.
if (oldTagMemRef->use_empty())
- if (auto *allocInst = oldTagMemRef->getDefiningInst())
+ if (auto *allocInst = oldTagMemRef->getDefiningOp())
allocInst->erase();
}
@@ -331,7 +331,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) {
mlir::createAffineComputationSlice(dmaStartInst, &sliceOps);
if (!sliceOps.empty()) {
for (auto sliceOp : sliceOps) {
- instShiftMap[sliceOp.getInstruction()] = 0;
+ instShiftMap[sliceOp.getOperation()] = 0;
}
} else {
// If a slice wasn't created, the reachable affine.apply op's from its
@@ -352,7 +352,7 @@ void PipelineDataTransfer::runOnAffineForOp(AffineForOp forOp) {
}
// Get shifts stored in map.
- std::vector<uint64_t> shifts(forOp.getBody()->getInstructions().size());
+ std::vector<uint64_t> shifts(forOp.getBody()->getOperations().size());
unsigned s = 0;
for (auto &inst : *forOp.getBody()) {
assert(instShiftMap.find(&inst) != instShiftMap.end());
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index e8dce29729d..79a2b12d242 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -116,7 +116,7 @@ private:
if (!operand->use_empty() &&
std::next(operand->use_begin()) != operand->use_end())
continue;
- if (auto *defInst = operand->getDefiningInst())
+ if (auto *defInst = operand->getDefiningOp())
addToWorklist(defInst);
}
}
diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp
index a6f1c8dd1ca..9a7db193d29 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -102,7 +102,7 @@ void mlir::getCleanupLoopLowerBound(AffineForOp forOp, unsigned unrollFactor,
// Remove any affine.apply's that became dead from the simplification above.
for (auto *v : bumpValues) {
if (v->use_empty()) {
- v->getDefiningInst()->erase();
+ v->getDefiningOp()->erase();
}
}
if (lb.use_empty())
@@ -123,7 +123,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) {
// Replaces all IV uses to its single iteration value.
auto *iv = forOp.getInductionVar();
- Instruction *forInst = forOp.getInstruction();
+ Instruction *forInst = forOp.getOperation();
if (!iv->use_empty()) {
if (forOp.hasConstantLowerBound()) {
auto *mlFunc = forInst->getFunction();
@@ -147,8 +147,8 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) {
}
// Move the loop body instructions to the loop's containing block.
auto *block = forInst->getBlock();
- block->getInstructions().splice(Block::iterator(forInst),
- forOp.getBody()->getInstructions());
+ block->getOperations().splice(Block::iterator(forInst),
+ forOp.getBody()->getOperations());
forOp.erase();
return success();
}
@@ -252,7 +252,7 @@ LogicalResult mlir::instBodySkew(AffineForOp forOp, ArrayRef<uint64_t> shifts,
int64_t step = forOp.getStep();
- unsigned numChildInsts = forOp.getBody()->getInstructions().size();
+ unsigned numChildInsts = forOp.getBody()->getOperations().size();
// Do a linear time (counting) sort for the shifts.
uint64_t maxShift = 0;
@@ -290,7 +290,7 @@ LogicalResult mlir::instBodySkew(AffineForOp forOp, ArrayRef<uint64_t> shifts,
auto origLbMap = forOp.getLowerBoundMap();
uint64_t lbShift = 0;
- FuncBuilder b(forOp.getInstruction());
+ FuncBuilder b(forOp.getOperation());
for (uint64_t d = 0, e = sortedInstGroups.size(); d < e; ++d) {
// If nothing is shifted by d, continue.
if (sortedInstGroups[d].empty())
@@ -345,7 +345,7 @@ LogicalResult mlir::instBodySkew(AffineForOp forOp, ArrayRef<uint64_t> shifts,
if (unrollPrologueEpilogue && prologue)
loopUnrollFull(prologue);
if (unrollPrologueEpilogue && !epilogue &&
- epilogue.getInstruction() != prologue.getInstruction())
+ epilogue.getOperation() != prologue.getOperation())
loopUnrollFull(epilogue);
return success();
@@ -404,7 +404,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp,
return failure();
// Generate the cleanup loop if trip count isn't a multiple of unrollFactor.
- Instruction *forInst = forOp.getInstruction();
+ Instruction *forInst = forOp.getOperation();
if (getLargestDivisorOfTripCount(forOp) % unrollFactor != 0) {
FuncBuilder builder(forInst->getBlock(), ++Block::iterator(forInst));
auto cleanupForInst = builder.clone(*forInst)->cast<AffineForOp>();
@@ -467,20 +467,20 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp,
/// Performs loop interchange on 'forOpA' and 'forOpB', where 'forOpB' is
/// nested within 'forOpA' as the only instruction in its block.
void mlir::interchangeLoops(AffineForOp forOpA, AffineForOp forOpB) {
- auto *forOpAInst = forOpA.getInstruction();
+ auto *forOpAInst = forOpA.getOperation();
// 1) Slice forOpA's instruction list (which is just forOpB) just before
// forOpA (in forOpA's parent's block) this should leave 'forOpA's
// instruction list empty (because its perfectly nested).
- assert(&*forOpA.getBody()->begin() == forOpB.getInstruction());
- forOpAInst->getBlock()->getInstructions().splice(
- Block::iterator(forOpAInst), forOpA.getBody()->getInstructions());
+ assert(&*forOpA.getBody()->begin() == forOpB.getOperation());
+ forOpAInst->getBlock()->getOperations().splice(
+ Block::iterator(forOpAInst), forOpA.getBody()->getOperations());
// 2) Slice forOpB's instruction list into forOpA's instruction list (this
// leaves forOpB's instruction list empty).
- forOpA.getBody()->getInstructions().splice(
- forOpA.getBody()->begin(), forOpB.getBody()->getInstructions());
+ forOpA.getBody()->getOperations().splice(forOpA.getBody()->begin(),
+ forOpB.getBody()->getOperations());
// 3) Slice forOpA into forOpB's instruction list.
- forOpB.getBody()->getInstructions().splice(
- forOpB.getBody()->begin(), forOpAInst->getBlock()->getInstructions(),
+ forOpB.getBody()->getOperations().splice(
+ forOpB.getBody()->begin(), forOpAInst->getBlock()->getOperations(),
Block::iterator(forOpAInst));
}
@@ -526,7 +526,7 @@ static void cloneLoopBodyInto(AffineForOp forOp, Value *oldIv,
for (auto it = forOp.getBody()->begin(), end = forOp.getBody()->end();
it != end; ++it) {
// Step over newForOp in case it is nested under forOp.
- if (&*it == newForOp.getInstruction()) {
+ if (&*it == newForOp.getOperation()) {
continue;
}
auto *inst = b.clone(*it, map);
@@ -558,7 +558,7 @@ stripmineSink(AffineForOp forOp, uint64_t factor,
auto scaledStep = originalStep * factor;
forOp.setStep(scaledStep);
- auto *forInst = forOp.getInstruction();
+ auto *forInst = forOp.getOperation();
FuncBuilder b(forInst->getBlock(), ++Block::iterator(forInst));
// Lower-bound map creation.
@@ -581,7 +581,7 @@ stripmineSink(AffineForOp forOp, uint64_t factor,
newForOp.createBody();
cloneLoopBodyInto(t, forOp.getInductionVar(), newForOp);
// Remove all instructions from `t` except `newForOp`.
- auto rit = ++newForOp.getInstruction()->getReverseIterator();
+ auto rit = ++newForOp.getOperation()->getReverseIterator();
auto re = t.getBody()->rend();
for (auto &inst : llvm::make_early_inc_range(llvm::make_range(rit, re))) {
inst.erase();
diff --git a/mlir/lib/Transforms/Utils/Utils.cpp b/mlir/lib/Transforms/Utils/Utils.cpp
index 7a44a6277a6..b5225d08827 100644
--- a/mlir/lib/Transforms/Utils/Utils.cpp
+++ b/mlir/lib/Transforms/Utils/Utils.cpp
@@ -127,7 +127,7 @@ bool mlir::replaceAllMemRefUsesWith(Value *oldMemRef, Value *newMemRef,
FuncBuilder builder(opInst);
for (auto *extraIndex : extraIndices) {
- assert(extraIndex->getDefiningInst()->getNumResults() == 1 &&
+ assert(extraIndex->getDefiningOp()->getNumResults() == 1 &&
"single result op's expected to generate these indices");
assert((isValidDim(extraIndex) || isValidSymbol(extraIndex)) &&
"invalid memory op index");
@@ -226,7 +226,7 @@ void mlir::createAffineComputationSlice(
SmallVector<Value *, 4> subOperands;
subOperands.reserve(opInst->getNumOperands());
for (auto *operand : opInst->getOperands()) {
- auto *defInst = operand->getDefiningInst();
+ auto *defInst = operand->getDefiningOp();
if (defInst && defInst->isa<AffineApplyOp>()) {
subOperands.push_back(operand);
}
diff --git a/mlir/lib/Transforms/Vectorize.cpp b/mlir/lib/Transforms/Vectorize.cpp
index a1e2c609653..3c6ab6c2cac 100644
--- a/mlir/lib/Transforms/Vectorize.cpp
+++ b/mlir/lib/Transforms/Vectorize.cpp
@@ -828,7 +828,7 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv,
auto vectorType = VectorType::get(state->strategy->vectorSizes, elementType);
// Materialize a MemRef with 1 vector.
- auto *opInst = memoryOp.getInstruction();
+ auto *opInst = memoryOp.getOperation();
// 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
@@ -842,7 +842,7 @@ static LogicalResult vectorizeRootOrTerminal(Value *iv,
auto transfer = b.create<VectorTransferReadOp>(
opInst->getLoc(), vectorType, memoryOp.getMemRef(),
map(makePtrDynCaster<Value>(), memoryOp.getIndices()), permutationMap);
- state->registerReplacement(opInst, transfer.getInstruction());
+ state->registerReplacement(opInst, transfer.getOperation());
} else {
state->registerTerminal(opInst);
}
@@ -867,7 +867,7 @@ static LogicalResult vectorizeAffineForOp(AffineForOp loop, int64_t step,
};
auto loadAndStores = matcher::Op(notVectorizedThisPattern);
SmallVector<NestedMatch, 8> loadAndStoresMatches;
- loadAndStores.match(loop.getInstruction(), &loadAndStoresMatches);
+ loadAndStores.match(loop.getOperation(), &loadAndStoresMatches);
for (auto ls : loadAndStoresMatches) {
auto *opInst = ls.getMatchedInstruction();
auto load = opInst->dyn_cast<LoadOp>();
@@ -953,7 +953,7 @@ static Value *vectorizeConstant(Instruction *inst, ConstantOp constant,
Location loc = inst->getLoc();
auto vectorType = type.cast<VectorType>();
auto attr = SplatElementsAttr::get(vectorType, constant.getValue());
- auto *constantOpInst = constant.getInstruction();
+ auto *constantOpInst = constant.getOperation();
OperationState state(b.getContext(), loc,
constantOpInst->getName().getStringRef(), {},
@@ -988,7 +988,7 @@ static Value *vectorizeOperand(Value *operand, Instruction *inst,
LLVM_DEBUG(dbgs() << "\n[early-vect]vectorize operand: ");
LLVM_DEBUG(operand->print(dbgs()));
// 1. If this value has already been vectorized this round, we are done.
- if (state->vectorizedSet.count(operand->getDefiningInst()) > 0) {
+ if (state->vectorizedSet.count(operand->getDefiningOp()) > 0) {
LLVM_DEBUG(dbgs() << " -> already vector operand");
return operand;
}
@@ -1009,7 +1009,7 @@ static Value *vectorizeOperand(Value *operand, Instruction *inst,
return nullptr;
}
// 3. vectorize constant.
- if (auto constant = operand->getDefiningInst()->dyn_cast<ConstantOp>()) {
+ if (auto constant = operand->getDefiningOp()->dyn_cast<ConstantOp>()) {
return vectorizeConstant(
inst, constant,
VectorType::get(state->strategy->vectorSizes, operand->getType()));
@@ -1051,7 +1051,7 @@ static Instruction *vectorizeOneInstruction(Instruction *opInst,
LLVM_DEBUG(permutationMap.print(dbgs()));
auto transfer = b.create<VectorTransferWriteOp>(
opInst->getLoc(), vectorValue, memRef, indices, permutationMap);
- auto *res = transfer.getInstruction();
+ auto *res = transfer.getOperation();
LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ vectorized store: " << *res);
// "Terminals" (i.e. StoreOps) are erased on the spot.
opInst->erase();
@@ -1163,7 +1163,7 @@ static LogicalResult vectorizeRootMatch(NestedMatch m,
/// Sets up error handling for this root loop. This is how the root match
/// maintains a clone for handling failure and restores the proper state via
/// RAII.
- auto *loopInst = loop.getInstruction();
+ auto *loopInst = loop.getOperation();
FuncBuilder builder(loopInst);
auto clonedLoop = builder.clone(*loopInst)->cast<AffineForOp>();
struct Guard {
diff --git a/mlir/test/EDSC/builder-api-test.cpp b/mlir/test/EDSC/builder-api-test.cpp
index 8a31eeb9f05..f607a3d4d3f 100644
--- a/mlir/test/EDSC/builder-api-test.cpp
+++ b/mlir/test/EDSC/builder-api-test.cpp
@@ -386,8 +386,8 @@ TEST_FUNC(custom_ops) {
ih0 = MY_CUSTOM_INST_0({m, m + n}, {}),
ih2 = MY_CUSTOM_INST_2({m, m + n}, {indexType, indexType}),
// These captures are verbose for now, can improve when used in practice.
- vh20 = ValueHandle(ih2.getInstruction()->getResult(0)),
- vh21 = ValueHandle(ih2.getInstruction()->getResult(1)),
+ vh20 = ValueHandle(ih2.getOperation()->getResult(0)),
+ vh21 = ValueHandle(ih2.getOperation()->getResult(1)),
MY_CUSTOM_OP({vh20, vh21}, {indexType}, {}),
});
diff --git a/mlir/test/mlir-tblgen/op-operand.td b/mlir/test/mlir-tblgen/op-operand.td
index 303d5c9be96..7849be2c00c 100644
--- a/mlir/test/mlir-tblgen/op-operand.td
+++ b/mlir/test/mlir-tblgen/op-operand.td
@@ -8,5 +8,5 @@ def OneOperandOp : Op<"one_operand_op", []> {
// CHECK-LABEL: OneOperandOp definitions
// CHECK: bool OneOperandOp::verify() {
-// CHECK: if (!((this->getInstruction()->getOperand(0)->getType().isInteger(32))))
+// CHECK: if (!((this->getOperation()->getOperand(0)->getType().isInteger(32))))
// CHECK-NEXT: return emitOpError("operand #0 must be 32-bit integer");
diff --git a/mlir/test/mlir-tblgen/op-result.td b/mlir/test/mlir-tblgen/op-result.td
index f98564c5d28..d9e82956505 100644
--- a/mlir/test/mlir-tblgen/op-result.td
+++ b/mlir/test/mlir-tblgen/op-result.td
@@ -8,7 +8,7 @@ def OneResultOp : Op<"one_result_op", []> {
// CHECK-LABEL: OneResultOp definitions
// CHECK: bool OneResultOp::verify() {
-// CHECK: if (!((this->getInstruction()->getResult(0)->getType().isInteger(32))))
+// CHECK: if (!((this->getOperation()->getResult(0)->getType().isInteger(32))))
// CHECK-NEXT: return emitOpError("result #0 must be 32-bit integer");
diff --git a/mlir/test/mlir-tblgen/predicate.td b/mlir/test/mlir-tblgen/predicate.td
index 756505f1a1d..9dabf7955d7 100644
--- a/mlir/test/mlir-tblgen/predicate.td
+++ b/mlir/test/mlir-tblgen/predicate.td
@@ -34,12 +34,12 @@ def IdentityI32 : Op<"identity_i32", [PredOpTrait<
// CHECK-LABEL: Identity::verify
// Verify arg constraints.
-// CHECK: this->getInstruction()->getOperand(0)->getType().cast<TensorType>().getElementType().isInteger(32) ||
-// CHECK-SAME: this->getInstruction()->getOperand(0)->getType().cast<TensorType>().getElementType().isF32()
+// CHECK: this->getOperation()->getOperand(0)->getType().cast<TensorType>().getElementType().isInteger(32) ||
+// CHECK-SAME: this->getOperation()->getOperand(0)->getType().cast<TensorType>().getElementType().isF32()
// Verify tautology constraint.
-// CHECK: if (!((((*this->getInstruction()).getNumOperands() > std::max(0,0))) && (((*this->getInstruction()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getInstruction()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getInstruction()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType() == (*this->getInstruction()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType()))))
+// CHECK: if (!((((*this->getOperation()).getNumOperands() > std::max(0,0))) && (((*this->getOperation()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getOperation()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getOperation()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType() == (*this->getOperation()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType()))))
// CHECK-NEXT: return emitOpError("failed to verify that first operand is a vector or tensor with the same elemental type as itself");
// CHECK-LABEL: IdentityI32::verify
-// CHECK: if (!((((*this->getInstruction()).getNumOperands() > 0)) && (((*this->getInstruction()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getInstruction()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType().isInteger(32)))))
+// CHECK: if (!((((*this->getOperation()).getNumOperands() > 0)) && (((*this->getOperation()).getOperand(0)->getType().isa<VectorOrTensorType>())) && (((*this->getOperation()).getOperand(0)->getType().cast<VectorOrTensorType>().getElementType().isInteger(32)))))
// CHECK-NEXT: return emitOpError("failed to verify that first operand has i32 element type");
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 0ce9719a414..198aa2599df 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -478,12 +478,12 @@ void OpEmitter::genNamedOperandGetters() {
if (!operand.constraint.isVariadic()) {
auto &m = opClass.newMethod("Value *", operand.name);
- m.body() << " return this->getInstruction()->getOperand(" << i << ");\n";
+ m.body() << " return this->getOperation()->getOperand(" << i << ");\n";
} else {
assert(i + 1 == e && "only the last operand can be variadic");
const char *const code = R"(
- assert(getInstruction()->getNumOperands() >= {0});
+ assert(getOperation()->getNumOperands() >= {0});
return {std::next(operand_begin(), {0}), operand_end()};
)";
auto &m = opClass.newMethod("Instruction::operand_range", operand.name);
@@ -499,7 +499,7 @@ void OpEmitter::genNamedResultGetters() {
continue;
auto &m = opClass.newMethod("Value *", result.name);
- m.body() << " return this->getInstruction()->getResult(" << i << ");\n";
+ m.body() << " return this->getOperation()->getResult(" << i << ");\n";
}
}
@@ -846,7 +846,7 @@ void OpEmitter::genVerifier() {
auto description = value.constraint.getDescription();
body << " if (!("
<< formatv(value.constraint.getConditionTemplate(),
- "this->getInstruction()->get" +
+ "this->getOperation()->get" +
Twine(isOperand ? "Operand" : "Result") + "(" +
Twine(index) + ")->getType()")
<< "))\n";
@@ -869,7 +869,7 @@ void OpEmitter::genVerifier() {
for (auto &trait : op.getTraits()) {
if (auto t = dyn_cast<tblgen::PredOpTrait>(&trait)) {
body << " if (!("
- << formatv(t->getPredTemplate().c_str(), "(*this->getInstruction())")
+ << formatv(t->getPredTemplate().c_str(), "(*this->getOperation())")
<< "))\n";
body << " return emitOpError(\"failed to verify that "
<< t->getDescription() << "\");\n";
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 21276a9e4f9..23fb49501e1 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -184,9 +184,9 @@ void PatternEmitter::emitOpMatch(DagNode tree, int depth) {
// Handle nested DAG construct first
if (DagNode argTree = tree.getArgAsNestedDag(i)) {
os.indent(indent) << "{\n";
- os.indent(indent + 2) << formatv(
- "auto op{0} = op{1}->getOperand({2})->getDefiningInst();\n",
- depth + 1, depth, i);
+ os.indent(indent + 2)
+ << formatv("auto op{0} = op{1}->getOperand({2})->getDefiningOp();\n",
+ depth + 1, depth, i);
emitOpMatch(argTree, depth + 1);
os.indent(indent) << "}\n";
continue;
OpenPOWER on IntegriCloud