CIRCT  20.0.0git
Macros | Enumerations | Functions
HWOps.cpp File Reference
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/Comb/CombOps.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/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/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. More...
 
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. More...
 
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. More...
 
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. More...
 
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< PortInfogetPortList (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'. More...
 
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. More...
 
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. More...
 

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 3363 of file HWOps.cpp.

Enumeration Type Documentation

◆ Delimiter

enum Delimiter
strong
Enumerator
None 
Paren 
OptionalLessGreater 

Definition at line 116 of file HWOps.cpp.

Function Documentation

◆ arrayOrEmpty()

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

Definition at line 84 of file HWOps.cpp.

References empty, and circt::calyx::direction::get().

Referenced by buildModule().

◆ buildModule()

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

Definition at line 549 of file HWOps.cpp.

References arrayOrEmpty(), and circt::calyx::direction::get().

◆ checkAttributes()

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

Definition at line 399 of file HWOps.cpp.

References elementType.

◆ flattenConcatOp()

static bool flattenConcatOp ( ArrayConcatOp  op,
PatternRewriter &  rewriter 
)
static

Definition at line 2124 of file HWOps.cpp.

◆ foldCreateToSlice()

static LogicalResult foldCreateToSlice ( ArrayCreateOp  op,
PatternRewriter &  rewriter 
)
static

Definition at line 1858 of file HWOps.cpp.

References circt::calyx::direction::get(), and circt::hw::isOffset().

◆ foldStructExtract()

static Value foldStructExtract ( Operation *  inputOp,
uint32_t  fieldIndex 
)
static

Definition at line 69 of file HWOps.cpp.

◆ getAllPortLocs()

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

Definition at line 1198 of file HWOps.cpp.

References assert(), and circt::calyx::direction::get().

◆ getAsmBlockArgumentNamesImpl()

static 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 101 of file HWOps.cpp.

◆ getHWModuleOpType()

FunctionType getHWModuleOpType ( Operation *  op)

Definition at line 1015 of file HWOps.cpp.

◆ getPort()

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

Definition at line 1440 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ getPortList()

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

Definition at line 1420 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ getUIntFromValue()

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

Definition at line 1929 of file HWOps.cpp.

◆ hasAdditionalAttributes()

template<class Op >
static 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 345 of file HWOps.cpp.

◆ hasAttribute()

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

Definition at line 893 of file HWOps.cpp.

Referenced by parseHWModuleOp().

◆ mergeConcatSlices()

static bool mergeConcatSlices ( ArrayConcatOp  op,
PatternRewriter &  rewriter 
)
static

Definition at line 2141 of file HWOps.cpp.

References append(), circt::calyx::direction::get(), and circt::hw::isOffset().

◆ modifyModuleArgs()

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 
)
static

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

Definition at line 587 of file HWOps.cpp.

References assert(), circt::calyx::direction::get(), and InOut.

Referenced by modifyModulePorts().

◆ modifyModulePorts()

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 
)
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 686 of file HWOps.cpp.

References circt::hw::detail::fnToMod(), circt::calyx::direction::get(), and modifyModuleArgs().

◆ parseArrayConcatTypes()

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

Definition at line 2058 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ parseExtractOp()

template<typename AggregateType >
static 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 2482 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ parseHWModuleOp()

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

◆ parseParamValue()

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

Definition at line 485 of file HWOps.cpp.

◆ parseSliceTypes()

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

Definition at line 1762 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ printArrayConcatTypes()

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

Definition at line 2088 of file HWOps.cpp.

◆ printExtractOp()

template<typename AggType >
static 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 2519 of file HWOps.cpp.

◆ printModuleOp()

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

◆ printParamValue()

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

Definition at line 493 of file HWOps.cpp.

◆ printSliceTypes()

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

Definition at line 1776 of file HWOps.cpp.

◆ setAllPortNames()

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

Definition at line 1268 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ setHWModuleType()

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

Definition at line 1341 of file HWOps.cpp.

References circt::calyx::direction::get().

◆ verifyAggregateFieldIndexAndType()

template<typename AggregateOp , typename AggregateType >
static 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 2456 of file HWOps.cpp.

References elementType, and circt::hw::getCanonicalType().

◆ verifyModuleCommon()

static LogicalResult verifyModuleCommon ( HWModuleLike  module)
static

Definition at line 1078 of file HWOps.cpp.

References assert(), and circt::hw::checkParameterInContext().