CIRCT 24.0.0git
Loading...
Searching...
No Matches
HandshakeToHW.cpp File Reference
#include "circt/Conversion/HandshakeToHW.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/ESI/ESIOps.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWSymCache.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/Handshake/HandshakeOps.h"
#include "circt/Dialect/Handshake/HandshakePasses.h"
#include "circt/Dialect/Handshake/HandshakeUtils.h"
#include "circt/Dialect/Handshake/Visitor.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "circt/Support/BackedgeBuilder.h"
#include "circt/Support/ValueMapper.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/Dialect/MemRef/IR/MemRef.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Pass/PassManager.h"
#include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/MathExtras.h"
#include <optional>
#include "circt/Conversion/Passes.h.inc"
Include dependency graph for HandshakeToHW.cpp:

Go to the source code of this file.

Namespaces

namespace  circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.

Macros

#define GEN_PASS_DEF_HANDSHAKETOHW

Typedefs

using NameUniquer = std::function<std::string(Operation *)>
using DiscriminatingTypes = std::pair<SmallVector<Type>, SmallVector<Type>>
 Returns a set of types which may uniquely identify the provided op.

Functions

static std::string getBareSubModuleName (Operation *oldOp)
 Returns a submodule name resulting from an operation, without discriminating type information.
static std::string getCallName (Operation *op)
static Type getOperandDataType (Value op)
 Extracts the type of the data-carrying type of opType.
static DiscriminatingTypes getHandshakeDiscriminatingTypes (Operation *op)
static std::string getTypeName (Location loc, Type type)
 Get type name.
static std::string getSubModuleName (Operation *oldOp)
 Construct a name for creating HW sub-module.
static HWModuleLike checkSubModuleOp (mlir::ModuleOp parentModule, StringRef modName)
 Check whether a submodule with the same name has been created elsewhere in the top level module.
static HWModuleLike checkSubModuleOp (mlir::ModuleOp parentModule, Operation *oldOp)
static ModulePortInfo getPortInfoForOp (Operation *op)
 Returns a vector of PortInfo's which defines the HW interface of the to-be-converted op.
static llvm::SmallVector< hw::detail::FieldInfo > portToFieldInfo (llvm::ArrayRef< hw::PortInfo > portInfo)
static LogicalResult convertExtMemoryOps (HWModuleOp mod)
static LogicalResult convertFuncOp (ESITypeConverter &typeConverter, ConversionTarget &target, handshake::FuncOp op, OpBuilder &moduleBuilder)

Macro Definition Documentation

◆ GEN_PASS_DEF_HANDSHAKETOHW

#define GEN_PASS_DEF_HANDSHAKETOHW

Definition at line 37 of file HandshakeToHW.cpp.

Typedef Documentation

◆ DiscriminatingTypes

using DiscriminatingTypes = std::pair<SmallVector<Type>, SmallVector<Type>>

Returns a set of types which may uniquely identify the provided op.

Return value is <inputTypes, outputTypes>.

Definition at line 121 of file HandshakeToHW.cpp.

◆ NameUniquer

using NameUniquer = std::function<std::string(Operation *)>

Definition at line 46 of file HandshakeToHW.cpp.

Function Documentation

◆ checkSubModuleOp() [1/2]

HWModuleLike checkSubModuleOp ( mlir::ModuleOp parentModule,
Operation * oldOp )
static

Definition at line 262 of file HandshakeToHW.cpp.

References assert(), checkSubModuleOp(), and getSubModuleName().

◆ checkSubModuleOp() [2/2]

HWModuleLike checkSubModuleOp ( mlir::ModuleOp parentModule,
StringRef modName )
static

Check whether a submodule with the same name has been created elsewhere in the top level module.

Return the matched module operation if true, otherwise return nullptr.

Definition at line 253 of file HandshakeToHW.cpp.

Referenced by checkSubModuleOp().

◆ convertExtMemoryOps()

◆ convertFuncOp()

LogicalResult convertFuncOp ( ESITypeConverter & typeConverter,
ConversionTarget & target,
handshake::FuncOp op,
OpBuilder & moduleBuilder )
static

Definition at line 1913 of file HandshakeToHW.cpp.

References getCallName(), and success().

◆ getBareSubModuleName()

std::string getBareSubModuleName ( Operation * oldOp)
static

Returns a submodule name resulting from an operation, without discriminating type information.

Definition at line 95 of file HandshakeToHW.cpp.

Referenced by getCallName(), and getSubModuleName().

◆ getCallName()

std::string getCallName ( Operation * op)
static

Definition at line 104 of file HandshakeToHW.cpp.

References getBareSubModuleName().

Referenced by convertFuncOp().

◆ getHandshakeDiscriminatingTypes()

DiscriminatingTypes getHandshakeDiscriminatingTypes ( Operation * op)
static

Definition at line 122 of file HandshakeToHW.cpp.

References getOperandDataType().

Referenced by getSubModuleName().

◆ getOperandDataType()

Type getOperandDataType ( Value op)
static

Extracts the type of the data-carrying type of opType.

If opType is an ESI channel, getHandshakeBundleDataType extracts the data-carrying type, else, assume that opType itself is the data-carrying type.

Definition at line 112 of file HandshakeToHW.cpp.

Referenced by getHandshakeDiscriminatingTypes().

◆ getPortInfoForOp()

ModulePortInfo getPortInfoForOp ( Operation * op)
static

Returns a vector of PortInfo's which defines the HW interface of the to-be-converted op.

Definition at line 279 of file HandshakeToHW.cpp.

References circt::handshake::getPortInfoForOpTypes().

◆ getSubModuleName()

std::string getSubModuleName ( Operation * oldOp)
static

Construct a name for creating HW sub-module.

Definition at line 171 of file HandshakeToHW.cpp.

References assert(), getBareSubModuleName(), getHandshakeDiscriminatingTypes(), getInt(), and getTypeName().

Referenced by checkSubModuleOp().

◆ getTypeName()

std::string getTypeName ( Location loc,
Type type )
static

Get type name.

Currently we only support integer or index types. The emitted type aligns with the getFIRRTLType() method. Thus all integers other than signed integers will be emitted as unsigned.

Definition at line 144 of file HandshakeToHW.cpp.

References elementType, and getTypeName().

Referenced by getSubModuleName(), and getTypeName().

◆ portToFieldInfo()

llvm::SmallVector< hw::detail::FieldInfo > portToFieldInfo ( llvm::ArrayRef< hw::PortInfo > portInfo)
static

Definition at line 284 of file HandshakeToHW.cpp.

Referenced by convertExtMemoryOps().