Loading [MathJax]/extensions/tex2jax.js
CIRCT 21.0.0git
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FIRRTLTypes.h
Go to the documentation of this file.
1//===- FIRRTLTypes.h - FIRRTL Type System -----------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the type system for the FIRRTL Dialect.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef CIRCT_DIALECT_FIRRTL_TYPES_H
14#define CIRCT_DIALECT_FIRRTL_TYPES_H
15
20#include "circt/Support/LLVM.h"
21#include "mlir/IR/OpDefinition.h"
22#include "mlir/IR/Types.h"
23#include "llvm/ADT/TypeSwitch.h"
24
25namespace circt {
26namespace firrtl {
27namespace detail {
28struct FIRRTLBaseTypeStorage;
29struct WidthTypeStorage;
30struct BundleTypeStorage;
31struct FVectorTypeStorage;
32struct FEnumTypeStorage;
33struct CMemoryTypeStorage;
34struct RefTypeStorage;
35struct LHSTypeStorage;
36struct BaseTypeAliasStorage;
37struct OpenBundleTypeStorage;
38struct OpenVectorTypeStorage;
39struct ClassTypeStorage;
40} // namespace detail.
41
42class AnyRefType;
43class ClassType;
44class ClockType;
45class ResetType;
46class AsyncResetType;
47class SIntType;
48class UIntType;
49class AnalogType;
50class BundleType;
51class OpenBundleType;
52class OpenVectorType;
53class FVectorType;
54class FEnumType;
55class RefType;
56class LHSType;
57class PropertyType;
58class StringType;
59class FIntegerType;
60class ListType;
61class PathType;
62class BoolType;
63class DoubleType;
64class BaseTypeAliasType;
65class FStringType;
66
67/// A collection of bits indicating the recursive properties of a type.
69 /// Whether the type only contains passive elements.
70 bool isPassive : 1;
71 /// Whether the type contains a reference type.
73 /// Whether the type contains an analog type.
75 /// Whether the type contains a const type.
76 bool containsConst : 1;
77 /// Whether the type contains a type alias.
79 /// Whether the type has any uninferred bit widths.
81 /// Whether the type has any uninferred reset.
83};
84
85// This is a common base class for all FIRRTL types.
86class FIRRTLType : public Type {
87public:
88 /// Support method to enable LLVM-style type casting.
89 static bool classof(Type type) {
90 return llvm::isa<FIRRTLDialect>(type.getDialect());
91 }
92
93 /// Return the recursive properties of the type, containing the `isPassive`,
94 /// `containsAnalog`, and `hasUninferredWidth` bits, among others.
96
97 //===--------------------------------------------------------------------===//
98 // Convenience methods for accessing recursive type properties
99 //===--------------------------------------------------------------------===//
100
101 /// Returns true if this is or contains a 'const' type.
103
104 /// Return true if this is or contains an Analog type.
106
107 /// Return true if this is or contains a Reference type.
111
112 /// Return true if this is an anonymous type (no type alias).
116
117 /// Return true if this type contains an uninferred bit width.
121
122 /// Return true if this type contains an uninferred bit reset.
126
127 //===--------------------------------------------------------------------===//
128 // Type classifications
129 //===--------------------------------------------------------------------===//
130
131 /// Return true if this is a 'ground' type, aka a non-aggregate type.
132 bool isGround();
133
134 /// Returns true if this is a 'const' type that can only hold compile-time
135 /// constant values
136 bool isConst();
137
138protected:
139 using Type::Type;
140};
141
142// Common base class for all base FIRRTL types.
144 : public FIRRTLType::TypeBase<FIRRTLBaseType, FIRRTLType,
145 detail::FIRRTLBaseTypeStorage> {
146public:
147 using Base::Base;
148
149 /// Returns true if this is a 'const' type that can only hold compile-time
150 /// constant values
151 bool isConst();
152
153 /// Return true if this is a "passive" type - one that contains no "flip"
154 /// types recursively within itself.
155 bool isPassive() const { return getRecursiveTypeProperties().isPassive; }
156
157 /// Return this type with any flip types recursively removed from itself.
159
160 /// Return this type with any type alias types recursively removed from
161 /// itself.
163
164 /// Return a 'const' or non-'const' version of this type.
166
167 /// Return this type with a 'const' modifiers dropped
169
170 /// Return this type with all ground types replaced with UInt<1>. This is
171 /// used for `mem` operations.
173
174 /// Return this type with widths of all ground types removed. This
175 /// enables two types to be compared by structure and name ignoring
176 /// widths.
178
179 /// If this is an IntType, AnalogType, or sugar type for a single bit (Clock,
180 /// Reset, etc) then return the bitwidth. Return -1 if the is one of these
181 /// types but without a specified bitwidth. Return -2 if this isn't a simple
182 /// type.
183 int32_t getBitWidthOrSentinel();
184
185 /// Support method to enable LLVM-style type casting.
186 static bool classof(Type type) {
187 return llvm::isa<FIRRTLDialect>(type.getDialect()) &&
188 !llvm::isa<PropertyType, RefType, LHSType, OpenBundleType,
189 OpenVectorType, FStringType>(type);
190 }
191
192 /// Returns true if this is a non-const "passive" that which is not analog.
194 return isPassive() && !containsAnalog() && !containsConst();
195 }
196
197 /// Return true if this is a valid "reset" type.
198 bool isResetType();
199};
200
201/// Returns true if this is a 'const' type whose value is guaranteed to be
202/// unchanging at circuit execution time
203bool isConst(Type type);
204
205/// Returns true if the type is or contains a 'const' type whose value is
206/// guaranteed to be unchanging at circuit execution time
207bool containsConst(Type type);
208
209/// Return true if the type has zero bit width.
210bool hasZeroBitWidth(FIRRTLType type);
211
212/// Returns whether the two types are equivalent. This implements the exact
213/// definition of type equivalence in the FIRRTL spec. If the types being
214/// compared have any outer flips that encode FIRRTL module directions (input or
215/// output), these should be stripped before using this method.
216bool areTypesEquivalent(FIRRTLType destType, FIRRTLType srcType,
217 bool destOuterTypeIsConst = false,
218 bool srcOuterTypeIsConst = false,
219 bool requireSameWidths = false);
220
221/// Returns true if two types are weakly equivalent. See the FIRRTL spec,
222/// Section 4.6, for a full definition of this. Roughly, the oriented types
223/// (the types with any flips pushed to the leaves) must match. This allows for
224/// types with flips in different positions to be equivalent.
226 bool destFlip = false, bool srcFlip = false,
227 bool destOuterTypeIsConst = false,
228 bool srcOuterTypeIsConst = false);
229
230/// Returns whether the srcType can be const-casted to the destType.
231bool areTypesConstCastable(FIRRTLType destType, FIRRTLType srcType,
232 bool srcOuterTypeIsConst = false);
233
234/// Return true if destination ref type can be cast from source ref type,
235/// per FIRRTL spec rules they must be identical or destination has
236/// more general versions of the corresponding type in the source.
237bool areTypesRefCastable(Type dstType, Type srcType);
238
239/// Returns true if the destination is at least as wide as a source. The source
240/// and destination types must be equivalent non-analog types. The types are
241/// recursively connected to ensure that the destination is larger than the
242/// source: ground types are compared on width, vector types are checked
243/// recursively based on their elements and bundles are compared
244/// field-by-field. Types with unresolved widths are assumed to fit into or
245/// hold their counterparts.
246bool isTypeLarger(FIRRTLBaseType dstType, FIRRTLBaseType srcType);
247
248/// Return true if anonymous types of given arguments are equivalent by pointer
249/// comparison.
251bool areAnonymousTypesEquivalent(mlir::Type lhs, mlir::Type rhs);
252
253mlir::Type getPassiveType(mlir::Type anyBaseFIRRTLType);
254
255/// Returns true if the given type has some flipped (aka unaligned) dataflow.
256/// This will be true if the port contains either bi-directional signals or
257/// analog types. Non-HW types (e.g., ref types) are never considered InOut.
258bool isTypeInOut(mlir::Type type);
259
260//===----------------------------------------------------------------------===//
261// Width Qualified Ground Types
262//===----------------------------------------------------------------------===//
263
264/// Trait for types which have a width.
265/// Users must implement:
266/// ```c++
267/// /// Return the width if known, or -1 if unknown.
268/// int32_t getWidthOrSentinel();
269/// ```
270template <typename ConcreteType>
272 : public mlir::TypeTrait::TraitBase<ConcreteType, WidthQualifiedTypeTrait> {
273public:
274 /// Return an optional containing the width, if the width is known (or empty
275 /// if width is unknown).
276 std::optional<int32_t> getWidth() const {
277 auto width = static_cast<const ConcreteType *>(this)->getWidthOrSentinel();
278 if (width < 0)
279 return std::nullopt;
280 return width;
281 }
282
283 /// Return true if this integer type has a known width.
284 bool hasWidth() const {
285 return 0 <= static_cast<const ConcreteType *>(this)->getWidthOrSentinel();
286 }
287};
288
289//===----------------------------------------------------------------------===//
290// IntType
291//===----------------------------------------------------------------------===//
292
293class SIntType;
294class UIntType;
295
296/// This is the common base class between SIntType and UIntType.
297class IntType : public FIRRTLBaseType, public WidthQualifiedTypeTrait<IntType> {
298public:
299 using FIRRTLBaseType::FIRRTLBaseType;
300
301 /// Return an SIntType or UIntType with the specified signedness, width, and
302 /// constness.
303 static IntType get(MLIRContext *context, bool isSigned,
304 int32_t widthOrSentinel = -1, bool isConst = false);
305
306 bool isSigned() { return mlir::isa<SIntType>(*this); }
307 bool isUnsigned() { return mlir::isa<UIntType>(*this); }
308
309 /// Return the width of this type, or -1 if it has none specified.
310 int32_t getWidthOrSentinel() const;
311
312 /// Return a 'const' or non-'const' version of this type.
314
315 static bool classof(Type type) { return mlir::isa<SIntType, UIntType>(type); }
316};
317
318//===----------------------------------------------------------------------===//
319// PropertyTypes
320//===----------------------------------------------------------------------===//
321
322class PropertyType : public FIRRTLType {
323public:
324 /// Support method to enable LLVM-style type casting.
325 static bool classof(Type type) {
326 return llvm::isa<AnyRefType, ClassType, StringType, FIntegerType, ListType,
327 PathType, BoolType, DoubleType>(type);
328 }
329
330protected:
331 using FIRRTLType::FIRRTLType;
332};
333
334//===----------------------------------------------------------------------===//
335// ClassElement
336//===----------------------------------------------------------------------===//
337
341
342 StringAttr name;
343 Type type;
345
346 StringRef getName() const { return name.getValue(); }
347
348 /// Return true if this is a simple output-only element. If you want the
349 /// direction of the port, use the \p direction field directly.
350 bool isInput() const { return direction == Direction::In && !isInOut(); }
351
352 /// Return true if this is a simple input-only element. If you want the
353 /// direction of the port, use the \p direction field directly.
354 bool isOutput() const { return direction == Direction::Out && !isInOut(); }
355
356 /// Return true if this is an inout port. This will be true if the port
357 /// contains either bi-directional signals or analog types.
358 /// Non-HW types (e.g., ref types) are never considered InOut.
359 bool isInOut() const { return isTypeInOut(type); }
360
361 bool operator==(const ClassElement &rhs) const {
362 return name == rhs.name && type == rhs.type;
363 }
364
365 bool operator!=(const ClassElement &rhs) const { return !(*this == rhs); }
366};
367
368// NOLINTNEXTLINE(readability-identifier-naming)
369inline llvm::hash_code hash_value(const ClassElement &element) {
370 return llvm::hash_combine(element.name, element.type, element.direction);
371}
372
373//===----------------------------------------------------------------------===//
374// Type helpers
375//===----------------------------------------------------------------------===//
376
377// Get the bit width for this type, return None if unknown. Unlike
378// getBitWidthOrSentinel(), this can recursively compute the bitwidth of
379// aggregate types. For bundle and vectors, recursively get the width of each
380// field element and return the total bit width of the aggregate type. This
381// returns None, if any of the bundle fields is a flip type, or ground type with
382// unknown bit width.
383std::optional<int64_t> getBitWidth(FIRRTLBaseType type,
384 bool ignoreFlip = false);
385
386// Parse a FIRRTL type without a leading `!firrtl.` dialect tag.
387ParseResult parseNestedType(FIRRTLType &result, AsmParser &parser);
388ParseResult parseNestedBaseType(FIRRTLBaseType &result, AsmParser &parser);
389ParseResult parseNestedPropertyType(PropertyType &result, AsmParser &parser);
390
391// Print a FIRRTL type without a leading `!firrtl.` dialect tag.
392void printNestedType(Type type, AsmPrinter &os);
393
394using FIRRTLValue = mlir::TypedValue<FIRRTLType>;
395using FIRRTLBaseValue = mlir::TypedValue<FIRRTLBaseType>;
396using FIRRTLPropertyValue = mlir::TypedValue<PropertyType>;
397
398} // namespace firrtl
399} // namespace circt
400
401// Include generated types.
402#define GET_TYPEDEF_CLASSES
403#include "circt/Dialect/FIRRTL/FIRRTLTypes.h.inc"
404
405namespace llvm {
406
407// Type hash just like pointers.
408template <>
409struct DenseMapInfo<circt::firrtl::FIRRTLType> {
413 return FIRRTLType(static_cast<mlir::Type::ImplType *>(pointer));
414 }
417 return FIRRTLType(static_cast<mlir::Type::ImplType *>(pointer));
418 }
419 static unsigned getHashValue(FIRRTLType val) { return mlir::hash_value(val); }
420 static bool isEqual(FIRRTLType LHS, FIRRTLType RHS) { return LHS == RHS; }
421};
422
423} // namespace llvm
424
425namespace circt {
426namespace firrtl {
427//===--------------------------------------------------------------------===//
428// Utility for type aliases
429//===--------------------------------------------------------------------===//
430
431/// A struct to check if there is a type derived from FIRRTLBaseType.
432/// `ContainAliasableTypes<BaseTy>::value` returns true if `BaseTy` is derived
433/// from `FIRRTLBaseType` and not `FIRRTLBaseType` itself, or is not FIRRTL type
434/// to cover type interfaces.
435template <typename head, typename... tail>
437public:
438 static constexpr bool value = ContainAliasableTypes<head>::value ||
440};
441
442template <typename BaseTy>
444 static constexpr bool isFIRRTLBaseType =
445 std::is_base_of<FIRRTLBaseType, BaseTy>::value &&
446 !std::is_same_v<FIRRTLBaseType, BaseTy>;
447 static constexpr bool isFIRRTLType =
448 std::is_base_of<FIRRTLType, BaseTy>::value;
449
450public:
451 static constexpr bool value = isFIRRTLBaseType || !isFIRRTLType;
452};
453
454template <typename... BaseTy>
455bool type_isa(Type type) { // NOLINT(readability-identifier-naming)
456 // First check if the type is the requested type.
457 if (isa<BaseTy...>(type))
458 return true;
459
460 // If the requested type is a subtype of FIRRTLBaseType, then check if it is a
461 // type alias wrapping the requested type.
462 if constexpr (ContainAliasableTypes<BaseTy...>::value) {
463 if (auto alias = dyn_cast<BaseTypeAliasType>(type))
464 return type_isa<BaseTy...>(alias.getInnerType());
465 }
466
467 return false;
468}
469
470// type_isa for a nullable argument.
471template <typename... BaseTy>
472bool type_isa_and_nonnull(Type type) { // NOLINT(readability-identifier-naming)
473 if (!type)
474 return false;
475 return type_isa<BaseTy...>(type);
476}
477
478template <typename BaseTy>
479BaseTy type_cast(Type type) { // NOLINT(readability-identifier-naming)
480 assert(type_isa<BaseTy>(type) && "type must convert to requested type");
481
482 // If the type is the requested type, return it.
483 if (isa<BaseTy>(type))
484 return cast<BaseTy>(type);
485
486 // Otherwise, it must be a type alias wrapping the requested type.
488 if (auto alias = dyn_cast<BaseTypeAliasType>(type))
489 return type_cast<BaseTy>(alias.getInnerType());
490 }
491
492 // Otherwise, it should fail. `cast` should cause a better assertion failure,
493 // so just use it.
494 return cast<BaseTy>(type);
495}
496
497template <typename BaseTy>
498BaseTy type_dyn_cast(Type type) { // NOLINT(readability-identifier-naming)
499 if (type_isa<BaseTy>(type))
500 return type_cast<BaseTy>(type);
501 return {};
502}
503
504template <typename BaseTy>
505BaseTy
506type_dyn_cast_or_null(Type type) { // NOLINT(readability-identifier-naming)
507 if (type_isa_and_nonnull<BaseTy>(type))
508 return type_cast<BaseTy>(type);
509 return {};
510}
511
512//===--------------------------------------------------------------------===//
513// Type alias aware TypeSwitch.
514//===--------------------------------------------------------------------===//
515
516/// This class implements the same functionality as TypeSwitch except that
517/// it uses firrtl::type_dyn_cast for dynamic cast. llvm::TypeSwitch is not
518/// customizable so this class currently duplicates the code.
519template <typename T, typename ResultT = void>
521 : public llvm::detail::TypeSwitchBase<FIRRTLTypeSwitch<T, ResultT>, T> {
522public:
524 using BaseT::BaseT;
525 using BaseT::Case;
527
528 /// Add a case on the given type.
529 template <typename CaseT, typename CallableT>
531 Case(CallableT &&caseFn) { // NOLINT(readability-identifier-naming)
532 if (result)
533 return *this;
534
535 // Check to see if CaseT applies to 'value'. Use `type_dyn_cast` here.
536 if (auto caseValue = circt::firrtl::type_dyn_cast<CaseT>(this->value))
537 result.emplace(caseFn(caseValue));
538 return *this;
539 }
540
541 /// As a default, invoke the given callable within the root value.
542 template <typename CallableT>
543 [[nodiscard]] ResultT
544 Default(CallableT &&defaultFn) { // NOLINT(readability-identifier-naming)
545 if (result)
546 return std::move(*result);
547 return defaultFn(this->value);
548 }
549
550 /// As a default, return the given value.
551 [[nodiscard]] ResultT
552 Default(ResultT defaultResult) { // NOLINT(readability-identifier-naming)
553 if (result)
554 return std::move(*result);
555 return defaultResult;
556 }
557
558 [[nodiscard]] operator ResultT() {
559 assert(result && "Fell off the end of a type-switch");
560 return std::move(*result);
561 }
562
563private:
564 /// The pointer to the result of this switch statement, once known,
565 /// null before that.
566 std::optional<ResultT> result;
567};
568
569/// Specialization of FIRRTLTypeSwitch for void returning callables.
570template <typename T>
571class FIRRTLTypeSwitch<T, void>
572 : public llvm::detail::TypeSwitchBase<FIRRTLTypeSwitch<T, void>, T> {
573public:
575 using BaseT::BaseT;
576 using BaseT::Case;
578
579 /// Add a case on the given type.
580 template <typename CaseT, typename CallableT>
582 Case(CallableT &&caseFn) { // NOLINT(readability-identifier-naming)
583 if (foundMatch)
584 return *this;
585
586 // Check to see if any of the types apply to 'value'.
587 if (auto caseValue = circt::firrtl::type_dyn_cast<CaseT>(this->value)) {
588 caseFn(caseValue);
589 foundMatch = true;
590 }
591 return *this;
592 }
593
594 /// As a default, invoke the given callable within the root value.
595 template <typename CallableT>
596 void Default(CallableT &&defaultFn) { // NOLINT(readability-identifier-naming)
597 if (!foundMatch)
598 defaultFn(this->value);
599 }
600
601private:
602 /// A flag detailing if we have already found a match.
603 bool foundMatch = false;
604};
605
606template <typename BaseTy>
608 : public ::mlir::Type::TypeBase<BaseTypeAliasOr<BaseTy>,
609 firrtl::FIRRTLBaseType,
610 detail::FIRRTLBaseTypeStorage> {
611
612public:
615 // Support LLVM isa/cast/dyn_cast to BaseTy.
616 static bool classof(Type other) { return type_isa<BaseTy>(other); }
617
618 // Support C++ implicit conversions to BaseTy.
619 operator BaseTy() const { return circt::firrtl::type_cast<BaseTy>(*this); }
620
621 BaseTy base() const { return circt::firrtl::type_cast<BaseTy>(*this); }
622};
623
624} // namespace firrtl
625} // namespace circt
626
627#endif // CIRCT_DIALECT_FIRRTL_TYPES_H
assert(baseType &&"element must be base type")
static bool classof(Type other)
A struct to check if there is a type derived from FIRRTLBaseType.
FIRRTLBaseType getAnonymousType()
Return this type with any type alias types recursively removed from itself.
static bool classof(Type type)
Support method to enable LLVM-style type casting.
bool isResetType()
Return true if this is a valid "reset" type.
bool isRegisterType()
Returns true if this is a non-const "passive" that which is not analog.
FIRRTLBaseType getMaskType()
Return this type with all ground types replaced with UInt<1>.
FIRRTLBaseType getPassiveType()
Return this type with any flip types recursively removed from itself.
int32_t getBitWidthOrSentinel()
If this is an IntType, AnalogType, or sugar type for a single bit (Clock, Reset, etc) then return the...
bool isConst()
Returns true if this is a 'const' type that can only hold compile-time constant values.
FIRRTLBaseType getAllConstDroppedType()
Return this type with a 'const' modifiers dropped.
bool isPassive() const
Return true if this is a "passive" type - one that contains no "flip" types recursively within itself...
FIRRTLBaseType getConstType(bool isConst)
Return a 'const' or non-'const' version of this type.
FIRRTLBaseType getWidthlessType()
Return this type with widths of all ground types removed.
void Default(CallableT &&defaultFn)
As a default, invoke the given callable within the root value.
FIRRTLTypeSwitch< T, void > & Case(CallableT &&caseFn)
Add a case on the given type.
FIRRTLTypeSwitch(FIRRTLTypeSwitch &&other)=default
This class implements the same functionality as TypeSwitch except that it uses firrtl::type_dyn_cast ...
ResultT Default(ResultT defaultResult)
As a default, return the given value.
FIRRTLTypeSwitch< T, ResultT > & Case(CallableT &&caseFn)
Add a case on the given type.
FIRRTLTypeSwitch(FIRRTLTypeSwitch &&other)=default
ResultT Default(CallableT &&defaultFn)
As a default, invoke the given callable within the root value.
std::optional< ResultT > result
The pointer to the result of this switch statement, once known, null before that.
bool containsReference()
Return true if this is or contains a Reference type.
bool isGround()
Return true if this is a 'ground' type, aka a non-aggregate type.
static bool classof(Type type)
Support method to enable LLVM-style type casting.
Definition FIRRTLTypes.h:89
bool isConst()
Returns true if this is a 'const' type that can only hold compile-time constant values.
bool hasUninferredWidth()
Return true if this type contains an uninferred bit width.
bool containsTypeAlias()
Return true if this is an anonymous type (no type alias).
RecursiveTypeProperties getRecursiveTypeProperties() const
Return the recursive properties of the type, containing the isPassive, containsAnalog,...
bool hasUninferredReset()
Return true if this type contains an uninferred bit reset.
bool containsAnalog()
Return true if this is or contains an Analog type.
bool containsConst()
Returns true if this is or contains a 'const' type.
This is the common base class between SIntType and UIntType.
static bool classof(Type type)
int32_t getWidthOrSentinel() const
Return the width of this type, or -1 if it has none specified.
static IntType get(MLIRContext *context, bool isSigned, int32_t widthOrSentinel=-1, bool isConst=false)
Return an SIntType or UIntType with the specified signedness, width, and constness.
IntType getConstType(bool isConst)
Return a 'const' or non-'const' version of this type.
static bool classof(Type type)
Support method to enable LLVM-style type casting.
Trait for types which have a width.
bool hasWidth() const
Return true if this integer type has a known width.
std::optional< int32_t > getWidth() const
Return an optional containing the width, if the width is known (or empty if width is unknown).
BaseTy type_cast(Type type)
Direction
This represents the direction of a single port.
mlir::TypedValue< FIRRTLBaseType > FIRRTLBaseValue
ParseResult parseNestedType(FIRRTLType &result, AsmParser &parser)
Parse a FIRRTLType.
bool areAnonymousTypesEquivalent(FIRRTLBaseType lhs, FIRRTLBaseType rhs)
Return true if anonymous types of given arguments are equivalent by pointer comparison.
bool type_isa_and_nonnull(Type type)
ParseResult parseNestedBaseType(FIRRTLBaseType &result, AsmParser &parser)
bool isTypeInOut(mlir::Type type)
Returns true if the given type has some flipped (aka unaligned) dataflow.
bool areTypesRefCastable(Type dstType, Type srcType)
Return true if destination ref type can be cast from source ref type, per FIRRTL spec rules they must...
bool areTypesEquivalent(FIRRTLType destType, FIRRTLType srcType, bool destOuterTypeIsConst=false, bool srcOuterTypeIsConst=false, bool requireSameWidths=false)
Returns whether the two types are equivalent.
bool areTypesWeaklyEquivalent(FIRRTLType destType, FIRRTLType srcType, bool destFlip=false, bool srcFlip=false, bool destOuterTypeIsConst=false, bool srcOuterTypeIsConst=false)
Returns true if two types are weakly equivalent.
mlir::Type getPassiveType(mlir::Type anyBaseFIRRTLType)
bool isTypeLarger(FIRRTLBaseType dstType, FIRRTLBaseType srcType)
Returns true if the destination is at least as wide as a source.
bool containsConst(Type type)
Returns true if the type is or contains a 'const' type whose value is guaranteed to be unchanging at ...
mlir::TypedValue< FIRRTLType > FIRRTLValue
bool hasZeroBitWidth(FIRRTLType type)
Return true if the type has zero bit width.
BaseTy type_dyn_cast(Type type)
void printNestedType(Type type, AsmPrinter &os)
Print a type defined by this dialect.
BaseTy type_dyn_cast_or_null(Type type)
mlir::TypedValue< PropertyType > FIRRTLPropertyValue
bool isConst(Type type)
Returns true if this is a 'const' type whose value is guaranteed to be unchanging at circuit executio...
llvm::hash_code hash_value(const ClassElement &element)
bool areTypesConstCastable(FIRRTLType destType, FIRRTLType srcType, bool srcOuterTypeIsConst=false)
Returns whether the srcType can be const-casted to the destType.
bool type_isa(Type type)
ParseResult parseNestedPropertyType(PropertyType &result, AsmParser &parser)
std::optional< int64_t > getBitWidth(FIRRTLBaseType type, bool ignoreFlip=false)
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
llvm::hash_code hash_value(const T &e)
bool isInOut() const
Return true if this is an inout port.
ClassElement(StringAttr name, Type type, Direction direction)
bool isOutput() const
Return true if this is a simple input-only element.
bool isInput() const
Return true if this is a simple output-only element.
StringRef getName() const
bool operator!=(const ClassElement &rhs) const
bool operator==(const ClassElement &rhs) const
A collection of bits indicating the recursive properties of a type.
Definition FIRRTLTypes.h:68
bool containsReference
Whether the type contains a reference type.
Definition FIRRTLTypes.h:72
bool isPassive
Whether the type only contains passive elements.
Definition FIRRTLTypes.h:70
bool containsAnalog
Whether the type contains an analog type.
Definition FIRRTLTypes.h:74
bool hasUninferredReset
Whether the type has any uninferred reset.
Definition FIRRTLTypes.h:82
bool containsTypeAlias
Whether the type contains a type alias.
Definition FIRRTLTypes.h:78
bool containsConst
Whether the type contains a const type.
Definition FIRRTLTypes.h:76
bool hasUninferredWidth
Whether the type has any uninferred bit widths.
Definition FIRRTLTypes.h:80
static unsigned getHashValue(FIRRTLType val)
static bool isEqual(FIRRTLType LHS, FIRRTLType RHS)