14 #ifndef CIRCT_DIALECT_HW_TYPES_H
15 #define CIRCT_DIALECT_HW_TYPES_H
21 #include "mlir/IR/BuiltinTypes.h"
22 #include "mlir/IR/Types.h"
38 return llvm::hash_combine(port.
dir, port.
name, port.
type);
45 using KeyTy = ArrayRef<ModulePort>;
49 return std::equal(key.begin(), key.end(),
ports.begin(),
ports.end());
54 return llvm::hash_combine_range(key.begin(), key.end());
85 ModuleType
fnToMod(Operation *op, ArrayRef<Attribute> inputNames,
86 ArrayRef<Attribute> outputNames);
87 ModuleType
fnToMod(FunctionType fn, ArrayRef<Attribute> inputNames,
88 ArrayRef<Attribute> outputNames);
106 #define GET_TYPEDEF_CLASSES
107 #include "circt/Dialect/HW/HWTypes.h.inc"
140 template <
typename...
BaseTy>
143 if (isa<BaseTy...>(type))
147 if (
auto alias = dyn_cast<TypeAliasType>(type))
154 template <
typename...
BaseTy>
161 template <
typename BaseTy>
163 assert(type_isa<BaseTy>(type) &&
"type must convert to requested type");
166 if (isa<BaseTy>(type))
167 return cast<BaseTy>(type);
170 return type_cast<BaseTy>(cast<TypeAliasType>(type).getInnerType());
173 template <
typename BaseTy>
175 if (!type_isa<BaseTy>(type))
178 return type_cast<BaseTy>(type);
184 template <
typename... Types>
189 mlir::TypeStorage>::Base::Base;
196 template <
typename BaseTy>
201 mlir::TypeStorage>::Base::Base;
205 static bool classof(Type other) {
return type_isa<BaseTy>(other); }
208 operator BaseTy()
const {
return type_cast<BaseTy>(*
this); }
assert(baseType &&"element must be base type")
This stores lookup tables to make manipulating and working with the IR more efficient.
static bool classof(Type other)
Utility type that wraps a type that may be one of several possible Types.
static bool classof(Type other)
ModuleType fnToMod(Operation *op, ArrayRef< Attribute > inputNames, ArrayRef< Attribute > outputNames)
BaseTy type_cast(Type type)
bool isHWIntegerType(mlir::Type type)
Return true if the specified type is a value HW Integer type.
bool type_isa_and_nonnull(Type type)
BaseTy type_dyn_cast(Type type)
bool isHWValueType(mlir::Type type)
Return true if the specified type can be used as an HW value type, that is the set of types that can ...
static bool operator==(const ModulePort &a, const ModulePort &b)
static llvm::hash_code hash_value(const ModulePort &port)
int64_t getBitWidth(mlir::Type type)
Return the hardware bit width of a type.
bool isHWEnumType(mlir::Type type)
Return true if the specified type is a HW Enum type.
mlir::Type getCanonicalType(mlir::Type type)
bool hasHWInOutType(mlir::Type type)
Return true if the specified type contains known marker types like InOutType.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
Struct defining a field. Used in structs.
static ModuleTypeStorage * construct(mlir::TypeStorageAllocator &allocator, const KeyTy &key)
Define a construction method for creating a new instance of this storage.
ArrayRef< ModulePort > getPorts() const
SmallVector< ModulePort > ports
The parametric data held by the storage class.
ModuleTypeStorage(ArrayRef< ModulePort > inPorts)
static llvm::hash_code hashKey(const KeyTy &key)
Define a hash function for the key type.
SmallVector< size_t > absToInput
bool operator==(const KeyTy &key) const
Define the comparison function for the key type.
SmallVector< size_t > outputToAbs
SmallVector< size_t > inputToAbs
ArrayRef< ModulePort > KeyTy
KeyTy getAsKey() const
Construct an instance of the key from this storage class.
SmallVector< size_t > absToOutput
Struct defining a field with an offset. Used in unions.