/// Create ML function builder and set insertion point to the given statement,
/// which will cause subsequent insertions to go right before it.
MLFuncBuilder(Statement *stmt)
- // TODO: Eliminate findFunction from this.
- : MLFuncBuilder(stmt->findFunction()) {
+ // TODO: Eliminate getFunction from this.
+ : MLFuncBuilder(stmt->getFunction()) {
setInsertionPoint(stmt);
}
MLFuncBuilder(StmtBlock *block)
- // TODO: Eliminate findFunction from this.
- : MLFuncBuilder(block->findFunction()) {
+ // TODO: Eliminate getFunction from this.
+ : MLFuncBuilder(block->getFunction()) {
setInsertionPoint(block, block->end());
}
MLFuncBuilder(StmtBlock *block, StmtBlock::iterator insertPoint)
- // TODO: Eliminate findFunction from this.
- : MLFuncBuilder(block->findFunction()) {
+ // TODO: Eliminate getFunction from this.
+ : MLFuncBuilder(block->getFunction()) {
setInsertionPoint(block, insertPoint);
}
/// Returns the function that this statement is part of.
/// The function is determined by traversing the chain of parent statements.
/// Returns nullptr if the statement is unlinked.
- MLFunction *findFunction() const;
+ MLFunction *getFunction() const;
/// Destroys this statement and its subclass data.
void destroy();
}
/// Resolve base class ambiguity.
- using Statement::findFunction;
+ using Statement::getFunction;
/// Operand iterators.
using operand_iterator = OperandIterator<ForStmt, MLValue>;
return const_cast<StmtBlock *>(this)->getContainingStmt();
}
- /// Returns the function that this statement block is part of.
- /// The function is determined by traversing the chain of parent statements.
- MLFunction *findFunction();
- const MLFunction *findFunction() const {
- return const_cast<StmtBlock *>(this)->findFunction();
+ /// Returns the function that this statement block is part of. The function
+ /// is determined by traversing the chain of parent statements.
+ MLFunction *getFunction();
+ const MLFunction *getFunction() const {
+ return const_cast<StmtBlock *>(this)->getFunction();
}
//===--------------------------------------------------------------------===//
if (&a == &b)
return false;
- if (a.findFunction() != b.findFunction())
+ if (a.getFunction() != b.getFunction())
return false;
if (a.getBlock() == b.getBlock()) {
case SSAValueKind::BlockArgument:
// If this is an argument to the function, give it an 'arg' name.
if (auto *block = cast<BlockArgument>(value)->getOwner())
- if (auto *fn = block->findFunction())
+ if (auto *fn = block->getFunction())
if (&fn->getBlockList().front() == block) {
specialName << "arg" << nextArgumentID++;
break;
}
void Statement::print(raw_ostream &os) const {
- MLFunction *function = findFunction();
+ MLFunction *function = getFunction();
if (!function) {
os << "<<UNLINKED STATEMENT>>\n";
return;
void Statement::dump() const { print(llvm::errs()); }
void StmtBlock::printBlock(raw_ostream &os) const {
- const MLFunction *function = findFunction();
+ const MLFunction *function = getFunction();
ModuleState state(function->getContext());
ModulePrinter modulePrinter(os, state);
MLFunctionPrinter(function, modulePrinter).print(this);
bool ReturnOp::verify() const {
const Function *function;
if (auto *stmt = dyn_cast<OperationStmt>(getOperation()))
- function = stmt->getBlock()->findFunction();
+ function = stmt->getFunction();
else
function = cast<Instruction>(getOperation())->getFunction();
Function *Operation::getOperationFunction() {
if (auto *inst = llvm::dyn_cast<Instruction>(this))
return inst->getFunction();
- return llvm::cast<OperationStmt>(this)->findFunction();
+ return llvm::cast<OperationStmt>(this)->getFunction();
}
/// Return the number of operands this operation has.
case SSAValueKind::BlockArgument:
return cast<BlockArgument>(this)->getFunction();
case SSAValueKind::StmtResult:
- return getDefiningStmt()->findFunction();
+ return getDefiningStmt()->getFunction();
case SSAValueKind::ForStmt:
- return cast<ForStmt>(this)->findFunction();
+ return cast<ForStmt>(this)->getFunction();
}
}
/// Return the function that this argument is defined in.
MLFunction *BlockArgument::getFunction() {
if (auto *owner = getOwner())
- return owner->findFunction();
+ return owner->getFunction();
return nullptr;
}
return block ? block->getContainingStmt() : nullptr;
}
-MLFunction *Statement::findFunction() const {
- return block ? block->findFunction() : nullptr;
+MLFunction *Statement::getFunction() const {
+ return block ? block->getFunction() : nullptr;
}
MLValue *Statement::getOperand(unsigned idx) {
// In the very odd case where we have no operands or results, fall back to
// doing a find.
- return findFunction()->getContext();
+ return getFunction()->getContext();
}
bool OperationStmt::isReturn() const { return isa<ReturnOp>(); }
// Check for degenerate case of if statement with no operands.
// This is unlikely, but legal.
if (operands.empty())
- return findFunction()->getContext();
+ return getFunction()->getContext();
return getOperand(0)->getType().getContext();
}
return parent ? parent->getContainingStmt() : nullptr;
}
-MLFunction *StmtBlock::findFunction() {
+MLFunction *StmtBlock::getFunction() {
StmtBlock *block = this;
while (auto *stmt = block->getContainingStmt()) {
block = stmt->getBlock();
MLFuncBuilder *b = region.isWrite() ? &epilogue : &prologue;
// Builder to create constants at the top level.
- MLFuncBuilder top(forStmt->findFunction());
+ MLFuncBuilder top(forStmt->getFunction());
auto loc = forStmt->getLoc();
auto *memref = region.memref;
// Replaces all IV uses to its single iteration value.
if (!forStmt->use_empty()) {
if (forStmt->hasConstantLowerBound()) {
- auto *mlFunc = forStmt->findFunction();
+ auto *mlFunc = forStmt->getFunction();
MLFuncBuilder topBuilder(&mlFunc->getBody()->front());
auto constOp = topBuilder.create<ConstantIndexOp>(
forStmt->getLoc(), forStmt->getConstantLowerBound());