CIRCT  20.0.0git
Public Member Functions | Private Member Functions | Private Attributes | List of all members
circt::scftocalyx::BuildOpGroups Class Reference

Iterate through the operations of a source function and instantiate components or primitives based on the type of the operations. More...

Inheritance diagram for circt::scftocalyx::BuildOpGroups:
Inheritance graph
[legend]
Collaboration diagram for circt::scftocalyx::BuildOpGroups:
Collaboration graph
[legend]

Public Member Functions

 BuildOpGroups (MLIRContext *context, LogicalResult &resRef, calyx::PatternApplicationState &patternState, DenseMap< mlir::func::FuncOp, calyx::ComponentOp > &map, calyx::CalyxLoweringState &state, mlir::Pass::Option< std::string > &writeJsonOpt)
 
LogicalResult partiallyLowerFuncToComp (FuncOp funcOp, PatternRewriter &rewriter) const override
 
- Public Member Functions inherited from circt::calyx::FuncOpPartialLoweringPattern
 FuncOpPartialLoweringPattern (MLIRContext *context, LogicalResult &resRef, PatternApplicationState &patternState, DenseMap< mlir::func::FuncOp, calyx::ComponentOp > &map, calyx::CalyxLoweringState &state)
 
LogicalResult partiallyLower (mlir::func::FuncOp funcOp, PatternRewriter &rewriter) const override final
 Entry point to initialize the state of this class and conduct the partial lowering. More...
 
calyx::ComponentOp getComponent () const
 Returns the component operation associated with the currently executing partial lowering. More...
 
template<typename T = ComponentLoweringStateInterface>
T & getState () const
 
CalyxLoweringStateloweringState () const
 Return the calyx lowering state for this pattern. More...
 
virtual LogicalResult partiallyLowerFuncToComp (mlir::func::FuncOp funcOp, PatternRewriter &rewriter) const =0
 
- Public Member Functions inherited from circt::calyx::PartialLoweringPattern< mlir::func::FuncOp >
 PartialLoweringPattern (MLIRContext *ctx, LogicalResult &resRef, PatternApplicationState &patternState)
 
LogicalResult matchAndRewrite (mlir::func::FuncOp op, PatternRewriter &rewriter) const override
 

Private Member Functions

LogicalResult buildOp (PatternRewriter &rewriter, scf::YieldOp yieldOp) const
 Op builder specializations. More...
 
LogicalResult buildOp (PatternRewriter &rewriter, BranchOpInterface brOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, arith::ConstantOp constOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, SelectOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, AddIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, SubIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, MulIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, DivUIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, DivSIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, RemUIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, RemSIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, AddFOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, MulFOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, CmpFOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ShRUIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ShRSIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ShLIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, AndIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, OrIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, XOrIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, CmpIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, TruncIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ExtUIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ExtSIOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, ReturnOp op) const
 For each return statement, we create a new group for assigning to the previously created return value registers. More...
 
LogicalResult buildOp (PatternRewriter &rewriter, IndexCastOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, memref::AllocOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, memref::AllocaOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, memref::GetGlobalOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, memref::LoadOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, memref::StoreOp op) const
 
LogicalResult buildOp (PatternRewriter &rewriter, scf::WhileOp whileOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, scf::ForOp forOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, scf::IfOp ifOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, scf::ReduceOp reduceOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, scf::ParallelOp parallelOp) const
 
LogicalResult buildOp (PatternRewriter &rewriter, CallOp callOp) const
 
template<typename TGroupOp , typename TCalyxLibOp , typename TSrcOp >
LogicalResult buildLibraryOp (PatternRewriter &rewriter, TSrcOp op, TypeRange srcTypes, TypeRange dstTypes) const
 buildLibraryOp will build a TCalyxLibOp inside a TGroupOp based on the source operation TSrcOp. More...
 
template<typename TGroupOp , typename TCalyxLibOp , typename TSrcOp >
LogicalResult buildLibraryOp (PatternRewriter &rewriter, TSrcOp op) const
 buildLibraryOp which provides in- and output types based on the operands and results of the op argument. More...
 
template<typename TGroupOp >
TGroupOp createGroupForOp (PatternRewriter &rewriter, Operation *op) const
 Creates a group named by the basic block which the input op resides in. More...
 
template<typename TOpType , typename TSrcOp >
LogicalResult buildLibraryBinaryPipeOp (PatternRewriter &rewriter, TSrcOp op, TOpType opPipe, Value out) const
 buildLibraryBinaryPipeOp will build a TCalyxLibBinaryPipeOp, to deal with MulIOp, DivUIOp and RemUIOp. More...
 
void assignAddressPorts (PatternRewriter &rewriter, Location loc, calyx::GroupInterface group, calyx::MemoryInterface memoryInterface, Operation::operand_range addressValues) const
 Creates assignments within the provided group to the address ports of the memoryOp based on the provided addressValues. More...
 
calyx::RegisterOp createSignalRegister (PatternRewriter &rewriter, Value signal, bool invert, StringRef nameSuffix, calyx::CompareFOpIEEE754 calyxCmpFOp, calyx::GroupOp group) const
 

Private Attributes

mlir::Pass::Option< std::string > & writeJson
 

Additional Inherited Members

- Protected Attributes inherited from circt::calyx::FuncOpPartialLoweringPattern
DenseMap< mlir::func::FuncOp, calyx::ComponentOp > & functionMapping
 

Detailed Description

Iterate through the operations of a source function and instantiate components or primitives based on the type of the operations.

Definition at line 275 of file SCFToCalyx.cpp.

Constructor & Destructor Documentation

◆ BuildOpGroups()

circt::scftocalyx::BuildOpGroups::BuildOpGroups ( MLIRContext *  context,
LogicalResult &  resRef,
calyx::PatternApplicationState patternState,
DenseMap< mlir::func::FuncOp, calyx::ComponentOp > &  map,
calyx::CalyxLoweringState state,
mlir::Pass::Option< std::string > &  writeJsonOpt 
)
inline

Definition at line 277 of file SCFToCalyx.cpp.

Member Function Documentation

◆ assignAddressPorts()

void circt::scftocalyx::BuildOpGroups::assignAddressPorts ( PatternRewriter &  rewriter,
Location  loc,
calyx::GroupInterface  group,
calyx::MemoryInterface  memoryInterface,
Operation::operand_range  addressValues 
) const
inlineprivate

Creates assignments within the provided group to the address ports of the memoryOp based on the provided addressValues.

Definition at line 522 of file SCFToCalyx.cpp.

References circt::calyx::MemoryInterface::addrPorts(), assert(), and circt::calyx::createConstant().

◆ buildLibraryBinaryPipeOp()

template<typename TOpType , typename TSrcOp >
LogicalResult circt::scftocalyx::BuildOpGroups::buildLibraryBinaryPipeOp ( PatternRewriter &  rewriter,
TSrcOp  op,
TOpType  opPipe,
Value  out 
) const
inlineprivate

buildLibraryBinaryPipeOp will build a TCalyxLibBinaryPipeOp, to deal with MulIOp, DivUIOp and RemUIOp.

Definition at line 462 of file SCFToCalyx.cpp.

References circt::calyx::createConstant(), circt::comb::createOrFoldNot(), circt::calyx::createRegister(), and seq::reg().

◆ buildLibraryOp() [1/2]

template<typename TGroupOp , typename TCalyxLibOp , typename TSrcOp >
LogicalResult circt::scftocalyx::BuildOpGroups::buildLibraryOp ( PatternRewriter &  rewriter,
TSrcOp  op 
) const
inlineprivate

buildLibraryOp which provides in- and output types based on the operands and results of the op argument.

Definition at line 443 of file SCFToCalyx.cpp.

◆ buildLibraryOp() [2/2]

template<typename TGroupOp , typename TCalyxLibOp , typename TSrcOp >
LogicalResult circt::scftocalyx::BuildOpGroups::buildLibraryOp ( PatternRewriter &  rewriter,
TSrcOp  op,
TypeRange  srcTypes,
TypeRange  dstTypes 
) const
inlineprivate

buildLibraryOp will build a TCalyxLibOp inside a TGroupOp based on the source operation TSrcOp.

Create assignments to the inputs of the library op.

Replace the result values of the source operator with the new operator.

Definition at line 397 of file SCFToCalyx.cpp.

References assert(), Input, and circt::calyx::toBitVector().

◆ buildOp() [1/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
AddFOp  op 
) const
private

Definition at line 769 of file SCFToCalyx.cpp.

◆ buildOp() [2/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
AddIOp  op 
) const
private

Definition at line 1310 of file SCFToCalyx.cpp.

◆ buildOp() [3/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
AndIOp  op 
) const
private

Definition at line 1330 of file SCFToCalyx.cpp.

◆ buildOp() [4/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
arith::ConstantOp  constOp 
) const
private

Move constant operations to the compOp body as hw::ConstantOp's.

Definition at line 1285 of file SCFToCalyx.cpp.

References circt::calyx::matchConstantOp().

◆ buildOp() [5/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
BranchOpInterface  brOp 
) const
private

Branch argument passing group creation Branch operands are passed through registers. In BuildBasicBlockRegs we created registers for all branch arguments of each block. We now create groups for assigning values to these registers.

Register the group as a block argument group, to be executed when entering the successor block from this block (srcBlock).

Definition at line 1227 of file SCFToCalyx.cpp.

References circt::calyx::buildAssignmentsForRegisterWrite(), loweringState, and seq::reg().

◆ buildOp() [6/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
CallOp  callOp 
) const
private

Definition at line 1469 of file SCFToCalyx.cpp.

References circt::calyx::getInstanceName(), and Output.

◆ buildOp() [7/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
CmpFOp  op 
) const
private

◆ buildOp() [8/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
CmpIOp  op 
) const
private

Definition at line 1347 of file SCFToCalyx.cpp.

◆ buildOp() [9/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
DivSIOp  op 
) const
private

Definition at line 730 of file SCFToCalyx.cpp.

◆ buildOp() [10/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
DivUIOp  op 
) const
private

Definition at line 717 of file SCFToCalyx.cpp.

◆ buildOp() [11/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ExtSIOp  op 
) const
private

Definition at line 1384 of file SCFToCalyx.cpp.

◆ buildOp() [12/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ExtUIOp  op 
) const
private

Definition at line 1378 of file SCFToCalyx.cpp.

◆ buildOp() [13/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
IndexCastOp  op 
) const
private

Drop the index cast and replace uses of the target value with the source value.

pad/slice the source operand.

Definition at line 1390 of file SCFToCalyx.cpp.

References circt::calyx::normalizeType().

◆ buildOp() [14/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
memref::AllocaOp  op 
) const
private

Definition at line 1091 of file SCFToCalyx.cpp.

References circt::scftocalyx::buildAllocOp().

◆ buildOp() [15/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
memref::AllocOp  op 
) const
private

Definition at line 1086 of file SCFToCalyx.cpp.

References circt::scftocalyx::buildAllocOp().

◆ buildOp() [16/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
memref::GetGlobalOp  op 
) const
private

Definition at line 1096 of file SCFToCalyx.cpp.

References circt::scftocalyx::buildAllocOp().

◆ buildOp() [17/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
memref::LoadOp  op 
) const
private

◆ buildOp() [18/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
memref::StoreOp  op 
) const
private

Definition at line 675 of file SCFToCalyx.cpp.

References circt::calyx::createConstant().

◆ buildOp() [19/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
MulFOp  op 
) const
private

Definition at line 785 of file SCFToCalyx.cpp.

◆ buildOp() [20/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
MulIOp  op 
) const
private

Definition at line 704 of file SCFToCalyx.cpp.

◆ buildOp() [21/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
OrIOp  op 
) const
private

Definition at line 1334 of file SCFToCalyx.cpp.

◆ buildOp() [22/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
RemSIOp  op 
) const
private

Definition at line 756 of file SCFToCalyx.cpp.

◆ buildOp() [23/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
RemUIOp  op 
) const
private

Definition at line 743 of file SCFToCalyx.cpp.

◆ buildOp() [24/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ReturnOp  op 
) const
private

For each return statement, we create a new group for assigning to the previously created return value registers.

Schedule group for execution for when executing the return op block.

Definition at line 1264 of file SCFToCalyx.cpp.

References circt::calyx::buildAssignmentsForRegisterWrite(), and seq::reg().

◆ buildOp() [25/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::ForOp  forOp 
) const
private

◆ buildOp() [26/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::IfOp  ifOp 
) const
private

Definition at line 1447 of file SCFToCalyx.cpp.

◆ buildOp() [27/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::ParallelOp  parallelOp 
) const
private

Definition at line 1462 of file SCFToCalyx.cpp.

◆ buildOp() [28/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::ReduceOp  reduceOp 
) const
private

Definition at line 1454 of file SCFToCalyx.cpp.

◆ buildOp() [29/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::WhileOp  whileOp 
) const
private

Definition at line 1415 of file SCFToCalyx.cpp.

◆ buildOp() [30/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
scf::YieldOp  yieldOp 
) const
private

Op builder specializations.

Definition at line 1102 of file SCFToCalyx.cpp.

References assert(), circt::calyx::buildAssignmentsForRegisterWrite(), circt::calyx::createConstant(), Input, and Output.

◆ buildOp() [31/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
SelectOp  op 
) const
private

Definition at line 1342 of file SCFToCalyx.cpp.

◆ buildOp() [32/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ShLIOp  op 
) const
private

Definition at line 1326 of file SCFToCalyx.cpp.

◆ buildOp() [33/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ShRSIOp  op 
) const
private

Definition at line 1322 of file SCFToCalyx.cpp.

◆ buildOp() [34/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
ShRUIOp  op 
) const
private

Definition at line 1318 of file SCFToCalyx.cpp.

◆ buildOp() [35/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
SubIOp  op 
) const
private

Definition at line 1314 of file SCFToCalyx.cpp.

◆ buildOp() [36/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
TruncIOp  op 
) const
private

Definition at line 1373 of file SCFToCalyx.cpp.

◆ buildOp() [37/37]

LogicalResult circt::scftocalyx::BuildOpGroups::buildOp ( PatternRewriter &  rewriter,
XOrIOp  op 
) const
private

Definition at line 1338 of file SCFToCalyx.cpp.

◆ createGroupForOp()

template<typename TGroupOp >
TGroupOp circt::scftocalyx::BuildOpGroups::createGroupForOp ( PatternRewriter &  rewriter,
Operation *  op 
) const
inlineprivate

Creates a group named by the basic block which the input op resides in.

Definition at line 450 of file SCFToCalyx.cpp.

References loweringState.

◆ createSignalRegister()

calyx::RegisterOp circt::scftocalyx::BuildOpGroups::createSignalRegister ( PatternRewriter &  rewriter,
Value  signal,
bool  invert,
StringRef  nameSuffix,
calyx::CompareFOpIEEE754  calyxCmpFOp,
calyx::GroupOp  group 
) const
inlineprivate

Definition at line 548 of file SCFToCalyx.cpp.

References circt::calyx::createRegister(), and seq::reg().

◆ partiallyLowerFuncToComp()

LogicalResult circt::scftocalyx::BuildOpGroups::partiallyLowerFuncToComp ( FuncOp  funcOp,
PatternRewriter &  rewriter 
) const
inlineoverride

We walk the operations of the funcOp to ensure that all def's have been visited before their uses.

SCF

memref

standard arithmetic

floating point

others

Skip: these special cases will be handled separately.

Definition at line 287 of file SCFToCalyx.cpp.

Member Data Documentation

◆ writeJson

mlir::Pass::Option<std::string>& circt::scftocalyx::BuildOpGroups::writeJson
private

Definition at line 349 of file SCFToCalyx.cpp.


The documentation for this class was generated from the following file: