CIRCT
20.0.0git
|
#include "circt-c/Dialect/FIRRTL.h"
#include "circt/Dialect/FIRRTL/FIRRTLAttributes.h"
#include "circt/Dialect/FIRRTL/FIRRTLDialect.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/Import/FIRAnnotations.h"
#include "mlir/CAPI/IR.h"
#include "mlir/CAPI/Registration.h"
#include "mlir/CAPI/Support.h"
#include "llvm/Support/JSON.h"
Go to the source code of this file.
Functions | |
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION (FIRRTL, firrtl, circt::firrtl::FIRRTLDialect) bool firrtlTypeIsConst(MlirType type) | |
MlirType | firrtlTypeGetConstType (MlirType type, bool isConst) |
Returns a const or non-const version of this type. More... | |
int64_t | firrtlTypeGetBitWidth (MlirType type, bool ignoreFlip) |
Gets the bit width for this type, returns -1 if unknown. More... | |
bool | firrtlTypeIsAUInt (MlirType type) |
Checks if this type is a unsigned integer type. More... | |
MlirType | firrtlTypeGetUInt (MlirContext ctx, int32_t width) |
Creates a unsigned integer type with the specified width. More... | |
bool | firrtlTypeIsASInt (MlirType type) |
Checks if this type is a signed integer type. More... | |
MlirType | firrtlTypeGetSInt (MlirContext ctx, int32_t width) |
Creates a signed integer type with the specified width. More... | |
bool | firrtlTypeIsAClock (MlirType type) |
Checks if this type is a clock type. More... | |
MlirType | firrtlTypeGetClock (MlirContext ctx) |
Creates a clock type. More... | |
bool | firrtlTypeIsAReset (MlirType type) |
Checks if this type is a reset type. More... | |
MlirType | firrtlTypeGetReset (MlirContext ctx) |
Creates a reset type. More... | |
bool | firrtlTypeIsAAsyncReset (MlirType type) |
Checks if this type is an async reset type. More... | |
MlirType | firrtlTypeGetAsyncReset (MlirContext ctx) |
Creates an async reset type. More... | |
bool | firrtlTypeIsAAnalog (MlirType type) |
Checks if this type is an analog type. More... | |
MlirType | firrtlTypeGetAnalog (MlirContext ctx, int32_t width) |
Creates an analog type with the specified width. More... | |
bool | firrtlTypeIsAVector (MlirType type) |
Checks if this type is a vector type. More... | |
MlirType | firrtlTypeGetVector (MlirContext ctx, MlirType element, size_t count) |
Creates a vector type with the specified element type and count. More... | |
MlirType | firrtlTypeGetVectorElement (MlirType vec) |
Returns the element type of a vector type. More... | |
size_t | firrtlTypeGetVectorNumElements (MlirType vec) |
Returns the number of elements in a vector type. More... | |
bool | firrtlTypeIsABundle (MlirType type) |
Returns true if the specified type is a bundle type. More... | |
bool | firrtlTypeIsAOpenBundle (MlirType type) |
Returns true if the specified type is an open bundle type. More... | |
MlirType | firrtlTypeGetBundle (MlirContext ctx, size_t count, const FIRRTLBundleField *fields) |
Creates a bundle type with the specified fields. More... | |
size_t | firrtlTypeGetBundleNumFields (MlirType bundle) |
Returns the number of fields in the bundle type. More... | |
bool | firrtlTypeGetBundleFieldByIndex (MlirType type, size_t index, FIRRTLBundleField *field) |
Returns the field at the specified index in the bundle type. More... | |
unsigned | firrtlTypeGetBundleFieldIndex (MlirType type, MlirStringRef fieldName) |
Returns the index of the field with the specified name in the bundle type. More... | |
bool | firrtlTypeIsARef (MlirType type) |
Checks if this type is a ref type. More... | |
MlirType | firrtlTypeGetRef (MlirType target, bool forceable) |
Creates a ref type. More... | |
bool | firrtlTypeIsAAnyRef (MlirType type) |
Checks if this type is an anyref type. More... | |
MlirType | firrtlTypeGetAnyRef (MlirContext ctx) |
Creates an anyref type. More... | |
bool | firrtlTypeIsAInteger (MlirType type) |
Checks if this type is a property integer type. More... | |
MlirType | firrtlTypeGetInteger (MlirContext ctx) |
Creates a property integer type. More... | |
bool | firrtlTypeIsADouble (MlirType type) |
Checks if this type is a property double type. More... | |
MlirType | firrtlTypeGetDouble (MlirContext ctx) |
Creates a property double type. More... | |
bool | firrtlTypeIsAString (MlirType type) |
Checks if this type is a property string type. More... | |
MlirType | firrtlTypeGetString (MlirContext ctx) |
Creates a property string type. More... | |
bool | firrtlTypeIsABoolean (MlirType type) |
Checks if this type is a property boolean type. More... | |
MlirType | firrtlTypeGetBoolean (MlirContext ctx) |
Creates a property boolean type. More... | |
bool | firrtlTypeIsAPath (MlirType type) |
Checks if this type is a property path type. More... | |
MlirType | firrtlTypeGetPath (MlirContext ctx) |
Creates a property path type. More... | |
bool | firrtlTypeIsAList (MlirType type) |
Checks if this type is a property list type. More... | |
MlirType | firrtlTypeGetList (MlirContext ctx, MlirType elementType) |
Creates a property list type with the specified element type. More... | |
bool | firrtlTypeIsAClass (MlirType type) |
Checks if this type is a class type. More... | |
MlirType | firrtlTypeGetClass (MlirContext ctx, MlirAttribute name, size_t numberOfElements, const FIRRTLClassElement *elements) |
Creates a class type with the specified name and elements. More... | |
MlirType | firrtlTypeGetMaskType (MlirType type) |
Returns this type with all ground types replaced with UInt<1>. More... | |
MlirAttribute | firrtlAttrGetConvention (MlirContext ctx, FIRRTLConvention convention) |
Creates an ConventionAttr with the specified value. More... | |
MlirAttribute | firrtlAttrGetPortDirs (MlirContext ctx, size_t count, const FIRRTLDirection *dirs) |
Creates a DenseBoolArrayAttr with the specified port directions. More... | |
MlirAttribute | firrtlAttrGetParamDecl (MlirContext ctx, MlirIdentifier name, MlirType type, MlirAttribute value) |
Creates a ParamDeclAttr with the specified name, type, and value. More... | |
MlirAttribute | firrtlAttrGetNameKind (MlirContext ctx, FIRRTLNameKind nameKind) |
Creates a NameKindEnumAttr with the specified name preservation semantic. More... | |
MlirAttribute | firrtlAttrGetRUW (MlirContext ctx, FIRRTLRUW ruw) |
Creates a RUWAttr with the specified Read-Under-Write Behaviour. More... | |
MlirAttribute | firrtlAttrGetMemInit (MlirContext ctx, MlirIdentifier filename, bool isBinary, bool isInline) |
Creates a MemoryInitAttr with the specified memory initialization information. More... | |
MlirAttribute | firrtlAttrGetMemDir (MlirContext ctx, FIRRTLMemDir dir) |
Creates a MemDirAttr with the specified memory port direction. More... | |
MlirAttribute | firrtlAttrGetEventControl (MlirContext ctx, FIRRTLEventControl eventControl) |
Creates a EventControlAttr with the specified value. More... | |
MlirAttribute | firrtlAttrGetIntegerFromString (MlirType type, unsigned numBits, MlirStringRef str, uint8_t radix) |
Creates an IntegerAttr from a string representation of integer. More... | |
FIRRTLValueFlow | firrtlValueFoldFlow (MlirValue value, FIRRTLValueFlow flow) |
Computes the flow for a Value, value , as determined by the FIRRTL specification. More... | |
bool | firrtlImportAnnotationsFromJSONRaw (MlirContext ctx, MlirStringRef annotationsStr, MlirAttribute *importedAnnotationsArray) |
Deserializes a JSON value into FIRRTL Annotations. More... | |
MlirAttribute firrtlAttrGetConvention | ( | MlirContext | ctx, |
FIRRTLConvention | convention | ||
) |
Creates an ConventionAttr with the specified value.
Definition at line 278 of file FIRRTL.cpp.
References FIRRTL_CONVENTION_INTERNAL, FIRRTL_CONVENTION_SCALARIZED, circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetEventControl | ( | MlirContext | ctx, |
FIRRTLEventControl | eventControl | ||
) |
Creates a EventControlAttr with the specified value.
Definition at line 373 of file FIRRTL.cpp.
References FIRRTL_EVENT_CONTROL_AT_EDGE, FIRRTL_EVENT_CONTROL_AT_NEG_EDGE, FIRRTL_EVENT_CONTROL_AT_POS_EDGE, circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetIntegerFromString | ( | MlirType | type, |
unsigned | numBits, | ||
MlirStringRef | str, | ||
uint8_t | radix | ||
) |
Creates an IntegerAttr from a string representation of integer.
This is a workaround for supporting large integers. See https://github.com/llvm/llvm-project/issues/84190#issuecomment-2035552035
Definition at line 392 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetMemDir | ( | MlirContext | ctx, |
FIRRTLMemDir | dir | ||
) |
Creates a MemDirAttr with the specified memory port direction.
Definition at line 352 of file FIRRTL.cpp.
References FIRRTL_MEM_DIR_INFER, FIRRTL_MEM_DIR_READ, FIRRTL_MEM_DIR_READ_WRITE, FIRRTL_MEM_DIR_WRITE, circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetMemInit | ( | MlirContext | ctx, |
MlirIdentifier | filename, | ||
bool | isBinary, | ||
bool | isInline | ||
) |
Creates a MemoryInitAttr with the specified memory initialization information.
Definition at line 346 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetNameKind | ( | MlirContext | ctx, |
FIRRTLNameKind | nameKind | ||
) |
Creates a NameKindEnumAttr with the specified name preservation semantic.
Definition at line 313 of file FIRRTL.cpp.
References FIRRTL_NAME_KIND_DROPPABLE_NAME, FIRRTL_NAME_KIND_INTERESTING_NAME, circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetParamDecl | ( | MlirContext | ctx, |
MlirIdentifier | name, | ||
MlirType | type, | ||
MlirAttribute | value | ||
) |
Creates a ParamDeclAttr with the specified name, type, and value.
This is used for module or instance parameter definition.
Definition at line 307 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetPortDirs | ( | MlirContext | ctx, |
size_t | count, | ||
const FIRRTLDirection * | dirs | ||
) |
Creates a DenseBoolArrayAttr with the specified port directions.
Definition at line 294 of file FIRRTL.cpp.
References FIRRTL_DIRECTION_IN, FIRRTL_DIRECTION_OUT, circt::firrtl::In, circt::firrtl::Out, circt::firrtl::direction::packAttribute(), unwrap(), and wrap().
MlirAttribute firrtlAttrGetRUW | ( | MlirContext | ctx, |
FIRRTLRUW | ruw | ||
) |
Creates a RUWAttr with the specified Read-Under-Write Behaviour.
Definition at line 328 of file FIRRTL.cpp.
References FIRRTL_RUW_NEW, FIRRTL_RUW_OLD, FIRRTL_RUW_UNDEFINED, circt::calyx::direction::get(), unwrap(), and wrap().
bool firrtlImportAnnotationsFromJSONRaw | ( | MlirContext | ctx, |
MlirStringRef | annotationsStr, | ||
MlirAttribute * | importedAnnotationsArray | ||
) |
Deserializes a JSON value into FIRRTL Annotations.
Annotations are represented as a Target-keyed arrays of attributes. The input JSON value is checked, at runtime, to be an array of objects. Returns true if successful, false if unsuccessful.
Definition at line 431 of file FIRRTL.cpp.
References circt::calyx::direction::get(), circt::firrtl::importAnnotationsFromJSONRaw(), unwrap(), and wrap().
MlirType firrtlTypeGetAnalog | ( | MlirContext | ctx, |
int32_t | width | ||
) |
Creates an analog type with the specified width.
Definition at line 87 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetAnyRef | ( | MlirContext | ctx | ) |
Creates an anyref type.
Definition at line 199 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetAsyncReset | ( | MlirContext | ctx | ) |
Creates an async reset type.
Definition at line 79 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
int64_t firrtlTypeGetBitWidth | ( | MlirType | type, |
bool | ignoreFlip | ||
) |
Gets the bit width for this type, returns -1 if unknown.
It recursively computes the bit width of aggregate types. For bundle and vectors, recursively get the width of each field element and return the total bit width of the aggregate type. This returns -1, if any of the bundle fields is a flip type, or ground type with unknown bit width.
Definition at line 46 of file FIRRTL.cpp.
References circt::firrtl::getBitWidth(), and unwrap().
MlirType firrtlTypeGetBoolean | ( | MlirContext | ctx | ) |
Creates a property boolean type.
Definition at line 229 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetBundle | ( | MlirContext | ctx, |
size_t | count, | ||
const FIRRTLBundleField * | fields | ||
) |
Creates a bundle type with the specified fields.
If any field has a non-FIRRTL base type, an open bundle type is returned, otherwise a normal bundle type is returned.
Definition at line 118 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
bool firrtlTypeGetBundleFieldByIndex | ( | MlirType | type, |
size_t | index, | ||
FIRRTLBundleField * | field | ||
) |
Returns the field at the specified index in the bundle type.
Definition at line 154 of file FIRRTL.cpp.
References FIRRTLBundleField::isFlip, FIRRTLBundleField::name, FIRRTLBundleField::type, unwrap(), and wrap().
unsigned firrtlTypeGetBundleFieldIndex | ( | MlirType | type, |
MlirStringRef | fieldName | ||
) |
Returns the index of the field with the specified name in the bundle type.
Definition at line 173 of file FIRRTL.cpp.
size_t firrtlTypeGetBundleNumFields | ( | MlirType | bundle | ) |
Returns the number of fields in the bundle type.
Definition at line 144 of file FIRRTL.cpp.
References unwrap().
MlirType firrtlTypeGetClass | ( | MlirContext | ctx, |
MlirAttribute | name, | ||
size_t | numberOfElements, | ||
const FIRRTLClassElement * | elements | ||
) |
Creates a class type with the specified name and elements.
Definition at line 250 of file FIRRTL.cpp.
References assert(), FIRRTLClassElement::direction, FIRRTL_DIRECTION_IN, circt::calyx::direction::get(), circt::firrtl::In, circt::firrtl::Out, unwrap(), and wrap().
MlirType firrtlTypeGetClock | ( | MlirContext | ctx | ) |
Creates a clock type.
Definition at line 65 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetConstType | ( | MlirType | type, |
bool | isConst | ||
) |
Returns a const or non-const version of this type.
Definition at line 42 of file FIRRTL.cpp.
References circt::firrtl::isConst(), unwrap(), and wrap().
MlirType firrtlTypeGetDouble | ( | MlirContext | ctx | ) |
Creates a property double type.
Definition at line 215 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetInteger | ( | MlirContext | ctx | ) |
Creates a property integer type.
Definition at line 207 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetList | ( | MlirContext | ctx, |
MlirType | elementType | ||
) |
Creates a property list type with the specified element type.
Definition at line 241 of file FIRRTL.cpp.
References assert(), elementType, circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetMaskType | ( | MlirType | type | ) |
Returns this type with all ground types replaced with UInt<1>.
This is used for mem
operations.
Definition at line 268 of file FIRRTL.cpp.
MlirType firrtlTypeGetPath | ( | MlirContext | ctx | ) |
Creates a property path type.
Definition at line 235 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetRef | ( | MlirType | target, |
bool | forceable | ||
) |
Creates a ref type.
Definition at line 188 of file FIRRTL.cpp.
References assert(), circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetReset | ( | MlirContext | ctx | ) |
Creates a reset type.
Definition at line 71 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetSInt | ( | MlirContext | ctx, |
int32_t | width | ||
) |
Creates a signed integer type with the specified width.
Definition at line 59 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetString | ( | MlirContext | ctx | ) |
Creates a property string type.
Definition at line 223 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetUInt | ( | MlirContext | ctx, |
int32_t | width | ||
) |
Creates a unsigned integer type with the specified width.
Definition at line 53 of file FIRRTL.cpp.
References circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetVector | ( | MlirContext | ctx, |
MlirType | element, | ||
size_t | count | ||
) |
Creates a vector type with the specified element type and count.
Definition at line 95 of file FIRRTL.cpp.
References assert(), circt::calyx::direction::get(), unwrap(), and wrap().
MlirType firrtlTypeGetVectorElement | ( | MlirType | vec | ) |
Returns the element type of a vector type.
Definition at line 102 of file FIRRTL.cpp.
size_t firrtlTypeGetVectorNumElements | ( | MlirType | vec | ) |
Returns the number of elements in a vector type.
Definition at line 106 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAAnalog | ( | MlirType | type | ) |
Checks if this type is an analog type.
Definition at line 83 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAAnyRef | ( | MlirType | type | ) |
Checks if this type is an anyref type.
Definition at line 195 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAAsyncReset | ( | MlirType | type | ) |
Checks if this type is an async reset type.
Definition at line 75 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsABoolean | ( | MlirType | type | ) |
Checks if this type is a property boolean type.
Definition at line 227 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsABundle | ( | MlirType | type | ) |
Returns true if the specified type is a bundle type.
Definition at line 110 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAClass | ( | MlirType | type | ) |
Checks if this type is a class type.
Definition at line 248 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAClock | ( | MlirType | type | ) |
bool firrtlTypeIsADouble | ( | MlirType | type | ) |
Checks if this type is a property double type.
Definition at line 211 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAInteger | ( | MlirType | type | ) |
Checks if this type is a property integer type.
Definition at line 203 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAList | ( | MlirType | type | ) |
Checks if this type is a property list type.
Definition at line 239 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAOpenBundle | ( | MlirType | type | ) |
Returns true if the specified type is an open bundle type.
An open bundle type means that it contains non FIRRTL base types.
Definition at line 114 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAPath | ( | MlirType | type | ) |
Checks if this type is a property path type.
Definition at line 233 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsARef | ( | MlirType | type | ) |
bool firrtlTypeIsAReset | ( | MlirType | type | ) |
bool firrtlTypeIsASInt | ( | MlirType | type | ) |
Checks if this type is a signed integer type.
Definition at line 57 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAString | ( | MlirType | type | ) |
Checks if this type is a property string type.
Definition at line 219 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAUInt | ( | MlirType | type | ) |
Checks if this type is a unsigned integer type.
Definition at line 51 of file FIRRTL.cpp.
References unwrap().
bool firrtlTypeIsAVector | ( | MlirType | type | ) |
Checks if this type is a vector type.
Definition at line 91 of file FIRRTL.cpp.
References unwrap().
FIRRTLValueFlow firrtlValueFoldFlow | ( | MlirValue | value, |
FIRRTLValueFlow | flow | ||
) |
Computes the flow for a Value, value
, as determined by the FIRRTL specification.
This recursively walks backwards from value
to the declaration. The resulting flow is a combination of the declaration flow (output ports and instance inputs are sinks, registers and wires are duplex, anything else is a source) and the number of intermediary flips. An even number of flips will result in the same flow as the declaration. An odd number of flips will result in reversed flow being returned. The reverse of source is sink. The reverse of sink is source. The reverse of duplex is duplex. The flow
parameter sets the initial flow. A user should normally not have to change this from its default of Flow::Source
.
Definition at line 398 of file FIRRTL.cpp.
References circt::firrtl::Duplex, FIRRTL_VALUE_FLOW_DUPLEX, FIRRTL_VALUE_FLOW_NONE, FIRRTL_VALUE_FLOW_SINK, FIRRTL_VALUE_FLOW_SOURCE, circt::firrtl::foldFlow(), circt::firrtl::None, circt::firrtl::Sink, circt::firrtl::Source, and unwrap().
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION | ( | FIRRTL | , |
firrtl | , | ||
circt::firrtl::FIRRTLDialect | |||
) |
Definition at line 33 of file FIRRTL.cpp.
References circt::firrtl::isConst(), and unwrap().