CIRCT  20.0.0git
Classes | Macros | Enumerations | Functions
FIRRTLTypes.cpp File Reference
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/HW/HWTypeInterfaces.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/TypeSwitch.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.cpp.inc"
Include dependency graph for FIRRTLTypes.cpp:

Go to the source code of this file.

Classes

struct  circt::firrtl::detail::FIRRTLBaseTypeStorage
 
struct  circt::firrtl::detail::WidthTypeStorage
 
struct  circt::firrtl::detail::BundleTypeStorage
 
struct  circt::firrtl::detail::OpenBundleTypeStorage
 
struct  circt::firrtl::detail::FVectorTypeStorage
 
struct  circt::firrtl::detail::OpenVectorTypeStorage
 
struct  circt::firrtl::detail::FEnumTypeStorage
 
struct  circt::firrtl::detail::BaseTypeAliasStorage
 
struct  circt::firrtl::detail::ClassTypeStorage
 

Macros

#define GET_TYPEDEF_CLASSES
 
#define GET_TYPEDEF_LIST
 

Enumerations

enum  { IsPassiveBitMask = 0x1 , ContainsAnalogBitMask = 0x2 , HasUninferredWidthBitMask = 0x4 }
 

Functions

static LogicalResult customTypePrinter (Type type, AsmPrinter &os)
 Print a type with a custom printer implementation. More...
 
static OptionalParseResult customTypeParser (AsmParser &parser, StringRef name, Type &result)
 Parse a type with a custom parser implementation. More...
 
static ParseResult parseType (Type &result, StringRef name, AsmParser &parser)
 Parse a type defined by this dialect. More...
 
static ParseResult parseFIRRTLType (FIRRTLType &result, StringRef name, AsmParser &parser)
 Parse a FIRRTLType with a name that has already been parsed. More...
 
static ParseResult parseFIRRTLBaseType (FIRRTLBaseType &result, StringRef name, AsmParser &parser)
 
static ParseResult parseFIRRTLPropertyType (PropertyType &result, StringRef name, AsmParser &parser)
 
static bool areBundleElementsEquivalent (BundleType::BundleElement destElement, BundleType::BundleElement srcElement, bool destOuterTypeIsConst, bool srcOuterTypeIsConst, bool requiresSameWidth)
 Helper to implement the equivalence logic for a pair of bundle elements. More...
 

Macro Definition Documentation

◆ GET_TYPEDEF_CLASSES

#define GET_TYPEDEF_CLASSES

Definition at line 33 of file FIRRTLTypes.cpp.

◆ GET_TYPEDEF_LIST

#define GET_TYPEDEF_LIST

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
IsPassiveBitMask 

Bit set if the type only contains passive elements.

ContainsAnalogBitMask 

Bit set if the type contains an analog type.

HasUninferredWidthBitMask 

Bit set fi the type has any uninferred bit widths.

Definition at line 590 of file FIRRTLTypes.cpp.

Function Documentation

◆ areBundleElementsEquivalent()

static bool areBundleElementsEquivalent ( BundleType::BundleElement  destElement,
BundleType::BundleElement  srcElement,
bool  destOuterTypeIsConst,
bool  srcOuterTypeIsConst,
bool  requiresSameWidth 
)
static

Helper to implement the equivalence logic for a pair of bundle elements.

Note that the FIRRTL spec requires bundle elements to have the same orientation, but this only compares their passive types. The FIRRTL dialect differs from the spec in how it uses flip types for module output ports and canonicalizes flips in bundles, so only passive types can be compared here.

Definition at line 879 of file FIRRTLTypes.cpp.

References circt::firrtl::areTypesEquivalent().

Referenced by circt::firrtl::areTypesEquivalent().

◆ customTypeParser()

static OptionalParseResult customTypeParser ( AsmParser &  parser,
StringRef  name,
Type &  result 
)
static

Parse a type with a custom parser implementation.

This only accepts a subset of all types in the dialect. Use parseType instead, which will call this function in turn, as appropriate.

Returns std::nullopt if the type name is not covered by the custom parsers. Otherwise returns success or failure as appropriate. On success, result is set to the resulting type.

firrtl-type
::= clock
::= reset
::= asyncreset
::= sint ('<' int '>')?
::= uint ('<' int '>')?
::= analog ('<' int '>')?
::= bundle '<' (bundle-elt (',' bundle-elt)*)? '>'
::= enum '<' (enum-elt (',' enum-elt)*)? '>'
::= vector '<' type ',' int '>'
::= const '.' type
::= 'property.' firrtl-phased-type
bundle-elt ::= identifier flip? ':' type
enum-elt ::= identifier ':' type

Definition at line 186 of file FIRRTLTypes.cpp.

Referenced by parseType().

◆ customTypePrinter()

static LogicalResult customTypePrinter ( Type  type,
AsmPrinter &  os 
)
static

Print a type with a custom printer implementation.

This only prints a subset of all types in the dialect. Use printNestedType instead, which will call this function in turn, as appropriate.

Definition at line 45 of file FIRRTLTypes.cpp.

References circt::firrtl::isConst().

◆ parseFIRRTLBaseType()

static ParseResult parseFIRRTLBaseType ( FIRRTLBaseType result,
StringRef  name,
AsmParser &  parser 
)
static

Definition at line 507 of file FIRRTLTypes.cpp.

References parseFIRRTLType().

Referenced by circt::firrtl::parseNestedBaseType().

◆ parseFIRRTLPropertyType()

static ParseResult parseFIRRTLPropertyType ( PropertyType result,
StringRef  name,
AsmParser &  parser 
)
static

Definition at line 520 of file FIRRTLTypes.cpp.

References parseFIRRTLType().

Referenced by circt::firrtl::parseNestedPropertyType().

◆ parseFIRRTLType()

static ParseResult parseFIRRTLType ( FIRRTLType result,
StringRef  name,
AsmParser &  parser 
)
static

Parse a FIRRTLType with a name that has already been parsed.

Note that only a subset of types defined in the FIRRTL dialect inherit from FIRRTLType. Use parseType to parse any of the defined types.

Definition at line 494 of file FIRRTLTypes.cpp.

References parseType().

Referenced by parseFIRRTLBaseType(), parseFIRRTLPropertyType(), and circt::firrtl::parseNestedType().

◆ parseType()

static ParseResult parseType ( Type &  result,
StringRef  name,
AsmParser &  parser 
)
static

Parse a type defined by this dialect.

This will first try the generated type parsers and then resort to the custom parser implementation. Emits an error and returns failure if name does not refer to a type defined in this dialect.

Definition at line 478 of file FIRRTLTypes.cpp.

References customTypeParser().

Referenced by parseFIRRTLType(), parseParameterList(), Manifest::Impl::parseType(), and Manifest::Impl::populateTypes().