CIRCT 24.0.0git
Loading...
Searching...
No Matches
HWOps.cpp File Reference
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/CustomDirectiveImpl.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWInstanceImplementation.h"
#include "circt/Dialect/HW/HWSymCache.h"
#include "circt/Dialect/HW/HWVisitors.h"
#include "circt/Dialect/HW/ModuleImplementation.h"
#include "circt/Support/CustomDirectiveImpl.h"
#include "circt/Support/Namespace.h"
#include "circt/Support/Naming.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/FunctionImplementation.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringSet.h"
#include "circt/Dialect/HW/HWCanonicalization.cpp.inc"
#include "circt/Dialect/HW/HW.cpp.inc"
Include dependency graph for HWOps.cpp:

Go to the source code of this file.

Macros

#define GET_OP_CLASSES

Enumerations

enum class  Delimiter { None , Paren , OptionalLessGreater }

Functions

static Value foldStructExtract (Operation *inputOp, uint32_t fieldIndex)
static ArrayAttr arrayOrEmpty (mlir::MLIRContext *context, ArrayRef< Attribute > attrs)
static void getAsmBlockArgumentNamesImpl (mlir::Region &region, OpAsmSetValueNameFn setNameFn)
 Get a special name to use when printing the entry block arguments of the region contained by an operation in this dialect.
template<class Op>
static bool hasAdditionalAttributes (Op op, ArrayRef< StringRef > ignoredAttrs={})
 Check whether an operation has any additional attributes set beyond its standard list of attributes returned by getAttributeNames.
static LogicalResult checkAttributes (Operation *op, Attribute attr, Type type)
static ParseResult parseParamValue (OpAsmParser &p, Attribute &value, Type &resultType)
static void printParamValue (OpAsmPrinter &p, Operation *, Attribute value, Type resultType)
template<typename ModuleTy>
static void buildModule (OpBuilder &builder, OperationState &result, StringAttr name, const ModulePortInfo &ports, ArrayAttr parameters, ArrayRef< NamedAttribute > attributes, StringAttr comment)
static void modifyModuleArgs (MLIRContext *context, ArrayRef< std::pair< unsigned, PortInfo > > insertArgs, ArrayRef< unsigned > removeArgs, ArrayRef< Attribute > oldArgNames, ArrayRef< Type > oldArgTypes, ArrayRef< Attribute > oldArgAttrs, ArrayRef< Location > oldArgLocs, SmallVector< Attribute > &newArgNames, SmallVector< Type > &newArgTypes, SmallVector< Attribute > &newArgAttrs, SmallVector< Location > &newArgLocs, Block *body=nullptr)
 Internal implementation of argument/result insertion and removal on modules.
static void modifyModulePorts (Operation *op, ArrayRef< std::pair< unsigned, PortInfo > > insertInputs, ArrayRef< std::pair< unsigned, PortInfo > > insertOutputs, ArrayRef< unsigned > removeInputs, ArrayRef< unsigned > removeOutputs, Block *body=nullptr)
 Insert and remove ports of a module.
static bool hasAttribute (StringRef name, ArrayRef< NamedAttribute > attrs)
template<typename ModuleTy>
static ParseResult parseHWModuleOp (OpAsmParser &parser, OperationState &result)
FunctionType getHWModuleOpType (Operation *op)
template<typename ModuleTy>
static void printModuleOp (OpAsmPrinter &p, ModuleTy mod)
static LogicalResult verifyModuleCommon (HWModuleLike module)
template<typename ModTy>
static SmallVector< Location > getAllPortLocs (ModTy module)
template<typename ModTy>
static void setAllPortNames (ArrayRef< Attribute > names, ModTy module)
template<typename ModTy>
static void setHWModuleType (ModTy &mod, ModuleType type)
template<typename ModuleTy>
static SmallVector< PortInfo > getPortList (ModuleTy &mod)
template<typename ModuleTy>
static PortInfo getPort (ModuleTy &mod, size_t idx)
static ParseResult parseSliceTypes (OpAsmParser &p, Type &srcType, Type &idxType)
static void printSliceTypes (OpAsmPrinter &p, Operation *, Type srcType, Type idxType)
static LogicalResult foldCreateToSlice (ArrayCreateOp op, PatternRewriter &rewriter)
static std::optional< uint64_t > getUIntFromValue (Value value)
static ParseResult parseArrayConcatTypes (OpAsmParser &p, SmallVectorImpl< Type > &inputTypes, Type &resultType)
static void printArrayConcatTypes (OpAsmPrinter &p, Operation *, TypeRange inputTypes, Type resultType)
static bool flattenConcatOp (ArrayConcatOp op, PatternRewriter &rewriter)
static bool mergeConcatSlices (ArrayConcatOp op, PatternRewriter &rewriter)
template<typename AggregateOp, typename AggregateType>
static LogicalResult verifyAggregateFieldIndexAndType (AggregateOp &op, AggregateType aggType, Type elementType)
 Ensure an aggregate op's field index is within the bounds of the aggregate type and the accessed field is of 'elementType'.
template<typename AggregateType>
static ParseResult parseExtractOp (OpAsmParser &parser, OperationState &result)
 Use the same parser for both struct_extract and union_extract since the syntax is identical.
template<typename AggType>
static void printExtractOp (OpAsmPrinter &printer, AggType op)
 Use the same printer for both struct_extract and union_extract since the syntax is identical.
static LogicalResult canonicalizeArrayInjectChain (ArrayInjectOp op, PatternRewriter &rewriter)
static LogicalResult canonicalizeArrayInjectIntoCreate (ArrayInjectOp op, PatternRewriter &rewriter)

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 3515 of file HWOps.cpp.

Enumeration Type Documentation

◆ Delimiter

enum class Delimiter
strong
Enumerator
None 
Paren 
OptionalLessGreater 

Definition at line 114 of file HWOps.cpp.

Function Documentation

◆ arrayOrEmpty()

ArrayAttr arrayOrEmpty ( mlir::MLIRContext * context,
ArrayRef< Attribute > attrs )
static

Definition at line 82 of file HWOps.cpp.

References attrs, context, and empty.

Referenced by buildModule().

◆ buildModule()

template<typename ModuleTy>
void buildModule ( OpBuilder & builder,
OperationState & result,
StringAttr name,
const ModulePortInfo & ports,
ArrayAttr parameters,
ArrayRef< NamedAttribute > attributes,
StringAttr comment )
static

Definition at line 603 of file HWOps.cpp.

References arrayOrEmpty().

◆ canonicalizeArrayInjectChain()

LogicalResult canonicalizeArrayInjectChain ( ArrayInjectOp op,
PatternRewriter & rewriter )
static

Definition at line 2988 of file HWOps.cpp.

References failure(), success(), and circt::hw::type_cast().

◆ canonicalizeArrayInjectIntoCreate()

LogicalResult canonicalizeArrayInjectIntoCreate ( ArrayInjectOp op,
PatternRewriter & rewriter )
static

Definition at line 3039 of file HWOps.cpp.

References failure(), and success().

◆ checkAttributes()

LogicalResult checkAttributes ( Operation * op,
Attribute attr,
Type type )
static

Definition at line 451 of file HWOps.cpp.

References checkAttributes(), elementType, failure(), and success().

Referenced by checkAttributes().

◆ flattenConcatOp()

bool flattenConcatOp ( ArrayConcatOp op,
PatternRewriter & rewriter )
static

Definition at line 2066 of file HWOps.cpp.

◆ foldCreateToSlice()

LogicalResult foldCreateToSlice ( ArrayCreateOp op,
PatternRewriter & rewriter )
static

Definition at line 1796 of file HWOps.cpp.

◆ foldStructExtract()

Value foldStructExtract ( Operation * inputOp,
uint32_t fieldIndex )
static

Definition at line 67 of file HWOps.cpp.

◆ getAllPortLocs()

template<typename ModTy>
SmallVector< Location > getAllPortLocs ( ModTy module)
static

Definition at line 1266 of file HWOps.cpp.

◆ getAsmBlockArgumentNamesImpl()

void getAsmBlockArgumentNamesImpl ( mlir::Region & region,
OpAsmSetValueNameFn setNameFn )
static

Get a special name to use when printing the entry block arguments of the region contained by an operation in this dialect.

Definition at line 99 of file HWOps.cpp.

◆ getHWModuleOpType()

FunctionType getHWModuleOpType ( Operation * op)

Definition at line 1058 of file HWOps.cpp.

◆ getPort()

template<typename ModuleTy>
PortInfo getPort ( ModuleTy & mod,
size_t idx )
static

Definition at line 1508 of file HWOps.cpp.

◆ getPortList()

template<typename ModuleTy>
SmallVector< PortInfo > getPortList ( ModuleTy & mod)
static

Definition at line 1488 of file HWOps.cpp.

◆ getUIntFromValue()

std::optional< uint64_t > getUIntFromValue ( Value value)
static

Definition at line 1867 of file HWOps.cpp.

References empty.

◆ hasAdditionalAttributes()

template<class Op>
bool hasAdditionalAttributes ( Op op,
ArrayRef< StringRef > ignoredAttrs = {} )
static

Check whether an operation has any additional attributes set beyond its standard list of attributes returned by getAttributeNames.

Definition at line 393 of file HWOps.cpp.

◆ hasAttribute()

bool hasAttribute ( StringRef name,
ArrayRef< NamedAttribute > attrs )
static

Definition at line 935 of file HWOps.cpp.

References attrs.

Referenced by parseHWModuleOp().

◆ mergeConcatSlices()

bool mergeConcatSlices ( ArrayConcatOp op,
PatternRewriter & rewriter )
static

Definition at line 2083 of file HWOps.cpp.

◆ modifyModuleArgs()

void modifyModuleArgs ( MLIRContext * context,
ArrayRef< std::pair< unsigned, PortInfo > > insertArgs,
ArrayRef< unsigned > removeArgs,
ArrayRef< Attribute > oldArgNames,
ArrayRef< Type > oldArgTypes,
ArrayRef< Attribute > oldArgAttrs,
ArrayRef< Location > oldArgLocs,
SmallVector< Attribute > & newArgNames,
SmallVector< Type > & newArgTypes,
SmallVector< Attribute > & newArgAttrs,
SmallVector< Location > & newArgLocs,
Block * body = nullptr )
static

Internal implementation of argument/result insertion and removal on modules.

Definition at line 641 of file HWOps.cpp.

References assert(), and context.

Referenced by modifyModulePorts().

◆ modifyModulePorts()

void modifyModulePorts ( Operation * op,
ArrayRef< std::pair< unsigned, PortInfo > > insertInputs,
ArrayRef< std::pair< unsigned, PortInfo > > insertOutputs,
ArrayRef< unsigned > removeInputs,
ArrayRef< unsigned > removeOutputs,
Block * body = nullptr )
static

Insert and remove ports of a module.

The insertion and removal indices must be in ascending order. The indices refer to the port positions before any insertion or removal occurs. Ports inserted at the same index will appear in the module in the same order as they were listed in the insert* array.

The operation must be any of the module-like operations.

This is marked deprecated as it's only used from HandshakeToHW and PortConverter and is likely broken and not currently tested. Users of this are still written dealing with input and output ports separately, which is an old and broken style.

Definition at line 731 of file HWOps.cpp.

References context, circt::hw::detail::fnToMod(), and modifyModuleArgs().

◆ parseArrayConcatTypes()

ParseResult parseArrayConcatTypes ( OpAsmParser & p,
SmallVectorImpl< Type > & inputTypes,
Type & resultType )
static

Definition at line 1997 of file HWOps.cpp.

◆ parseExtractOp()

template<typename AggregateType>
ParseResult parseExtractOp ( OpAsmParser & parser,
OperationState & result )
static

Use the same parser for both struct_extract and union_extract since the syntax is identical.

Definition at line 2452 of file HWOps.cpp.

References found.

◆ parseHWModuleOp()

template<typename ModuleTy>
ParseResult parseHWModuleOp ( OpAsmParser & parser,
OperationState & result )
static

◆ parseParamValue()

ParseResult parseParamValue ( OpAsmParser & p,
Attribute & value,
Type & resultType )
static

Definition at line 537 of file HWOps.cpp.

References failure(), and success().

◆ parseSliceTypes()

ParseResult parseSliceTypes ( OpAsmParser & p,
Type & srcType,
Type & idxType )
static

Definition at line 1683 of file HWOps.cpp.

◆ printArrayConcatTypes()

void printArrayConcatTypes ( OpAsmPrinter & p,
Operation * ,
TypeRange inputTypes,
Type resultType )
static

Definition at line 2027 of file HWOps.cpp.

◆ printExtractOp()

template<typename AggType>
void printExtractOp ( OpAsmPrinter & printer,
AggType op )
static

Use the same printer for both struct_extract and union_extract since the syntax is identical.

Definition at line 2489 of file HWOps.cpp.

References getFieldName().

◆ printModuleOp()

template<typename ModuleTy>
void printModuleOp ( OpAsmPrinter & p,
ModuleTy mod )
static

◆ printParamValue()

void printParamValue ( OpAsmPrinter & p,
Operation * ,
Attribute value,
Type resultType )
static

Definition at line 545 of file HWOps.cpp.

◆ printSliceTypes()

void printSliceTypes ( OpAsmPrinter & p,
Operation * ,
Type srcType,
Type idxType )
static

Definition at line 1697 of file HWOps.cpp.

◆ setAllPortNames()

template<typename ModTy>
void setAllPortNames ( ArrayRef< Attribute > names,
ModTy module )
static

Definition at line 1336 of file HWOps.cpp.

◆ setHWModuleType()

template<typename ModTy>
void setHWModuleType ( ModTy & mod,
ModuleType type )
static

Definition at line 1409 of file HWOps.cpp.

◆ verifyAggregateFieldIndexAndType()

template<typename AggregateOp, typename AggregateType>
LogicalResult verifyAggregateFieldIndexAndType ( AggregateOp & op,
AggregateType aggType,
Type elementType )
static

Ensure an aggregate op's field index is within the bounds of the aggregate type and the accessed field is of 'elementType'.

Definition at line 2426 of file HWOps.cpp.

◆ verifyModuleCommon()

LogicalResult verifyModuleCommon ( HWModuleLike module)
static

Definition at line 1123 of file HWOps.cpp.

References assert(), if(), and success().