CIRCT  19.0.0git
Classes | Namespaces | Macros | Functions
CFToHandshake.cpp File Reference
#include "circt/Conversion/CFToHandshake.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Dialect/Handshake/HandshakeUtils.h"
#include "circt/Support/BackedgeBuilder.h"
#include "circt/Transforms/Passes.h"
#include "mlir/Analysis/CFGLoopInfo.h"
#include "mlir/Conversion/AffineToStandard/AffineToStandard.h"
#include "mlir/Dialect/Affine/Analysis/AffineAnalysis.h"
#include "mlir/Dialect/Affine/Analysis/AffineStructures.h"
#include "mlir/Dialect/Affine/IR/AffineOps.h"
#include "mlir/Dialect/Affine/IR/AffineValueMap.h"
#include "mlir/Dialect/Affine/Utils.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/ControlFlow/IR/ControlFlowOps.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/Dialect/SCF/IR/SCF.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/Types.h"
#include "mlir/IR/Value.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/Passes.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/raw_ostream.h"
#include <list>
#include <map>
#include "circt/Conversion/Passes.h.inc"
Include dependency graph for CFToHandshake.cpp:

Go to the source code of this file.

Classes

class  LowerRegionTarget
 
struct  PartialLowerRegion
 Allows to partially lower a region by matching on the parent operation to then call the provided partial lowering function with the region and the rewriter. More...
 
struct  BlockControlTerm
 Holds information about an handshake "basic block terminator" control operation. More...
 

Namespaces

 circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
 

Macros

#define GEN_PASS_DEF_CFTOHANDSHAKE
 
#define GEN_PASS_DEF_HANDSHAKEREMOVEBLOCK
 

Functions

template<typename TOp >
static LogicalResult partiallyLowerOp (const std::function< LogicalResult(TOp, ConversionPatternRewriter &)> &loweringFunc, MLIRContext *ctx, TOp op)
 
void removeBasicBlocks (handshake::FuncOp funcOp)
 
static LogicalResult isValidMemrefType (Location loc, mlir::MemRefType type)
 
static unsigned getBlockPredecessorCount (Block *block)
 
static Value getMergeOperand (HandshakeLowering::MergeOpInfo mergeInfo, Block *predBlock)
 
static void removeBlockOperands (Region &f)
 
template<typename TOp >
static Operation * getFirstOp (Block *block)
 Returns the first occurance of an operation of type TOp, else, returns null op. More...
 
static Operation * getControlMerge (Block *block)
 
static ConditionalBranchOp getControlCondBranch (Block *block)
 
static void reconnectMergeOps (Region &r, HandshakeLowering::BlockOps blockMerges, HandshakeLowering::ValueMap &mergePairs)
 
static bool isAllocOp (Operation *op)
 
static bool isLiveOut (Value val)
 
static int getBranchCount (Value val, Block *block)
 
static bool loopsHaveSingleExit (CFGLoopInfo &loopInfo)
 
static Operation * findBranchToBlock (Block *block)
 
static Value getOperandFromBlock (MuxOp mux, Block *block)
 
static std::vector< Value > getSortedInputs (ControlMergeOp cmerge, MuxOp mux)
 
static Value getSuccResult (Operation *termOp, Operation *newOp, Block *succBlock)
 
static BlockControlTerm getBlockControlTerminator (Block *block)
 
static LogicalResult getOpMemRef (Operation *op, Value &out)
 
static bool isMemoryOp (Operation *op)
 
static SmallVector< Value, 8 > getResultsToMemory (Operation *op)
 
static void addLazyForks (Region &f, ConversionPatternRewriter &rewriter)
 
static void removeUnusedAllocOps (Region &r, ConversionPatternRewriter &rewriter)
 
static void addJoinOps (ConversionPatternRewriter &rewriter, ArrayRef< BlockControlTerm > controlTerms)
 
static std::vector< BlockControlTermgetControlTerminators (ArrayRef< Operation * > memOps)
 
static void addValueToOperands (Operation *op, Value val)
 
static void setLoadDataInputs (ArrayRef< Operation * > memOps, Operation *memOp)
 
static LogicalResult setJoinControlInputs (ArrayRef< Operation * > memOps, Operation *memOp, int offset, ArrayRef< int > cntrlInd)
 
static LogicalResult maximizeSSANoMem (Region &r, ConversionPatternRewriter &rewriter)
 Converts every value in the region into maximal SSA form, unless the value is a block argument of type MemRefType or the result of an allocation operation. More...
 
static LogicalResult lowerFuncOp (func::FuncOp funcOp, MLIRContext *ctx, bool sourceConstants, bool disableTaskPipelining)
 

Macro Definition Documentation

◆ GEN_PASS_DEF_CFTOHANDSHAKE

#define GEN_PASS_DEF_CFTOHANDSHAKE

Definition at line 50 of file CFToHandshake.cpp.

◆ GEN_PASS_DEF_HANDSHAKEREMOVEBLOCK

#define GEN_PASS_DEF_HANDSHAKEREMOVEBLOCK

Definition at line 51 of file CFToHandshake.cpp.

Function Documentation

◆ addJoinOps()

static void addJoinOps ( ConversionPatternRewriter &  rewriter,
ArrayRef< BlockControlTerm controlTerms 
)
static

◆ addLazyForks()

static void addLazyForks ( Region &  f,
ConversionPatternRewriter &  rewriter 
)
static

◆ addValueToOperands()

static void addValueToOperands ( Operation *  op,
Value  val 
)
static

◆ findBranchToBlock()

static Operation* findBranchToBlock ( Block *  block)
static

Definition at line 623 of file CFToHandshake.cpp.

◆ getBlockControlTerminator()

static BlockControlTerm getBlockControlTerminator ( Block *  block)
static

Definition at line 1232 of file CFToHandshake.cpp.

Referenced by addLazyForks(), getControlTerminators(), and setJoinControlInputs().

◆ getBlockPredecessorCount()

static unsigned getBlockPredecessorCount ( Block *  block)
static

◆ getBranchCount()

static int getBranchCount ( Value  val,
Block *  block 
)
static

◆ getControlCondBranch()

static ConditionalBranchOp getControlCondBranch ( Block *  block)
static

Definition at line 432 of file CFToHandshake.cpp.

◆ getControlMerge()

static Operation* getControlMerge ( Block *  block)
static

Definition at line 428 of file CFToHandshake.cpp.

Referenced by reconnectMergeOps().

◆ getControlTerminators()

static std::vector<BlockControlTerm> getControlTerminators ( ArrayRef< Operation * >  memOps)
static

◆ getFirstOp()

template<typename TOp >
static Operation* getFirstOp ( Block *  block)
static

Returns the first occurance of an operation of type TOp, else, returns null op.

Definition at line 421 of file CFToHandshake.cpp.

◆ getMergeOperand()

static Value getMergeOperand ( HandshakeLowering::MergeOpInfo  mergeInfo,
Block *  predBlock 
)
static

◆ getOperandFromBlock()

static Value getOperandFromBlock ( MuxOp  mux,
Block *  block 
)
static

Definition at line 880 of file CFToHandshake.cpp.

References assert().

Referenced by getSortedInputs().

◆ getOpMemRef()

static LogicalResult getOpMemRef ( Operation *  op,
Value &  out 
)
static

◆ getResultsToMemory()

static SmallVector<Value, 8> getResultsToMemory ( Operation *  op)
static

Definition at line 1372 of file CFToHandshake.cpp.

References assert().

Referenced by circt::handshake::HandshakeLowering::connectToMemory().

◆ getSortedInputs()

static std::vector<Value> getSortedInputs ( ControlMergeOp  cmerge,
MuxOp  mux 
)
static

Definition at line 893 of file CFToHandshake.cpp.

References assert(), and getOperandFromBlock().

◆ getSuccResult()

static Value getSuccResult ( Operation *  termOp,
Operation *  newOp,
Block *  succBlock 
)
static

Definition at line 1111 of file CFToHandshake.cpp.

References assert().

Referenced by circt::handshake::HandshakeLowering::addBranchOps().

◆ isAllocOp()

static bool isAllocOp ( Operation *  op)
static

Definition at line 493 of file CFToHandshake.cpp.

Referenced by removeUnusedAllocOps().

◆ isLiveOut()

static bool isLiveOut ( Value  val)
static

◆ isMemoryOp()

static bool isMemoryOp ( Operation *  op)
static

◆ isValidMemrefType()

static LogicalResult isValidMemrefType ( Location  loc,
mlir::MemRefType  type 
)
static

◆ loopsHaveSingleExit()

static bool loopsHaveSingleExit ( CFGLoopInfo &  loopInfo)
static

Definition at line 593 of file CFToHandshake.cpp.

◆ lowerFuncOp()

static LogicalResult lowerFuncOp ( func::FuncOp  funcOp,
MLIRContext *  ctx,
bool  sourceConstants,
bool  disableTaskPipelining 
)
static

◆ maximizeSSANoMem()

static LogicalResult maximizeSSANoMem ( Region &  r,
ConversionPatternRewriter &  rewriter 
)
static

Converts every value in the region into maximal SSA form, unless the value is a block argument of type MemRefType or the result of an allocation operation.

Definition at line 1670 of file CFToHandshake.cpp.

References circt::maximizeSSA(), and strategy.

Referenced by lowerFuncOp().

◆ partiallyLowerOp()

template<typename TOp >
static LogicalResult partiallyLowerOp ( const std::function< LogicalResult(TOp, ConversionPatternRewriter &)> &  loweringFunc,
MLIRContext *  ctx,
TOp  op 
)
static

Definition at line 131 of file CFToHandshake.cpp.

◆ reconnectMergeOps()

static void reconnectMergeOps ( Region &  r,
HandshakeLowering::BlockOps  blockMerges,
HandshakeLowering::ValueMap mergePairs 
)
static

◆ removeBasicBlocks()

void removeBasicBlocks ( handshake::FuncOp  funcOp)

Definition at line 263 of file CFToHandshake.cpp.

◆ removeBlockOperands()

static void removeBlockOperands ( Region &  f)
static

Definition at line 406 of file CFToHandshake.cpp.

Referenced by reconnectMergeOps().

◆ removeUnusedAllocOps()

static void removeUnusedAllocOps ( Region &  r,
ConversionPatternRewriter &  rewriter 
)
static

Definition at line 1399 of file CFToHandshake.cpp.

References isAllocOp().

Referenced by circt::handshake::HandshakeLowering::connectToMemory().

◆ setJoinControlInputs()

static LogicalResult setJoinControlInputs ( ArrayRef< Operation * >  memOps,
Operation *  memOp,
int  offset,
ArrayRef< int >  cntrlInd 
)
static

◆ setLoadDataInputs()

static void setLoadDataInputs ( ArrayRef< Operation * >  memOps,
Operation *  memOp 
)
static