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

Instantiate one of these and use it to build typed backedges. More...

#include <BackedgeBuilder.h>

Collaboration diagram for circt::BackedgeBuilder:
Collaboration graph
[legend]

Public Member Functions

 BackedgeBuilder (mlir::OpBuilder &builder, mlir::Location loc)
 To build a backedge op and manipulate it, we need a PatternRewriter and a Location. More...
 
 BackedgeBuilder (mlir::PatternRewriter &rewriter, mlir::Location loc)
 
 ~BackedgeBuilder ()
 
Backedge get (mlir::Type resultType, mlir::LocationAttr optionalLoc={})
 Create a typed backedge. More...
 
mlir::LogicalResult clearOrEmitError ()
 Clear the backedges, erasing any remaining cursor ops. More...
 
void abandon ()
 Abandon the backedges, suppressing any diagnostics if they are still active upon destruction of the backedge builder. More...
 

Private Attributes

mlir::OpBuilder & builder
 
mlir::PatternRewriter * rewriter
 
mlir::Location loc
 
llvm::SmallVector< mlir::Operation *, 16 > edges
 

Friends

class Backedge
 

Detailed Description

Instantiate one of these and use it to build typed backedges.

Backedges which get used as operands must be assigned to with the actual value before this class is destructed, usually at the end of a scope. It will check that invariant then erase all the backedge ops during destruction.

Example use:

circt::Backedge ready = back.get(rewriter.getI1Type());
// Use `ready` as a `Value`.
auto addOp = rewriter.create<addOp>(loc, ready);
// When the actual value is available,
ready.set(anotherOp.getResult(0));
Instantiate one of these and use it to build typed backedges.
mlir::PatternRewriter * rewriter
Backedge is a wrapper class around a Value.

Definition at line 46 of file BackedgeBuilder.h.

Constructor & Destructor Documentation

◆ BackedgeBuilder() [1/2]

circt::BackedgeBuilder::BackedgeBuilder ( mlir::OpBuilder &  builder,
mlir::Location  loc 
)

To build a backedge op and manipulate it, we need a PatternRewriter and a Location.

Store them during construct of this instance and use them when building.

◆ BackedgeBuilder() [2/2]

circt::BackedgeBuilder::BackedgeBuilder ( mlir::PatternRewriter &  rewriter,
mlir::Location  loc 
)

◆ ~BackedgeBuilder()

BackedgeBuilder::~BackedgeBuilder ( )

Definition at line 35 of file BackedgeBuilder.cpp.

References clearOrEmitError().

Member Function Documentation

◆ abandon()

void BackedgeBuilder::abandon ( )

Abandon the backedges, suppressing any diagnostics if they are still active upon destruction of the backedge builder.

Also, any currently existing cursor ops will be abandoned.

Definition at line 59 of file BackedgeBuilder.cpp.

References edges.

◆ clearOrEmitError()

LogicalResult BackedgeBuilder::clearOrEmitError ( )

Clear the backedges, erasing any remaining cursor ops.

Returns failure and emits diagnostic messages if a backedge is still active.

Definition at line 37 of file BackedgeBuilder.cpp.

References edges, loc, and rewriter.

Referenced by ~BackedgeBuilder().

◆ get()

Backedge BackedgeBuilder::get ( mlir::Type  resultType,
mlir::LocationAttr  optionalLoc = {} 
)

Create a typed backedge.

If no location is provided, the one passed to the constructor will be used.

Definition at line 65 of file BackedgeBuilder.cpp.

References Backedge, builder, edges, and loc.

Referenced by circt::handshake::HandshakeLowering::insertMerge(), instantiateSystemVerilogMemory(), lockRegion(), and circt::hw::PortConverterImpl::updateInstance().

Friends And Related Function Documentation

◆ Backedge

friend class Backedge
friend

Definition at line 47 of file BackedgeBuilder.h.

Referenced by get().

Member Data Documentation

◆ builder

mlir::OpBuilder& circt::BackedgeBuilder::builder
private

Definition at line 71 of file BackedgeBuilder.h.

Referenced by get().

◆ edges

llvm::SmallVector<mlir::Operation *, 16> circt::BackedgeBuilder::edges
private

◆ loc

mlir::Location circt::BackedgeBuilder::loc
private

Definition at line 73 of file BackedgeBuilder.h.

Referenced by clearOrEmitError(), and get().

◆ rewriter

mlir::PatternRewriter* circt::BackedgeBuilder::rewriter
private

Definition at line 72 of file BackedgeBuilder.h.

Referenced by clearOrEmitError().


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