diff options
Diffstat (limited to 'mlir/lib/IR')
| -rw-r--r-- | mlir/lib/IR/AsmPrinter.cpp | 43 | ||||
| -rw-r--r-- | mlir/lib/IR/Block.cpp (renamed from mlir/lib/IR/StmtBlock.cpp) | 106 | ||||
| -rw-r--r-- | mlir/lib/IR/Builders.cpp | 10 | ||||
| -rw-r--r-- | mlir/lib/IR/BuiltinOps.cpp | 18 | ||||
| -rw-r--r-- | mlir/lib/IR/Function.cpp | 2 | ||||
| -rw-r--r-- | mlir/lib/IR/Operation.cpp | 8 | ||||
| -rw-r--r-- | mlir/lib/IR/Statement.cpp | 43 |
7 files changed, 112 insertions, 118 deletions
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp index 2ff7220f8ee..daaaee7010c 100644 --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -180,7 +180,7 @@ void ModuleState::visitExtFunction(const Function *fn) { void ModuleState::visitCFGFunction(const Function *fn) { visitType(fn->getType()); for (auto &block : *fn) { - for (auto &op : block.getStatements()) { + for (auto &op : block.getInstructions()) { if (auto *opInst = dyn_cast<OperationInst>(&op)) visitOperation(opInst); else { @@ -914,7 +914,7 @@ public: void print(const OperationInst *inst); void print(const ForStmt *stmt); void print(const IfStmt *stmt); - void print(const StmtBlock *block); + void print(const Block *block); void printOperation(const OperationInst *op); void printDefaultOp(const OperationInst *op); @@ -944,11 +944,11 @@ public: enum { nameSentinel = ~0U }; - void printBBName(const BasicBlock *block) { os << "bb" << getBBID(block); } + void printBlockName(const Block *block) { os << "bb" << getBlockID(block); } - unsigned getBBID(const BasicBlock *block) { - auto it = basicBlockIDs.find(block); - assert(it != basicBlockIDs.end() && "Block not in this function?"); + unsigned getBlockID(const Block *block) { + auto it = blockIDs.find(block); + assert(it != blockIDs.end() && "Block not in this function?"); return it->second; } @@ -964,7 +964,7 @@ public: protected: void numberValueID(const Value *value); - void numberValuesInBlock(const StmtBlock &block); + void numberValuesInBlock(const Block &block); void printValueID(const Value *value, bool printResultNo = true) const; private: @@ -976,7 +976,7 @@ private: DenseMap<const Value *, StringRef> valueNames; /// This is the block ID for each block in the current function. - DenseMap<const BasicBlock *, unsigned> basicBlockIDs; + DenseMap<const Block *, unsigned> blockIDs; /// This keeps track of all of the non-numeric names that are in flight, /// allowing us to check for duplicates. @@ -1007,10 +1007,10 @@ FunctionPrinter::FunctionPrinter(const Function *function, } /// Number all of the SSA values in the specified block list. -void FunctionPrinter::numberValuesInBlock(const StmtBlock &block) { +void FunctionPrinter::numberValuesInBlock(const Block &block) { // Each block gets a unique ID, and all of the instructions within it get // numbered as well. - basicBlockIDs[&block] = nextBlockID++; + blockIDs[&block] = nextBlockID++; for (auto *arg : block.getArguments()) numberValueID(arg); @@ -1154,6 +1154,7 @@ void FunctionPrinter::printMLFunctionSignature() { os << " : "; printType(arg->getType()); } + os << ')'; printFunctionResultType(type); } @@ -1174,11 +1175,11 @@ void FunctionPrinter::printOtherFunctionSignature() { printFunctionResultType(type); } -void FunctionPrinter::print(const StmtBlock *block) { +void FunctionPrinter::print(const Block *block) { // Print the block label and argument list, unless we are in an ML function. if (!block->getFunction()->isML()) { os.indent(currentIndent); - printBBName(block); + printBlockName(block); // Print the argument list if non-empty. if (!block->args_empty()) { @@ -1201,13 +1202,13 @@ void FunctionPrinter::print(const StmtBlock *block) { os << "\t// no predecessors"; } else if (auto *pred = block->getSinglePredecessor()) { os << "\t// pred: "; - printBBName(pred); + printBlockName(pred); } else { // We want to print the predecessors in increasing numeric order, not in // whatever order the use-list is in, so gather and sort them. SmallVector<unsigned, 4> predIDs; for (auto *pred : block->getPredecessors()) - predIDs.push_back(getBBID(pred)); + predIDs.push_back(getBlockID(pred)); llvm::array_pod_sort(predIDs.begin(), predIDs.end()); os << "\t// " << predIDs.size() << " preds: "; @@ -1218,7 +1219,8 @@ void FunctionPrinter::print(const StmtBlock *block) { } currentIndent += indentWidth; - for (auto &stmt : block->getStatements()) { + + for (auto &stmt : block->getInstructions()) { print(&stmt); os << '\n'; } @@ -1358,10 +1360,9 @@ void FunctionPrinter::printDefaultOp(const OperationInst *op) { void FunctionPrinter::printSuccessorAndUseList(const OperationInst *term, unsigned index) { - printBBName(term->getSuccessor(index)); + printBlockName(term->getSuccessor(index)); auto succOperands = term->getSuccessorOperands(index); - if (succOperands.begin() == succOperands.end()) return; @@ -1516,7 +1517,7 @@ void Instruction::dump() const { llvm::errs() << "\n"; } -void BasicBlock::print(raw_ostream &os) const { +void Block::print(raw_ostream &os) const { auto *function = getFunction(); if (!function) { os << "<<UNLINKED BLOCK>>\n"; @@ -1528,17 +1529,17 @@ void BasicBlock::print(raw_ostream &os) const { FunctionPrinter(function, modulePrinter).print(this); } -void BasicBlock::dump() const { print(llvm::errs()); } +void Block::dump() const { print(llvm::errs()); } /// Print out the name of the basic block without printing its body. -void StmtBlock::printAsOperand(raw_ostream &os, bool printType) { +void Block::printAsOperand(raw_ostream &os, bool printType) { if (!getFunction()) { os << "<<UNLINKED BLOCK>>\n"; return; } ModuleState state(getFunction()->getContext()); ModulePrinter modulePrinter(os, state); - FunctionPrinter(getFunction(), modulePrinter).printBBName(this); + FunctionPrinter(getFunction(), modulePrinter).printBlockName(this); } void Function::print(raw_ostream &os) const { diff --git a/mlir/lib/IR/StmtBlock.cpp b/mlir/lib/IR/Block.cpp index b551b1121a7..c7e84194c35 100644 --- a/mlir/lib/IR/StmtBlock.cpp +++ b/mlir/lib/IR/Block.cpp @@ -1,4 +1,4 @@ -//===- StmtBlock.cpp - MLIR Statement Instruction Classes -----------------===// +//===- Block.cpp - MLIR Block and BlockList Classes -----------------------===// // // Copyright 2019 The MLIR Authors. // @@ -15,12 +15,12 @@ // limitations under the License. // ============================================================================= -#include "mlir/IR/StmtBlock.h" +#include "mlir/IR/Block.h" #include "mlir/IR/Builders.h" #include "mlir/IR/BuiltinOps.h" using namespace mlir; -StmtBlock::~StmtBlock() { +Block::~Block() { clear(); llvm::DeleteContainerPointers(arguments); @@ -28,13 +28,13 @@ StmtBlock::~StmtBlock() { /// Returns the closest surrounding statement that contains this block or /// nullptr if this is a top-level statement block. -Statement *StmtBlock::getContainingStmt() { - return parent ? parent->getContainingStmt() : nullptr; +Statement *Block::getContainingInst() { + return parent ? parent->getContainingInst() : nullptr; } -Function *StmtBlock::getFunction() { - StmtBlock *block = this; - while (auto *stmt = block->getContainingStmt()) { +Function *Block::getFunction() { + Block *block = this; + while (auto *stmt = block->getContainingInst()) { block = stmt->getBlock(); if (!block) return nullptr; @@ -44,34 +44,34 @@ Function *StmtBlock::getFunction() { return nullptr; } -/// Returns 'stmt' if 'stmt' lies in this block, or otherwise finds the ancestor -/// statement of 'stmt' that lies in this block. Returns nullptr if the latter -/// fails. -const Statement * -StmtBlock::findAncestorStmtInBlock(const Statement &stmt) const { +/// Returns 'inst' if 'inst' lies in this block, or otherwise finds the +/// ancestor instruction of 'inst' that lies in this block. Returns nullptr if +/// the latter fails. +const Instruction * +Block::findAncestorInstInBlock(const Instruction &inst) const { // Traverse up the statement hierarchy starting from the owner of operand to // find the ancestor statement that resides in the block of 'forStmt'. - const auto *currStmt = &stmt; - while (currStmt->getBlock() != this) { - currStmt = currStmt->getParentStmt(); - if (!currStmt) + const auto *currInst = &inst; + while (currInst->getBlock() != this) { + currInst = currInst->getParentStmt(); + if (!currInst) return nullptr; } - return currStmt; + return currInst; } //===----------------------------------------------------------------------===// // Argument list management. //===----------------------------------------------------------------------===// -BlockArgument *StmtBlock::addArgument(Type type) { +BlockArgument *Block::addArgument(Type type) { auto *arg = new BlockArgument(type, this); arguments.push_back(arg); return arg; } /// Add one argument to the argument list for each type specified in the list. -auto StmtBlock::addArguments(ArrayRef<Type> types) +auto Block::addArguments(ArrayRef<Type> types) -> llvm::iterator_range<args_iterator> { arguments.reserve(arguments.size() + types.size()); auto initialSize = arguments.size(); @@ -81,7 +81,7 @@ auto StmtBlock::addArguments(ArrayRef<Type> types) return {arguments.data() + initialSize, arguments.data() + arguments.size()}; } -void StmtBlock::eraseArgument(unsigned index) { +void Block::eraseArgument(unsigned index) { assert(index < arguments.size()); // Delete the argument. @@ -100,12 +100,12 @@ void StmtBlock::eraseArgument(unsigned index) { // Terminator management //===----------------------------------------------------------------------===// -OperationInst *StmtBlock::getTerminator() { +OperationInst *Block::getTerminator() { if (empty()) return nullptr; // Check if the last instruction is a terminator. - auto &backInst = statements.back(); + auto &backInst = back(); auto *opStmt = dyn_cast<OperationInst>(&backInst); if (!opStmt || !opStmt->isTerminator()) return nullptr; @@ -113,14 +113,14 @@ OperationInst *StmtBlock::getTerminator() { } /// Return true if this block has no predecessors. -bool StmtBlock::hasNoPredecessors() const { return pred_begin() == pred_end(); } +bool Block::hasNoPredecessors() const { return pred_begin() == pred_end(); } // Indexed successor access. -unsigned StmtBlock::getNumSuccessors() const { +unsigned Block::getNumSuccessors() const { return getTerminator()->getNumSuccessors(); } -StmtBlock *StmtBlock::getSuccessor(unsigned i) { +Block *Block::getSuccessor(unsigned i) { return getTerminator()->getSuccessor(i); } @@ -130,7 +130,7 @@ StmtBlock *StmtBlock::getSuccessor(unsigned i) { /// Note that multiple edges from a single block (e.g. if you have a cond /// branch with the same block as the true/false destinations) is not /// considered to be a single predecessor. -StmtBlock *StmtBlock::getSinglePredecessor() { +Block *Block::getSinglePredecessor() { auto it = pred_begin(); if (it == pred_end()) return nullptr; @@ -143,9 +143,9 @@ StmtBlock *StmtBlock::getSinglePredecessor() { // Other //===----------------------------------------------------------------------===// -/// Unlink this BasicBlock from its Function and delete it. -void BasicBlock::eraseFromFunction() { - assert(getFunction() && "BasicBlock has no parent"); +/// Unlink this Block from its Function and delete it. +void Block::eraseFromFunction() { + assert(getFunction() && "Block has no parent"); getFunction()->getBlocks().erase(this); } @@ -156,21 +156,21 @@ void BasicBlock::eraseFromFunction() { /// the original basic block, an unconditional branch is added to the original /// block (going to the new block), and the rest of the instructions in the /// original block are moved to the new BB, including the old terminator. The -/// newly formed BasicBlock is returned. +/// newly formed Block is returned. /// /// This function invalidates the specified iterator. -BasicBlock *BasicBlock::splitBasicBlock(iterator splitBefore) { +Block *Block::splitBlock(iterator splitBefore) { // Start by creating a new basic block, and insert it immediate after this // one in the containing function. - auto newBB = new BasicBlock(); + auto newBB = new Block(); getFunction()->getBlocks().insert(++Function::iterator(this), newBB); auto branchLoc = splitBefore == end() ? getTerminator()->getLoc() : splitBefore->getLoc(); // Move all of the operations from the split point to the end of the function // into the new block. - newBB->getStatements().splice(newBB->end(), getStatements(), splitBefore, - end()); + newBB->getInstructions().splice(newBB->end(), getInstructions(), splitBefore, + end()); // Create an unconditional branch to the new block, and move our terminator // to the new block. @@ -179,58 +179,54 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator splitBefore) { } //===----------------------------------------------------------------------===// -// StmtBlockList +// BlockList //===----------------------------------------------------------------------===// -StmtBlockList::StmtBlockList(Function *container) : container(container) {} +BlockList::BlockList(Function *container) : container(container) {} -StmtBlockList::StmtBlockList(Statement *container) : container(container) {} +BlockList::BlockList(Statement *container) : container(container) {} -Function *StmtBlockList::getFunction() { return getContainingFunction(); } - -Statement *StmtBlockList::getContainingStmt() { +Statement *BlockList::getContainingInst() { return container.dyn_cast<Statement *>(); } -Function *StmtBlockList::getContainingFunction() { +Function *BlockList::getContainingFunction() { return container.dyn_cast<Function *>(); } -StmtBlockList *llvm::ilist_traits<::mlir::StmtBlock>::getContainingBlockList() { - size_t Offset(size_t( - &((StmtBlockList *)nullptr->*StmtBlockList::getSublistAccess(nullptr)))); - iplist<StmtBlock> *Anchor(static_cast<iplist<StmtBlock> *>(this)); - return reinterpret_cast<StmtBlockList *>(reinterpret_cast<char *>(Anchor) - - Offset); +BlockList *llvm::ilist_traits<::mlir::Block>::getContainingBlockList() { + size_t Offset( + size_t(&((BlockList *)nullptr->*BlockList::getSublistAccess(nullptr)))); + iplist<Block> *Anchor(static_cast<iplist<Block> *>(this)); + return reinterpret_cast<BlockList *>(reinterpret_cast<char *>(Anchor) - + Offset); } /// This is a trait method invoked when a basic block is added to a function. /// We keep the function pointer up to date. -void llvm::ilist_traits<::mlir::StmtBlock>::addNodeToList(StmtBlock *block) { +void llvm::ilist_traits<::mlir::Block>::addNodeToList(Block *block) { assert(!block->parent && "already in a function!"); block->parent = getContainingBlockList(); } /// This is a trait method invoked when an instruction is removed from a /// function. We keep the function pointer up to date. -void llvm::ilist_traits<::mlir::StmtBlock>::removeNodeFromList( - StmtBlock *block) { +void llvm::ilist_traits<::mlir::Block>::removeNodeFromList(Block *block) { assert(block->parent && "not already in a function!"); block->parent = nullptr; } /// This is a trait method invoked when an instruction is moved from one block /// to another. We keep the block pointer up to date. -void llvm::ilist_traits<::mlir::StmtBlock>::transferNodesFromList( - ilist_traits<StmtBlock> &otherList, block_iterator first, - block_iterator last) { +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 // pointer doesn't need to be updated. auto *curParent = getContainingBlockList(); if (curParent == otherList.getContainingBlockList()) return; - // Update the 'parent' member of each StmtBlock. + // Update the 'parent' member of each Block. for (; first != last; ++first) first->parent = curParent; } diff --git a/mlir/lib/IR/Builders.cpp b/mlir/lib/IR/Builders.cpp index 81a3b7c2950..a9eb6fe8c8a 100644 --- a/mlir/lib/IR/Builders.cpp +++ b/mlir/lib/IR/Builders.cpp @@ -275,8 +275,8 @@ AffineMap Builder::getShiftedAffineMap(AffineMap map, int64_t shift) { /// 'insertBefore' basic block is passed, the block will be placed before the /// specified block. If not, the block will be appended to the end of the /// current function. -StmtBlock *FuncBuilder::createBlock(StmtBlock *insertBefore) { - StmtBlock *b = new StmtBlock(); +Block *FuncBuilder::createBlock(Block *insertBefore) { + Block *b = new Block(); // If we are supposed to insert before a specific block, do so, otherwise add // the block to the end of the function. @@ -294,7 +294,7 @@ OperationInst *FuncBuilder::createOperation(const OperationState &state) { auto *op = OperationInst::create(state.location, state.name, state.operands, state.types, state.attributes, state.successors, context); - block->getStatements().insert(insertPoint, op); + block->getInstructions().insert(insertPoint, op); return op; } @@ -303,7 +303,7 @@ ForStmt *FuncBuilder::createFor(Location location, ArrayRef<Value *> lbOperands, AffineMap ubMap, int64_t step) { auto *stmt = ForStmt::create(location, lbOperands, lbMap, ubOperands, ubMap, step); - block->getStatements().insert(insertPoint, stmt); + block->getInstructions().insert(insertPoint, stmt); return stmt; } @@ -317,6 +317,6 @@ ForStmt *FuncBuilder::createFor(Location location, int64_t lb, int64_t ub, IfStmt *FuncBuilder::createIf(Location location, ArrayRef<Value *> operands, IntegerSet set) { auto *stmt = IfStmt::create(location, operands, set); - block->getStatements().insert(insertPoint, stmt); + block->getInstructions().insert(insertPoint, stmt); return stmt; } diff --git a/mlir/lib/IR/BuiltinOps.cpp b/mlir/lib/IR/BuiltinOps.cpp index 51596a9f09e..a0264fc11b0 100644 --- a/mlir/lib/IR/BuiltinOps.cpp +++ b/mlir/lib/IR/BuiltinOps.cpp @@ -167,13 +167,13 @@ bool AffineApplyOp::constantFold(ArrayRef<Attribute> operandConstants, // BranchOp //===----------------------------------------------------------------------===// -void BranchOp::build(Builder *builder, OperationState *result, BasicBlock *dest, +void BranchOp::build(Builder *builder, OperationState *result, Block *dest, ArrayRef<Value *> operands) { result->addSuccessor(dest, operands); } bool BranchOp::parse(OpAsmParser *parser, OperationState *result) { - BasicBlock *dest; + Block *dest; SmallVector<Value *, 4> destOperands; if (parser->parseSuccessorAndUseList(dest, destOperands)) return true; @@ -193,9 +193,9 @@ bool BranchOp::verify() const { return false; } -BasicBlock *BranchOp::getDest() { return getInstruction()->getSuccessor(0); } +Block *BranchOp::getDest() { return getInstruction()->getSuccessor(0); } -void BranchOp::setDest(BasicBlock *block) { +void BranchOp::setDest(Block *block) { return getInstruction()->setSuccessor(block, 0); } @@ -208,8 +208,8 @@ void BranchOp::eraseOperand(unsigned index) { //===----------------------------------------------------------------------===// void CondBranchOp::build(Builder *builder, OperationState *result, - Value *condition, BasicBlock *trueDest, - ArrayRef<Value *> trueOperands, BasicBlock *falseDest, + Value *condition, Block *trueDest, + ArrayRef<Value *> trueOperands, Block *falseDest, ArrayRef<Value *> falseOperands) { result->addOperands(condition); result->addSuccessor(trueDest, trueOperands); @@ -218,7 +218,7 @@ void CondBranchOp::build(Builder *builder, OperationState *result, bool CondBranchOp::parse(OpAsmParser *parser, OperationState *result) { SmallVector<Value *, 4> destOperands; - BasicBlock *dest; + Block *dest; OpAsmParser::OperandType condInfo; // Parse the condition. @@ -263,11 +263,11 @@ bool CondBranchOp::verify() const { return false; } -BasicBlock *CondBranchOp::getTrueDest() { +Block *CondBranchOp::getTrueDest() { return getInstruction()->getSuccessor(trueIndex); } -BasicBlock *CondBranchOp::getFalseDest() { +Block *CondBranchOp::getFalseDest() { return getInstruction()->getSuccessor(falseIndex); } diff --git a/mlir/lib/IR/Function.cpp b/mlir/lib/IR/Function.cpp index 0e777c65f23..cbe84e10247 100644 --- a/mlir/lib/IR/Function.cpp +++ b/mlir/lib/IR/Function.cpp @@ -37,7 +37,7 @@ Function::Function(Kind kind, Location location, StringRef name, // TODO(clattner): Unify this behavior. if (kind == Kind::MLFunc) { // The body of an ML Function always has one block. - auto *entry = new StmtBlock(); + auto *entry = new Block(); blocks.push_back(entry); // Initialize the arguments. diff --git a/mlir/lib/IR/Operation.cpp b/mlir/lib/IR/Operation.cpp index 23e54b3638e..ccd7d65f7c8 100644 --- a/mlir/lib/IR/Operation.cpp +++ b/mlir/lib/IR/Operation.cpp @@ -245,7 +245,7 @@ bool OpTrait::impl::verifySameOperandsAndResultType(const OperationInst *op) { static bool verifyBBArguments( llvm::iterator_range<OperationInst::const_operand_iterator> operands, - const BasicBlock *destBB, const OperationInst *op) { + const Block *destBB, const OperationInst *op) { unsigned operandCount = std::distance(operands.begin(), operands.end()); if (operandCount != destBB->getNumArguments()) return op->emitError("branch has " + Twine(operandCount) + @@ -277,11 +277,11 @@ static bool verifyTerminatorSuccessors(const OperationInst *op) { bool OpTrait::impl::verifyIsTerminator(const OperationInst *op) { // Verify that the operation is at the end of the respective parent block. if (op->getFunction()->isML()) { - StmtBlock *block = op->getBlock(); - if (!block || block->getContainingStmt() || &block->back() != op) + Block *block = op->getBlock(); + if (!block || block->getContainingInst() || &block->back() != op) return op->emitOpError("must be the last statement in the ML function"); } else { - const BasicBlock *block = op->getBlock(); + const Block *block = op->getBlock(); if (!block || &block->back() != op) return op->emitOpError( "must be the last instruction in the parent basic block."); diff --git a/mlir/lib/IR/Statement.cpp b/mlir/lib/IR/Statement.cpp index 96b44600460..6bd9944bb65 100644 --- a/mlir/lib/IR/Statement.cpp +++ b/mlir/lib/IR/Statement.cpp @@ -49,7 +49,7 @@ template <> unsigned InstOperand::getOperandNumber() const { } /// Return which operand this is in the operand list. -template <> unsigned StmtBlockOperand::getOperandNumber() const { +template <> unsigned BlockOperand::getOperandNumber() const { return this - &getOwner()->getBlockOperands()[0]; } @@ -79,7 +79,7 @@ void Statement::destroy() { } Statement *Statement::getParentStmt() const { - return block ? block->getContainingStmt() : nullptr; + return block ? block->getContainingInst() : nullptr; } Function *Statement::getFunction() const { @@ -191,12 +191,10 @@ void llvm::ilist_traits<::mlir::Statement>::deleteNode(Statement *stmt) { stmt->destroy(); } -StmtBlock *llvm::ilist_traits<::mlir::Statement>::getContainingBlock() { - size_t Offset( - size_t(&((StmtBlock *)nullptr->*StmtBlock::getSublistAccess(nullptr)))); +Block *llvm::ilist_traits<::mlir::Statement>::getContainingBlock() { + size_t Offset(size_t(&((Block *)nullptr->*Block::getSublistAccess(nullptr)))); iplist<Statement> *Anchor(static_cast<iplist<Statement> *>(this)); - return reinterpret_cast<StmtBlock *>(reinterpret_cast<char *>(Anchor) - - Offset); + return reinterpret_cast<Block *>(reinterpret_cast<char *>(Anchor) - Offset); } /// This is a trait method invoked when a statement is added to a block. We @@ -221,7 +219,7 @@ void llvm::ilist_traits<::mlir::Statement>::transferNodesFromList( stmt_iterator last) { // If we are transferring statements within the same block, the block // pointer doesn't need to be updated. - StmtBlock *curParent = getContainingBlock(); + Block *curParent = getContainingBlock(); if (curParent == otherList.getContainingBlock()) return; @@ -230,11 +228,11 @@ void llvm::ilist_traits<::mlir::Statement>::transferNodesFromList( first->block = curParent; } -/// Remove this statement (and its descendants) from its StmtBlock and delete +/// Remove this statement (and its descendants) from its Block and delete /// all of them. void Statement::erase() { assert(getBlock() && "Statement has no block"); - getBlock()->getStatements().erase(this); + getBlock()->getInstructions().erase(this); } /// Unlink this statement from its current block and insert it right before @@ -246,10 +244,10 @@ void Statement::moveBefore(Statement *existingStmt) { /// Unlink this operation instruction from its current basic block and insert /// it right before `iterator` in the specified basic block. -void Statement::moveBefore(StmtBlock *block, +void Statement::moveBefore(Block *block, llvm::iplist<Statement>::iterator iterator) { - block->getStatements().splice(iterator, getBlock()->getStatements(), - getIterator()); + block->getInstructions().splice(iterator, getBlock()->getInstructions(), + getIterator()); } /// This drops all operand uses from this instruction, which is an essential @@ -273,7 +271,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, ArrayRef<Value *> operands, ArrayRef<Type> resultTypes, ArrayRef<NamedAttribute> attributes, - ArrayRef<StmtBlock *> successors, + ArrayRef<Block *> successors, MLIRContext *context) { unsigned numSuccessors = successors.size(); @@ -282,7 +280,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, unsigned numOperands = operands.size() - numSuccessors; auto byteSize = - totalSizeToAlloc<InstResult, StmtBlockOperand, unsigned, InstOperand>( + totalSizeToAlloc<InstResult, BlockOperand, unsigned, InstOperand>( resultTypes.size(), numSuccessors, numSuccessors, numOperands); void *rawMem = malloc(byteSize); @@ -340,7 +338,7 @@ OperationInst *OperationInst::create(Location location, OperationName name, } new (&instBlockOperands[currentSuccNum]) - StmtBlockOperand(stmt, successors[currentSuccNum]); + BlockOperand(stmt, successors[currentSuccNum]); *succOperandCountIt = 0; ++currentSuccNum; continue; @@ -382,7 +380,7 @@ OperationInst::~OperationInst() { // Explicitly run the destructors for the successors. if (isTerminator()) for (auto &successor : getBlockOperands()) - successor.~StmtBlockOperand(); + successor.~BlockOperand(); } /// Return true if there are no users of any results of this operation. @@ -420,7 +418,7 @@ MLIRContext *OperationInst::getContext() const { bool OperationInst::isReturn() const { return isa<ReturnOp>(); } -void OperationInst::setSuccessor(BasicBlock *block, unsigned index) { +void OperationInst::setSuccessor(Block *block, unsigned index) { assert(index < getNumSuccessors()); getBlockOperands()[index].set(block); } @@ -559,7 +557,7 @@ ForStmt::ForStmt(Location location, unsigned numOperands, AffineMap lbMap, body(this), lbMap(lbMap), ubMap(ubMap), step(step) { // The body of a for stmt always has one block. - body.push_back(new StmtBlock()); + body.push_back(new Block()); operands.reserve(numOperands); } @@ -679,7 +677,7 @@ IfStmt::IfStmt(Location location, unsigned numOperands, IntegerSet set) operands.reserve(numOperands); // The then of an 'if' stmt always has one block. - thenClause.push_back(new StmtBlock()); + thenClause.push_back(new Block()); } IfStmt::~IfStmt() { @@ -736,7 +734,7 @@ Statement *Statement::clone(DenseMap<const Value *, Value *> &operandMap, }; SmallVector<Value *, 8> operands; - SmallVector<StmtBlock *, 2> successors; + SmallVector<Block *, 2> successors; if (auto *opStmt = dyn_cast<OperationInst>(this)) { operands.reserve(getNumOperands() + opStmt->getNumSuccessors()); @@ -758,8 +756,7 @@ Statement *Statement::clone(DenseMap<const Value *, Value *> &operandMap, successors.reserve(opStmt->getNumSuccessors()); for (unsigned succ = 0, e = opStmt->getNumSuccessors(); succ != e; ++succ) { - successors.push_back( - const_cast<StmtBlock *>(opStmt->getSuccessor(succ))); + successors.push_back(const_cast<Block *>(opStmt->getSuccessor(succ))); // Add sentinel to delineate successor operands. operands.push_back(nullptr); |

