CIRCT  19.0.0git
Public Member Functions | Private Attributes | List of all members
circt::calyx::ComponentLoweringStateInterface Class Reference

#include <CalyxLoweringUtils.h>

Inheritance diagram for circt::calyx::ComponentLoweringStateInterface:
Inheritance graph
[legend]
Collaboration diagram for circt::calyx::ComponentLoweringStateInterface:
Collaboration graph
[legend]

Public Member Functions

 ComponentLoweringStateInterface (calyx::ComponentOp component)
 
 ~ComponentLoweringStateInterface ()
 
calyx::ComponentOp getComponentOp ()
 Returns the calyx::ComponentOp associated with this lowering state. More...
 
void addBlockArgReg (Block *block, calyx::RegisterOp reg, unsigned idx)
 Register reg as being the idx'th argument register for block. More...
 
const DenseMap< unsigned, calyx::RegisterOp > & getBlockArgRegs (Block *block)
 Return a mapping of block argument indices to block argument registers. More...
 
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'. More...
 
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'. More...
 
std::string getUniqueName (StringRef prefix)
 Returns a unique name within compOp with the provided prefix. More...
 
StringRef getUniqueName (Operation *op)
 Returns a unique name associated with a specific operation. More...
 
void setUniqueName (Operation *op, StringRef prefix)
 Registers a unique name for a given operation using a provided prefix. More...
 
void registerEvaluatingGroup (Value v, calyx::GroupInterface group)
 Register value v as being evaluated when scheduling group. More...
 
void addReturnReg (calyx::RegisterOp reg, unsigned idx)
 Register reg as being the idx'th return value register. More...
 
calyx::RegisterOp getReturnReg (unsigned idx)
 Returns the idx'th return value register. More...
 
void registerMemoryInterface (Value memref, const calyx::MemoryInterface &memoryInterface)
 Registers a memory interface as being associated with a memory identified by 'memref'. More...
 
calyx::MemoryInterface getMemoryInterface (Value memref)
 Returns the memory interface registered for the given memref. More...
 
std::optional< calyx::MemoryInterfaceisInputPortOfMemory (Value v)
 If v is an input to any memory registered within this component, returns the memory. More...
 
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. More...
 
unsigned getFuncOpResultMapping (unsigned funcReturnIdx)
 Get the output port index of this component for which the funcReturnIdx of the original function maps to. More...
 
InstanceOp getInstance (StringRef calleeName)
 The instance is obtained from the name of the callee. More...
 
void addInstance (StringRef calleeName, InstanceOp instanceOp)
 Put the name of the callee and the instance of the call into map. More...
 
template<typename TGroupOp = calyx::GroupInterface>
TGroupOp getEvaluatingGroup (Value v)
 Return the group which evaluates the value v. More...
 
template<typename TLibraryOp >
TLibraryOp getNewLibraryOpInstance (OpBuilder &builder, Location loc, TypeRange resTypes)
 

Private Attributes

calyx::ComponentOp component
 The component which this lowering state is associated to. More...
 
DenseMap< Block *, DenseMap< unsigned, calyx::RegisterOp > > blockArgRegs
 A mapping from blocks to block argument registers. More...
 
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. More...
 
std::map< std::string, unsigned > prefixIdMap
 A mapping of string prefixes and the current uniqueness counter for that prefix. More...
 
std::map< Operation *, std::string > opNames
 A mapping from Operations and previously assigned unique name of the op. More...
 
DenseMap< Value, calyx::GroupInterface > valueGroupAssigns
 A mapping between SSA values and the groups which assign them. More...
 
DenseMap< unsigned, calyx::RegisterOp > returnRegs
 A mapping from return value indexes to return value registers. More...
 
DenseMap< Value, calyx::MemoryInterfacememories
 A mapping from memref's to their corresponding Calyx memory interface. More...
 
DenseMap< unsigned, unsigned > funcOpResultMapping
 A mapping between the source funcOp result indices and the corresponding output port indices of this componentOp. More...
 
llvm::StringMap< calyx::InstanceOp > instanceMap
 A mapping between the callee and the instance. More...
 

Detailed Description

Definition at line 334 of file CalyxLoweringUtils.h.

Constructor & Destructor Documentation

◆ ComponentLoweringStateInterface()

circt::calyx::ComponentLoweringStateInterface::ComponentLoweringStateInterface ( calyx::ComponentOp  component)

Definition at line 306 of file CalyxLoweringUtils.cpp.

◆ ~ComponentLoweringStateInterface()

circt::calyx::ComponentLoweringStateInterface::~ComponentLoweringStateInterface ( )
default

Member Function Documentation

◆ addBlockArgGroup()

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 329 of file CalyxLoweringUtils.cpp.

References blockArgGroups.

◆ addBlockArgReg()

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 316 of file CalyxLoweringUtils.cpp.

References assert(), blockArgRegs, and seq::reg().

◆ addInstance()

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 421 of file CalyxLoweringUtils.cpp.

References instanceMap.

◆ addReturnReg()

void circt::calyx::ComponentLoweringStateInterface::addReturnReg ( calyx::RegisterOp  reg,
unsigned  idx 
)

Register reg as being the idx'th return value register.

Definition at line 364 of file CalyxLoweringUtils.cpp.

References assert(), seq::reg(), and returnRegs.

◆ getBlockArgGroups()

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 335 of file CalyxLoweringUtils.cpp.

References blockArgGroups.

◆ getBlockArgRegs()

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 325 of file CalyxLoweringUtils.cpp.

References blockArgRegs.

◆ getComponentOp()

calyx::ComponentOp circt::calyx::ComponentLoweringStateInterface::getComponentOp ( )

Returns the calyx::ComponentOp associated with this lowering state.

Definition at line 312 of file CalyxLoweringUtils.cpp.

References component.

Referenced by circt::pipelinetocalyx::buildAllocOp(), and circt::scftocalyx::buildAllocOp().

◆ getEvaluatingGroup()

template<typename TGroupOp = calyx::GroupInterface>
TGroupOp circt::calyx::ComponentLoweringStateInterface::getEvaluatingGroup ( Value  v)
inline

Return the group which evaluates the value v.

Optionally, caller may specify the expected type of the group.

Definition at line 406 of file CalyxLoweringUtils.h.

References assert(), and valueGroupAssigns.

Referenced by circt::calyx::InlineCombGroups::recurseInlineCombGroups().

◆ getFuncOpResultMapping()

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 408 of file CalyxLoweringUtils.cpp.

References assert(), and funcOpResultMapping.

◆ getInstance()

InstanceOp circt::calyx::ComponentLoweringStateInterface::getInstance ( StringRef  calleeName)

The instance is obtained from the name of the callee.

Definition at line 417 of file CalyxLoweringUtils.cpp.

References instanceMap.

◆ getMemoryInterface()

calyx::MemoryInterface circt::calyx::ComponentLoweringStateInterface::getMemoryInterface ( Value  memref)

Returns the memory interface registered for the given memref.

Definition at line 385 of file CalyxLoweringUtils.cpp.

References assert(), and memories.

◆ getNewLibraryOpInstance()

template<typename TLibraryOp >
TLibraryOp circt::calyx::ComponentLoweringStateInterface::getNewLibraryOpInstance ( OpBuilder &  builder,
Location  loc,
TypeRange  resTypes 
)
inline

Definition at line 419 of file CalyxLoweringUtils.h.

References builder, component, and getUniqueName().

◆ getReturnReg()

calyx::RegisterOp circt::calyx::ComponentLoweringStateInterface::getReturnReg ( unsigned  idx)

Returns the idx'th return value register.

Definition at line 371 of file CalyxLoweringUtils.cpp.

References assert(), and returnRegs.

◆ getUniqueName() [1/2]

StringRef circt::calyx::ComponentLoweringStateInterface::getUniqueName ( Operation *  op)

Returns a unique name associated with a specific operation.

Definition at line 346 of file CalyxLoweringUtils.cpp.

References assert(), and opNames.

◆ getUniqueName() [2/2]

std::string circt::calyx::ComponentLoweringStateInterface::getUniqueName ( StringRef  prefix)

Returns a unique name within compOp with the provided prefix.

Definition at line 339 of file CalyxLoweringUtils.cpp.

References prefixIdMap.

Referenced by circt::pipelinetocalyx::buildAllocOp(), circt::scftocalyx::buildAllocOp(), getNewLibraryOpInstance(), and setUniqueName().

◆ isInputPortOfMemory()

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 393 of file CalyxLoweringUtils.cpp.

References memories.

◆ registerEvaluatingGroup()

void circt::calyx::ComponentLoweringStateInterface::registerEvaluatingGroup ( Value  v,
calyx::GroupInterface  group 
)

Register value v as being evaluated when scheduling group.

Definition at line 359 of file CalyxLoweringUtils.cpp.

References valueGroupAssigns.

◆ registerMemoryInterface()

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 376 of file CalyxLoweringUtils.cpp.

References assert(), and memories.

Referenced by circt::pipelinetocalyx::buildAllocOp(), and circt::scftocalyx::buildAllocOp().

◆ setFuncOpResultMapping()

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 403 of file CalyxLoweringUtils.cpp.

References funcOpResultMapping.

Referenced by circt::pipelinetocalyx::FuncOpConversion::partiallyLowerFuncToComp(), and circt::scftocalyx::FuncOpConversion::partiallyLowerFuncToComp().

◆ setUniqueName()

void circt::calyx::ComponentLoweringStateInterface::setUniqueName ( Operation *  op,
StringRef  prefix 
)

Registers a unique name for a given operation using a provided prefix.

Definition at line 352 of file CalyxLoweringUtils.cpp.

References assert(), getUniqueName(), and opNames.

Member Data Documentation

◆ blockArgGroups

DenseMap<Block *, DenseMap<Block *, SmallVector<calyx::GroupOp> > > circt::calyx::ComponentLoweringStateInterface::blockArgGroups
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 440 of file CalyxLoweringUtils.h.

Referenced by addBlockArgGroup(), and getBlockArgGroups().

◆ blockArgRegs

DenseMap<Block *, DenseMap<unsigned, calyx::RegisterOp> > circt::calyx::ComponentLoweringStateInterface::blockArgRegs
private

A mapping from blocks to block argument registers.

Definition at line 433 of file CalyxLoweringUtils.h.

Referenced by addBlockArgReg(), and getBlockArgRegs().

◆ component

calyx::ComponentOp circt::calyx::ComponentLoweringStateInterface::component
private

The component which this lowering state is associated to.

Definition at line 430 of file CalyxLoweringUtils.h.

Referenced by getComponentOp(), and getNewLibraryOpInstance().

◆ funcOpResultMapping

DenseMap<unsigned, unsigned> circt::calyx::ComponentLoweringStateInterface::funcOpResultMapping
private

A mapping between the source funcOp result indices and the corresponding output port indices of this componentOp.

Definition at line 460 of file CalyxLoweringUtils.h.

Referenced by getFuncOpResultMapping(), and setFuncOpResultMapping().

◆ instanceMap

llvm::StringMap<calyx::InstanceOp> circt::calyx::ComponentLoweringStateInterface::instanceMap
private

A mapping between the callee and the instance.

Definition at line 463 of file CalyxLoweringUtils.h.

Referenced by addInstance(), and getInstance().

◆ memories

DenseMap<Value, calyx::MemoryInterface> circt::calyx::ComponentLoweringStateInterface::memories
private

A mapping from memref's to their corresponding Calyx memory interface.

Definition at line 456 of file CalyxLoweringUtils.h.

Referenced by getMemoryInterface(), isInputPortOfMemory(), and registerMemoryInterface().

◆ opNames

std::map<Operation *, std::string> circt::calyx::ComponentLoweringStateInterface::opNames
private

A mapping from Operations and previously assigned unique name of the op.

Definition at line 447 of file CalyxLoweringUtils.h.

Referenced by getUniqueName(), and setUniqueName().

◆ prefixIdMap

std::map<std::string, unsigned> circt::calyx::ComponentLoweringStateInterface::prefixIdMap
private

A mapping of string prefixes and the current uniqueness counter for that prefix.

Used to generate unique names.

Definition at line 444 of file CalyxLoweringUtils.h.

Referenced by getUniqueName().

◆ returnRegs

DenseMap<unsigned, calyx::RegisterOp> circt::calyx::ComponentLoweringStateInterface::returnRegs
private

A mapping from return value indexes to return value registers.

Definition at line 453 of file CalyxLoweringUtils.h.

Referenced by addReturnReg(), and getReturnReg().

◆ valueGroupAssigns

DenseMap<Value, calyx::GroupInterface> circt::calyx::ComponentLoweringStateInterface::valueGroupAssigns
private

A mapping between SSA values and the groups which assign them.

Definition at line 450 of file CalyxLoweringUtils.h.

Referenced by getEvaluatingGroup(), and registerEvaluatingGroup().


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