CIRCT 22.0.0git
|
#include <CalyxLoweringUtils.h>
Classes | |
struct | IsFloatingPoint |
struct | IsFloatingPoint< T, std::void_t< decltype(std::declval< T >().getFloatingPointStandard())> > |
Public Member Functions | |
ComponentLoweringStateInterface (calyx::ComponentOp component) | |
virtual | ~ComponentLoweringStateInterface () |
calyx::ComponentOp | getComponentOp () |
Returns the calyx::ComponentOp associated with this lowering state. | |
void | addBlockArgReg (Block *block, calyx::RegisterOp reg, unsigned idx) |
Register reg as being the idx'th argument register for block. | |
const DenseMap< unsigned, calyx::RegisterOp > & | getBlockArgRegs (Block *block) |
Return a mapping of block argument indices to block argument registers. | |
void | addBlockArgGroup (Block *from, Block *to, calyx::GroupOp grp) |
Register 'grp' as a group which performs block argument register transfer when transitioning from basic block 'from' to 'to'. | |
ArrayRef< calyx::GroupOp > | getBlockArgGroups (Block *from, Block *to) |
Returns a list of groups to be evaluated to perform the block argument register assignments when transitioning from basic block 'from' to 'to'. | |
std::string | getUniqueName (StringRef prefix) |
Returns a unique name within compOp with the provided prefix. | |
StringRef | getUniqueName (Operation *op) |
Returns a unique name associated with a specific operation. | |
void | setUniqueName (Operation *op, StringRef prefix) |
Registers a unique name for a given operation using a provided prefix. | |
void | registerEvaluatingGroup (Value v, calyx::GroupInterface group) |
Register value v as being evaluated when scheduling group. | |
void | addReturnReg (calyx::RegisterOp reg, unsigned idx) |
Register reg as being the idx'th return value register. | |
calyx::RegisterOp | getReturnReg (unsigned idx) |
Returns the idx'th return value register. | |
void | registerMemoryInterface (Value memref, const calyx::MemoryInterface &memoryInterface) |
Registers a memory interface as being associated with a memory identified by 'memref'. | |
calyx::MemoryInterface | getMemoryInterface (Value memref) |
Returns the memory interface registered for the given memref. | |
std::optional< calyx::MemoryInterface > | isInputPortOfMemory (Value v) |
If v is an input to any memory registered within this component, returns the memory. | |
void | setFuncOpResultMapping (const DenseMap< unsigned, unsigned > &mapping) |
Assign a mapping between the source funcOp result indices and the corresponding output port indices of this componentOp. | |
unsigned | getFuncOpResultMapping (unsigned funcReturnIdx) |
Get the output port index of this component for which the funcReturnIdx of the original function maps to. | |
InstanceOp | getInstance (StringRef calleeName) |
The instance is obtained from the name of the callee. | |
void | addInstance (StringRef calleeName, InstanceOp instanceOp) |
Put the name of the callee and the instance of the call into map. | |
bool | isSeqGuardCmpLibOp (Operation *op) |
Returns if op is a compare operator that requires a register to hold the value of its sequential guard computation. | |
void | addSeqGuardCmpLibOp (Operation *op) |
Add op if it's a compare operator that requires a register to hold the value of its sequential guard computation. | |
template<typename TGroupOp = calyx::GroupInterface> | |
std::optional< TGroupOp > | findEvaluatingGroup (Value v) |
Returns the evaluating group or None if not found. | |
template<typename TGroupOp = calyx::GroupInterface> | |
TGroupOp | getEvaluatingGroup (Value v) |
Return the group which evaluates the value v. | |
template<typename TLibraryOp > | |
TLibraryOp | getNewLibraryOpInstance (OpBuilder &builder, Location loc, TypeRange resTypes) |
llvm::json::Value & | getExtMemData () |
const llvm::json::Value & | getExtMemData () const |
void | setDataField (StringRef name, llvm::json::Array data) |
void | setFormat (StringRef name, std::string numType, bool isSigned, unsigned width) |
Private Attributes | |
calyx::ComponentOp | component |
The component which this lowering state is associated to. | |
DenseMap< Block *, DenseMap< unsigned, calyx::RegisterOp > > | blockArgRegs |
A mapping from blocks to block argument registers. | |
DenseMap< Block *, DenseMap< Block *, SmallVector< calyx::GroupOp > > > | blockArgGroups |
Block arg groups is a list of groups that should be sequentially executed when passing control from the source to destination block. | |
std::map< std::string, unsigned > | prefixIdMap |
A mapping of string prefixes and the current uniqueness counter for that prefix. | |
std::map< Operation *, std::string > | opNames |
A mapping from Operations and previously assigned unique name of the op. | |
DenseMap< Value, calyx::GroupInterface > | valueGroupAssigns |
A mapping between SSA values and the groups which assign them. | |
DenseMap< unsigned, calyx::RegisterOp > | returnRegs |
A mapping from return value indexes to return value registers. | |
DenseMap< Value, calyx::MemoryInterface > | memories |
A mapping from memref's to their corresponding Calyx memory interface. | |
DenseMap< unsigned, unsigned > | funcOpResultMapping |
A mapping between the source funcOp result indices and the corresponding output port indices of this componentOp. | |
llvm::StringMap< calyx::InstanceOp > | instanceMap |
A mapping between the callee and the instance. | |
llvm::json::Value | extMemData |
A json file to store external global memory data. | |
DenseSet< Operation * > | seqGuardCmpLibOps |
A set of compare operators that require registers to hold their sequential guard computation. | |
Definition at line 339 of file CalyxLoweringUtils.h.
circt::calyx::ComponentLoweringStateInterface::ComponentLoweringStateInterface | ( | calyx::ComponentOp | component | ) |
Definition at line 340 of file CalyxLoweringUtils.cpp.
|
virtualdefault |
void circt::calyx::ComponentLoweringStateInterface::addBlockArgGroup | ( | Block * | from, |
Block * | to, | ||
calyx::GroupOp | grp | ||
) |
Register 'grp' as a group which performs block argument register transfer when transitioning from basic block 'from' to 'to'.
Definition at line 363 of file CalyxLoweringUtils.cpp.
References blockArgGroups.
void circt::calyx::ComponentLoweringStateInterface::addBlockArgReg | ( | Block * | block, |
calyx::RegisterOp | reg, | ||
unsigned | idx | ||
) |
Register reg as being the idx'th argument register for block.
This is necessary for the BuildBBReg
pass.
Definition at line 350 of file CalyxLoweringUtils.cpp.
References assert(), and blockArgRegs.
void circt::calyx::ComponentLoweringStateInterface::addInstance | ( | StringRef | calleeName, |
InstanceOp | instanceOp | ||
) |
Put the name of the callee and the instance of the call into map.
Definition at line 455 of file CalyxLoweringUtils.cpp.
References instanceMap.
void circt::calyx::ComponentLoweringStateInterface::addReturnReg | ( | calyx::RegisterOp | reg, |
unsigned | idx | ||
) |
Register reg as being the idx'th return value register.
Definition at line 398 of file CalyxLoweringUtils.cpp.
References assert(), and returnRegs.
void circt::calyx::ComponentLoweringStateInterface::addSeqGuardCmpLibOp | ( | Operation * | op | ) |
Add op
if it's a compare operator that requires a register to hold the value of its sequential guard computation.
Definition at line 464 of file CalyxLoweringUtils.cpp.
References seqGuardCmpLibOps.
|
inline |
Returns the evaluating group or None if not found.
Definition at line 418 of file CalyxLoweringUtils.h.
References assert(), and valueGroupAssigns.
ArrayRef< calyx::GroupOp > circt::calyx::ComponentLoweringStateInterface::getBlockArgGroups | ( | Block * | from, |
Block * | to | ||
) |
Returns a list of groups to be evaluated to perform the block argument register assignments when transitioning from basic block 'from' to 'to'.
Definition at line 369 of file CalyxLoweringUtils.cpp.
References blockArgGroups.
const DenseMap< unsigned, calyx::RegisterOp > & circt::calyx::ComponentLoweringStateInterface::getBlockArgRegs | ( | Block * | block | ) |
Return a mapping of block argument indices to block argument registers.
This is necessary for the BuildBBReg
pass.
Definition at line 359 of file CalyxLoweringUtils.cpp.
References blockArgRegs.
calyx::ComponentOp circt::calyx::ComponentLoweringStateInterface::getComponentOp | ( | ) |
Returns the calyx::ComponentOp associated with this lowering state.
Definition at line 346 of file CalyxLoweringUtils.cpp.
References component.
Referenced by circt::pipelinetocalyx::buildAllocOp(), and circt::scftocalyx::buildAllocOp().
|
inline |
Return the group which evaluates the value v.
Optionally, caller may specify the expected type of the group.
Definition at line 435 of file CalyxLoweringUtils.h.
References assert().
Referenced by circt::calyx::InlineCombGroups::recurseInlineCombGroups().
|
inline |
Definition at line 474 of file CalyxLoweringUtils.h.
References extMemData.
|
inline |
Definition at line 476 of file CalyxLoweringUtils.h.
References extMemData.
unsigned circt::calyx::ComponentLoweringStateInterface::getFuncOpResultMapping | ( | unsigned | funcReturnIdx | ) |
Get the output port index of this component for which the funcReturnIdx of the original function maps to.
Definition at line 442 of file CalyxLoweringUtils.cpp.
References assert(), and funcOpResultMapping.
InstanceOp circt::calyx::ComponentLoweringStateInterface::getInstance | ( | StringRef | calleeName | ) |
The instance is obtained from the name of the callee.
Definition at line 451 of file CalyxLoweringUtils.cpp.
References instanceMap.
calyx::MemoryInterface circt::calyx::ComponentLoweringStateInterface::getMemoryInterface | ( | Value | memref | ) |
Returns the memory interface registered for the given memref.
Definition at line 419 of file CalyxLoweringUtils.cpp.
|
inline |
Definition at line 451 of file CalyxLoweringUtils.h.
References assert(), component, getUniqueName(), and circt::calyx::IEEE754.
calyx::RegisterOp circt::calyx::ComponentLoweringStateInterface::getReturnReg | ( | unsigned | idx | ) |
Returns the idx'th return value register.
Definition at line 405 of file CalyxLoweringUtils.cpp.
References assert(), and returnRegs.
StringRef circt::calyx::ComponentLoweringStateInterface::getUniqueName | ( | Operation * | op | ) |
Returns a unique name associated with a specific operation.
Definition at line 380 of file CalyxLoweringUtils.cpp.
std::string circt::calyx::ComponentLoweringStateInterface::getUniqueName | ( | StringRef | prefix | ) |
Returns a unique name within compOp with the provided prefix.
Definition at line 373 of file CalyxLoweringUtils.cpp.
References prefixIdMap.
Referenced by circt::pipelinetocalyx::buildAllocOp(), circt::scftocalyx::buildAllocOp(), getNewLibraryOpInstance(), and setUniqueName().
std::optional< calyx::MemoryInterface > circt::calyx::ComponentLoweringStateInterface::isInputPortOfMemory | ( | Value | v | ) |
If v is an input to any memory registered within this component, returns the memory.
If not, returns null.
Definition at line 427 of file CalyxLoweringUtils.cpp.
References memories.
bool circt::calyx::ComponentLoweringStateInterface::isSeqGuardCmpLibOp | ( | Operation * | op | ) |
Returns if op
is a compare operator that requires a register to hold the value of its sequential guard computation.
Definition at line 460 of file CalyxLoweringUtils.cpp.
References seqGuardCmpLibOps.
Referenced by circt::calyx::InlineCombGroups::recurseInlineCombGroups().
void circt::calyx::ComponentLoweringStateInterface::registerEvaluatingGroup | ( | Value | v, |
calyx::GroupInterface | group | ||
) |
Register value v as being evaluated when scheduling group.
Definition at line 393 of file CalyxLoweringUtils.cpp.
References valueGroupAssigns.
void circt::calyx::ComponentLoweringStateInterface::registerMemoryInterface | ( | Value | memref, |
const calyx::MemoryInterface & | memoryInterface | ||
) |
Registers a memory interface as being associated with a memory identified by 'memref'.
Definition at line 410 of file CalyxLoweringUtils.cpp.
References assert(), and memories.
Referenced by circt::pipelinetocalyx::buildAllocOp(), and circt::scftocalyx::buildAllocOp().
|
inline |
Definition at line 478 of file CalyxLoweringUtils.h.
References assert(), and extMemData.
Referenced by circt::scftocalyx::buildAllocOp().
|
inline |
Definition at line 491 of file CalyxLoweringUtils.h.
References assert(), and extMemData.
Referenced by circt::scftocalyx::buildAllocOp().
void circt::calyx::ComponentLoweringStateInterface::setFuncOpResultMapping | ( | const DenseMap< unsigned, unsigned > & | mapping | ) |
Assign a mapping between the source funcOp result indices and the corresponding output port indices of this componentOp.
Definition at line 437 of file CalyxLoweringUtils.cpp.
References funcOpResultMapping.
Referenced by circt::pipelinetocalyx::FuncOpConversion::partiallyLowerFuncToComp(), and circt::scftocalyx::FuncOpConversion::partiallyLowerFuncToComp().
void circt::calyx::ComponentLoweringStateInterface::setUniqueName | ( | Operation * | op, |
StringRef | prefix | ||
) |
Registers a unique name for a given operation using a provided prefix.
Definition at line 386 of file CalyxLoweringUtils.cpp.
References assert(), getUniqueName(), and opNames.
|
private |
Block arg groups is a list of groups that should be sequentially executed when passing control from the source to destination block.
Block arg groups are executed before blockScheduleables (akin to a phi-node).
Definition at line 518 of file CalyxLoweringUtils.h.
Referenced by addBlockArgGroup(), and getBlockArgGroups().
|
private |
A mapping from blocks to block argument registers.
Definition at line 511 of file CalyxLoweringUtils.h.
Referenced by addBlockArgReg(), and getBlockArgRegs().
|
private |
The component which this lowering state is associated to.
Definition at line 508 of file CalyxLoweringUtils.h.
Referenced by getComponentOp(), and getNewLibraryOpInstance().
|
private |
A json file to store external global memory data.
See https://docs.calyxir.org/lang/data-format.html?highlight=json#the-data-format
Definition at line 545 of file CalyxLoweringUtils.h.
Referenced by getExtMemData(), getExtMemData(), setDataField(), and setFormat().
|
private |
A mapping between the source funcOp result indices and the corresponding output port indices of this componentOp.
Definition at line 538 of file CalyxLoweringUtils.h.
Referenced by getFuncOpResultMapping(), and setFuncOpResultMapping().
|
private |
A mapping between the callee and the instance.
Definition at line 541 of file CalyxLoweringUtils.h.
Referenced by addInstance(), and getInstance().
|
private |
A mapping from memref's to their corresponding Calyx memory interface.
Definition at line 534 of file CalyxLoweringUtils.h.
Referenced by getMemoryInterface(), isInputPortOfMemory(), and registerMemoryInterface().
|
private |
A mapping from Operations and previously assigned unique name of the op.
Definition at line 525 of file CalyxLoweringUtils.h.
Referenced by getUniqueName(), and setUniqueName().
|
private |
A mapping of string prefixes and the current uniqueness counter for that prefix.
Used to generate unique names.
Definition at line 522 of file CalyxLoweringUtils.h.
Referenced by getUniqueName().
|
private |
A mapping from return value indexes to return value registers.
Definition at line 531 of file CalyxLoweringUtils.h.
Referenced by addReturnReg(), and getReturnReg().
|
private |
A set of compare operators that require registers to hold their sequential guard computation.
Definition at line 549 of file CalyxLoweringUtils.h.
Referenced by addSeqGuardCmpLibOp(), and isSeqGuardCmpLibOp().
|
private |
A mapping between SSA values and the groups which assign them.
Definition at line 528 of file CalyxLoweringUtils.h.
Referenced by findEvaluatingGroup(), and registerEvaluatingGroup().