CIRCT 24.0.0git
Loading...
Searching...
No Matches
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

namespace  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.
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< BlockControlTerm > getControlTerminators (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.
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()

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

◆ addLazyForks()

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

◆ addValueToOperands()

void addValueToOperands ( Operation * op,
Value val )
static

◆ findBranchToBlock()

Operation * findBranchToBlock ( Block * block)
static

Definition at line 624 of file CFToHandshake.cpp.

◆ getBlockControlTerminator()

BlockControlTerm getBlockControlTerminator ( Block * block)
static

Definition at line 1234 of file CFToHandshake.cpp.

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

◆ getBlockPredecessorCount()

unsigned getBlockPredecessorCount ( Block * block)
static

◆ getBranchCount()

int getBranchCount ( Value val,
Block * block )
static

◆ getControlCondBranch()

ConditionalBranchOp getControlCondBranch ( Block * block)
static

Definition at line 433 of file CFToHandshake.cpp.

◆ getControlMerge()

Operation * getControlMerge ( Block * block)
static

Definition at line 429 of file CFToHandshake.cpp.

References getFirstOp().

Referenced by reconnectMergeOps().

◆ getControlTerminators()

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

◆ getFirstOp()

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

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

Definition at line 422 of file CFToHandshake.cpp.

Referenced by getControlMerge().

◆ getMergeOperand()

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

◆ getOperandFromBlock()

Value getOperandFromBlock ( MuxOp mux,
Block * block )
static

Definition at line 881 of file CFToHandshake.cpp.

References assert().

Referenced by getSortedInputs().

◆ getOpMemRef()

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

Definition at line 1250 of file CFToHandshake.cpp.

References success().

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

◆ getResultsToMemory()

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

Definition at line 1374 of file CFToHandshake.cpp.

References assert().

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

◆ getSortedInputs()

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

Definition at line 894 of file CFToHandshake.cpp.

References assert(), and getOperandFromBlock().

◆ getSuccResult()

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

Definition at line 1113 of file CFToHandshake.cpp.

References assert().

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

◆ isAllocOp()

bool isAllocOp ( Operation * op)
static

Definition at line 494 of file CFToHandshake.cpp.

Referenced by removeUnusedAllocOps().

◆ isLiveOut()

bool isLiveOut ( Value val)
static

◆ isMemoryOp()

bool isMemoryOp ( Operation * op)
static

◆ isValidMemrefType()

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

◆ loopsHaveSingleExit()

bool loopsHaveSingleExit ( CFGLoopInfo & loopInfo)
static

Definition at line 594 of file CFToHandshake.cpp.

◆ lowerFuncOp()

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

◆ maximizeSSANoMem()

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

References circt::maximizeSSA().

Referenced by lowerFuncOp().

◆ partiallyLowerOp()

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

Definition at line 131 of file CFToHandshake.cpp.

References success().

Referenced by lowerFuncOp().

◆ reconnectMergeOps()

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

◆ removeBasicBlocks()

Definition at line 263 of file CFToHandshake.cpp.

References circt::handshake::removeBasicBlocks().

◆ removeBlockOperands()

void removeBlockOperands ( Region & f)
static

Definition at line 407 of file CFToHandshake.cpp.

Referenced by reconnectMergeOps().

◆ removeUnusedAllocOps()

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

Definition at line 1401 of file CFToHandshake.cpp.

References isAllocOp().

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

◆ setJoinControlInputs()

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

◆ setLoadDataInputs()

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