CIRCT  19.0.0git
Classes | Functions
CFToHandshake.cpp File Reference
#include "circt/Conversion/CFToHandshake.h"
#include "../PassDetail.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Support/BackedgeBuilder.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 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...
 

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)
 

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 609 of file CFToHandshake.cpp.

◆ getBlockControlTerminator()

static BlockControlTerm getBlockControlTerminator ( Block *  block)
static

Definition at line 1218 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 418 of file CFToHandshake.cpp.

◆ getControlMerge()

static Operation* getControlMerge ( Block *  block)
static

Definition at line 414 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 407 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 866 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 1358 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 879 of file CFToHandshake.cpp.

References assert(), and getOperandFromBlock().

◆ getSuccResult()

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

Definition at line 1097 of file CFToHandshake.cpp.

References assert().

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

◆ isAllocOp()

static bool isAllocOp ( Operation *  op)
static

Definition at line 479 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 579 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 1656 of file CFToHandshake.cpp.

References circt::maximizeSSA().

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 123 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 249 of file CFToHandshake.cpp.

◆ removeBlockOperands()

static void removeBlockOperands ( Region &  f)
static

Definition at line 392 of file CFToHandshake.cpp.

Referenced by reconnectMergeOps().

◆ removeUnusedAllocOps()

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

Definition at line 1385 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