CIRCT  18.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/HWSymCache.h"
#include "circt/Dialect/HW/HWVisitors.h"
#include "circt/Dialect/HW/InstanceImplementation.h"
#include "circt/Dialect/HW/ModuleImplementation.h"
#include "circt/Support/CustomDirectiveImpl.h"
#include "circt/Support/Namespace.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 }
 
enum  ExternModKind { PlainMod , ExternMod , GenMod }
 

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 bool hasAttribute (StringRef name, ArrayRef< NamedAttribute > attrs)
 
static void addPortAttrsAndLocs (Builder &builder, OperationState &result, SmallVectorImpl< module_like_impl::PortParse > &ports, StringAttr portAttrsName, StringAttr portLocsName)
 
template<typename ModuleTy >
static ParseResult parseHWModuleOp (OpAsmParser &parser, OperationState &result, ExternModKind modKind=PlainMod)
 
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 setAllPortLocs (ArrayRef< Location > locs, 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'. 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 3262 of file HWOps.cpp.

Enumeration Type Documentation

◆ Delimiter

enum Delimiter
strong
Enumerator
None 
Paren 
OptionalLessGreater 

Definition at line 115 of file HWOps.cpp.

◆ ExternModKind

Enumerator
PlainMod 
ExternMod 
GenMod 

Definition at line 545 of file HWOps.cpp.

Function Documentation

◆ addPortAttrsAndLocs()

static void addPortAttrsAndLocs ( Builder &  builder,
OperationState &  result,
SmallVectorImpl< module_like_impl::PortParse > &  ports,
StringAttr  portAttrsName,
StringAttr  portLocsName 
)
static

Definition at line 878 of file HWOps.cpp.

References builder.

Referenced by parseHWModuleOp().

◆ arrayOrEmpty()

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

Definition at line 83 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(), builder, and circt::calyx::direction::get().

◆ checkAttributes()

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

Definition at line 400 of file HWOps.cpp.

References elementType.

◆ flattenConcatOp()

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

Definition at line 2037 of file HWOps.cpp.

◆ foldCreateToSlice()

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

Definition at line 1771 of file HWOps.cpp.

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

◆ foldStructExtract()

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

Definition at line 68 of file HWOps.cpp.

◆ getAllPortLocs()

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

Definition at line 1187 of file HWOps.cpp.

References assert().

◆ 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 100 of file HWOps.cpp.

◆ getHWModuleOpType()

FunctionType getHWModuleOpType ( Operation *  op)

Definition at line 986 of file HWOps.cpp.

◆ getPort()

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

Definition at line 1401 of file HWOps.cpp.

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

◆ getPortList()

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

Definition at line 1382 of file HWOps.cpp.

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

◆ getUIntFromValue()

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

Definition at line 1842 of file HWOps.cpp.

References value.

◆ 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 342 of file HWOps.cpp.

◆ hasAttribute()

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

Definition at line 870 of file HWOps.cpp.

Referenced by parseHWModuleOp().

◆ mergeConcatSlices()

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

Definition at line 2054 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 591 of file HWOps.cpp.

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

Referenced by circt::hw::modifyModulePorts().

◆ parseArrayConcatTypes()

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

Definition at line 1971 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 2395 of file HWOps.cpp.

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

◆ parseHWModuleOp()

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

◆ parseParamValue()

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

Definition at line 482 of file HWOps.cpp.

References value.

◆ parseSliceTypes()

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

Definition at line 1675 of file HWOps.cpp.

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

◆ printArrayConcatTypes()

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

Definition at line 2001 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 2432 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 490 of file HWOps.cpp.

References value.

◆ printSliceTypes()

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

Definition at line 1689 of file HWOps.cpp.

◆ setAllPortLocs()

template<typename ModTy >
static void setAllPortLocs ( ArrayRef< Location >  locs,
ModTy  module 
)
static

Definition at line 1212 of file HWOps.cpp.

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

◆ setAllPortNames()

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

Definition at line 1230 of file HWOps.cpp.

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

◆ setHWModuleType()

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

Definition at line 1303 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 2369 of file HWOps.cpp.

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

◆ verifyModuleCommon()

static LogicalResult verifyModuleCommon ( HWModuleLike  module)
static

Definition at line 1047 of file HWOps.cpp.

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