Minor renamings: Trim the "Stmt" prefix off

StmtSuccessorIterator/StmtSuccessorIterator, and rename and move the
CFGFunctionViewGraph pass to ViewFunctionGraph.

This is step 13/n towards merging instructions and statements, NFC.

PiperOrigin-RevId: 227069438
This commit is contained in:
Chris Lattner 2018-12-27 15:27:05 -08:00 committed by jpienaar
parent 294687ef59
commit 4fbcd1ac52
5 changed files with 40 additions and 44 deletions

View File

@ -30,14 +30,10 @@ class StmtBlockList;
using CFGFunction = Function;
using MLFunction = Function;
// TODO(clattner): drop the Stmt prefixes on these once BasicBlock's versions of
// these go away.
template <typename BlockType> class StmtPredecessorIterator;
template <typename BlockType> class StmtSuccessorIterator;
template <typename BlockType> class PredecessorIterator;
template <typename BlockType> class SuccessorIterator;
/// Statement block represents an ordered list of statements, with the order
/// being the contiguous lexical order in which the statements appear as
/// children of a parent statement in the ML Function.
/// Blocks represents an ordered list of Instructions.
class StmtBlock
: public IRObjectWithUseList,
public llvm::ilist_node_with_parent<StmtBlock, StmtBlockList> {
@ -175,12 +171,12 @@ public:
//===--------------------------------------------------------------------===//
// Predecessor iteration.
using const_pred_iterator = StmtPredecessorIterator<const StmtBlock>;
using const_pred_iterator = PredecessorIterator<const StmtBlock>;
const_pred_iterator pred_begin() const;
const_pred_iterator pred_end() const;
llvm::iterator_range<const_pred_iterator> getPredecessors() const;
using pred_iterator = StmtPredecessorIterator<StmtBlock>;
using pred_iterator = PredecessorIterator<StmtBlock>;
pred_iterator pred_begin();
pred_iterator pred_end();
llvm::iterator_range<pred_iterator> getPredecessors();
@ -208,12 +204,12 @@ public:
StmtBlock *getSuccessor(unsigned i);
// Successor iteration.
using const_succ_iterator = StmtSuccessorIterator<const StmtBlock>;
using const_succ_iterator = SuccessorIterator<const StmtBlock>;
const_succ_iterator succ_begin() const;
const_succ_iterator succ_end() const;
llvm::iterator_range<const_succ_iterator> getSuccessors() const;
using succ_iterator = StmtSuccessorIterator<StmtBlock>;
using succ_iterator = SuccessorIterator<StmtBlock>;
succ_iterator succ_begin();
succ_iterator succ_end();
llvm::iterator_range<succ_iterator> getSuccessors();
@ -378,19 +374,19 @@ private:
/// operand, we can get the terminator that contains it, and it's parent block
/// is the predecessor.
template <typename BlockType>
class StmtPredecessorIterator
: public llvm::iterator_facade_base<StmtPredecessorIterator<BlockType>,
class PredecessorIterator
: public llvm::iterator_facade_base<PredecessorIterator<BlockType>,
std::forward_iterator_tag,
BlockType *> {
public:
StmtPredecessorIterator(StmtBlockOperand *firstOperand)
PredecessorIterator(StmtBlockOperand *firstOperand)
: bbUseIterator(firstOperand) {}
StmtPredecessorIterator &operator=(const StmtPredecessorIterator &rhs) {
PredecessorIterator &operator=(const PredecessorIterator &rhs) {
bbUseIterator = rhs.bbUseIterator;
}
bool operator==(const StmtPredecessorIterator &rhs) const {
bool operator==(const PredecessorIterator &rhs) const {
return bbUseIterator == rhs.bbUseIterator;
}
@ -400,7 +396,7 @@ public:
return bbUseIterator.getUser()->getBlock();
}
StmtPredecessorIterator &operator++() {
PredecessorIterator &operator++() {
++bbUseIterator;
return *this;
}
@ -447,22 +443,22 @@ inline auto StmtBlock::getPredecessors()
/// This template implments the successor iterators for StmtBlock.
template <typename BlockType>
class StmtSuccessorIterator final
: public IndexedAccessorIterator<StmtSuccessorIterator<BlockType>,
BlockType, BlockType> {
class SuccessorIterator final
: public IndexedAccessorIterator<SuccessorIterator<BlockType>, BlockType,
BlockType> {
public:
/// Initializes the result iterator to the specified index.
StmtSuccessorIterator(BlockType *object, unsigned index)
: IndexedAccessorIterator<StmtSuccessorIterator<BlockType>, BlockType,
SuccessorIterator(BlockType *object, unsigned index)
: IndexedAccessorIterator<SuccessorIterator<BlockType>, BlockType,
BlockType>(object, index) {}
StmtSuccessorIterator(const StmtSuccessorIterator &other)
: StmtSuccessorIterator(other.object, other.index) {}
SuccessorIterator(const SuccessorIterator &other)
: SuccessorIterator(other.object, other.index) {}
/// Support converting to the const variant. This will be a no-op for const
/// variant.
operator StmtSuccessorIterator<const BlockType>() const {
return StmtSuccessorIterator<const BlockType>(this->object, this->index);
operator SuccessorIterator<const BlockType>() const {
return SuccessorIterator<const BlockType>(this->object, this->index);
}
BlockType *operator*() const {

View File

@ -1,4 +1,4 @@
//===- CFGFunctionViewGraph.h - View/write graphviz graphs ------*- C++ -*-===//
//===- ViewFunctionGraph.h - View/write graphviz graphs ---------*- C++ -*-===//
//
// Copyright 2019 The MLIR Authors.
//
@ -15,29 +15,29 @@
// limitations under the License.
// =============================================================================
//
// Defines interface to produce Graphviz outputs of MLIR CFGFunctions.
// Defines interface to produce Graphviz outputs of MLIR Functions.
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_TRANSFORMS_CFGFUNCTIONVIEWGRAPH_H_
#define MLIR_TRANSFORMS_CFGFUNCTIONVIEWGRAPH_H_
#ifndef MLIR_TRANSFORMS_VIEWFUNCTIONGRAPH_H_
#define MLIR_TRANSFORMS_VIEWFUNCTIONGRAPH_H_
#include "mlir/IR/Function.h"
#include "mlir/Pass.h"
#include "llvm/ADT/Twine.h"
#include "mlir/Support/LLVM.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
namespace mlir {
class Function;
class FunctionPass;
/// Displays the CFG in a window. This is for use from the debugger and
/// depends on Graphviz to generate the graph.
void viewGraph(const CFGFunction &function, const Twine &name,
void viewGraph(const Function &function, const Twine &name,
bool shortNames = false, const Twine &title = "",
llvm::GraphProgram::Name program = llvm::GraphProgram::DOT);
llvm::raw_ostream &writeGraph(llvm::raw_ostream &os,
const CFGFunction *function,
llvm::raw_ostream &writeGraph(llvm::raw_ostream &os, const Function *function,
bool shortNames = false, const Twine &title = "");
/// Creates a pass to print CFG graphs.
@ -47,4 +47,4 @@ FunctionPass *createPrintCFGGraphPass(llvm::raw_ostream &os = llvm::errs(),
} // end namespace mlir
#endif // MLIR_TRANSFORMS_CFGFUNCTIONVIEWGRAPH_H_
#endif // MLIR_TRANSFORMS_VIEWFUNCTIONGRAPH_H_

View File

@ -60,7 +60,7 @@ static bool isMemRefDereferencingOp(const Operation &op) {
// extra operands, note that 'indexRemap' would just be applied to the existing
// indices (%i, %j).
//
// TODO(mlir-team): extend this for Value/ CFGFunctions. Can also be easily
// TODO(mlir-team): extend this for CFG Functions. Can also be easily
// extended to add additional indices at any position.
bool mlir::replaceAllMemRefUsesWith(const Value *oldMemRef, Value *newMemRef,
ArrayRef<Value *> extraIndices,
@ -313,9 +313,8 @@ OperationStmt *mlir::createAffineComputationSlice(OperationStmt *opStmt) {
}
void mlir::forwardSubstitute(OpPointer<AffineApplyOp> affineApplyOp) {
if (affineApplyOp->getOperation()->getOperationFunction()->getKind() !=
Function::Kind::MLFunc) {
// TODO: Support forward substitution for CFGFunctions.
if (!affineApplyOp->getOperation()->getOperationFunction()->isML()) {
// TODO: Support forward substitution for CFG style functions.
return;
}
auto *opStmt = cast<OperationStmt>(affineApplyOp->getOperation());

View File

@ -1,4 +1,4 @@
//===- CFGFunctionViewGraph.cpp - View/write graphviz graphs --------------===//
//===- ViewFunctionGraph.cpp - View/write graphviz graphs -----------------===//
//
// Copyright 2019 The MLIR Authors.
//
@ -15,8 +15,9 @@
// limitations under the License.
// =============================================================================
#include "mlir/Transforms/CFGFunctionViewGraph.h"
#include "mlir/Transforms/ViewFunctionGraph.h"
#include "mlir/IR/FunctionGraphTraits.h"
#include "mlir/Pass.h"
using namespace mlir;

View File

@ -33,8 +33,8 @@
#include "mlir/TensorFlow/ControlFlowOps.h"
#include "mlir/TensorFlow/Passes.h"
#include "mlir/TensorFlowLite/Passes.h"
#include "mlir/Transforms/CFGFunctionViewGraph.h"
#include "mlir/Transforms/Passes.h"
#include "mlir/Transforms/ViewFunctionGraph.h"
#include "mlir/XLA/Passes.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FileUtilities.h"