17#include "mlir/IR/DialectImplementation.h"
18#include "llvm/ADT/StringExtras.h"
19#include "llvm/ADT/StringSwitch.h"
20#include "llvm/ADT/TypeSwitch.h"
25using mlir::OptionalParseResult;
26using mlir::TypeStorageAllocator;
33#define GET_TYPEDEF_CLASSES
34#include "circt/Dialect/FIRRTL/FIRRTLTypes.cpp.inc"
49 auto printWidthQualifier = [&](std::optional<int32_t> width) {
51 os <<
'<' << *width <<
'>';
53 bool anyFailed =
false;
54 TypeSwitch<Type>(type)
55 .Case<ClockType>([&](
auto) { os <<
"clock"; })
56 .Case<ResetType>([&](
auto) { os <<
"reset"; })
57 .Case<AsyncResetType>([&](
auto) { os <<
"asyncreset"; })
58 .Case<SIntType>([&](
auto sIntType) {
60 printWidthQualifier(sIntType.getWidth());
62 .Case<UIntType>([&](
auto uIntType) {
64 printWidthQualifier(uIntType.getWidth());
66 .Case<AnalogType>([&](
auto analogType) {
68 printWidthQualifier(analogType.getWidth());
70 .Case<BundleType, OpenBundleType>([&](
auto bundleType) {
74 llvm::interleaveComma(bundleType, os, [&](
auto element) {
75 StringRef fieldName = element.name.getValue();
76 bool isLiteralIdentifier =
77 !fieldName.empty() && llvm::isDigit(fieldName.front());
78 if (isLiteralIdentifier)
80 os << element.name.getValue();
81 if (isLiteralIdentifier)
90 .Case<FEnumType>([&](
auto fenumType) {
92 std::optional<APInt> previous;
93 llvm::interleaveComma(
94 fenumType, os, [&](FEnumType::EnumElement element) {
96 os << element.name.getValue();
99 auto value = element.value.getValue();
104 if (value != previous) {
106 os.printAttributeWithoutType(element.value);
108 }
else if (!element.value.getValue().isZero()) {
110 os.printAttributeWithoutType(element.value);
115 bool skipType =
false;
116 if (
auto type = dyn_cast<UIntType>(element.type))
117 if (type.getWidth() == 0)
126 .Case<FVectorType, OpenVectorType>([&](
auto vectorType) {
131 os <<
", " << vectorType.getNumElements() <<
'>';
133 .Case<RefType>([&](RefType refType) {
134 if (refType.getForceable())
138 if (
auto layer = refType.getLayer())
142 .Case<LHSType>([&](LHSType lhstype) {
147 .Case<StringType>([&](
auto stringType) { os <<
"string"; })
148 .Case<FIntegerType>([&](
auto integerType) { os <<
"integer"; })
149 .Case<BoolType>([&](
auto boolType) { os <<
"bool"; })
150 .Case<DoubleType>([&](
auto doubleType) { os <<
"double"; })
151 .Case<ListType>([&](
auto listType) {
156 .Case([&](OptionType optionType) {
161 .Case<RegistryType>([&](
auto registryType) {
166 .Case<PathType>([&](
auto pathType) { os <<
"path"; })
167 .Case<BaseTypeAliasType>([&](BaseTypeAliasType alias) {
168 os <<
"alias<" << alias.getName().getValue() <<
", ";
172 .Case<ClassType>([&](ClassType type) {
174 type.printInterface(os);
177 .Case<AnyRefType>([&](AnyRefType type) { os <<
"anyref"; })
178 .Case<FStringType>([&](
auto) { os <<
"fstring"; })
179 .Case<DomainType>([&](DomainType type) {
181 os.printSymbolName(type.getName().getValue());
183 llvm::interleaveComma(type.getFields(), os, [&](Attribute attr) {
184 auto field = cast<DomainFieldAttr>(attr);
185 os << field.getName().getValue() <<
": ";
186 os.printType(field.getType());
191 .Default([&](
auto) { anyFailed =
true; });
203 assert(
false &&
"type to print unknown to FIRRTL dialect");
238 const char constPrefix[] =
"const.";
239 if (name.starts_with(constPrefix)) {
241 name = name.drop_front(std::size(constPrefix) - 1);
244 auto *
context = parser.getContext();
249 if (name ==
"asyncreset")
252 if (name ==
"sint" || name ==
"uint" || name ==
"analog") {
255 if (!parser.parseOptionalLess()) {
256 if (parser.parseInteger(width) || parser.parseGreater())
260 return parser.emitError(parser.getNameLoc(),
"unknown width"),
266 else if (name ==
"uint")
275 if (name ==
"bundle") {
276 SmallVector<BundleType::BundleElement, 4> elements;
278 auto parseBundleElement = [&]() -> ParseResult {
283 if (failed(parser.parseKeywordOrString(&nameStr)))
287 bool isFlip = succeeded(parser.parseOptionalKeyword(
"flip"));
291 elements.push_back({StringAttr::get(
context, name), isFlip, type});
295 if (parser.parseCommaSeparatedList(mlir::AsmParser::Delimiter::LessGreater,
299 result = parser.getChecked<BundleType>(
context, elements,
isConst);
302 if (name ==
"openbundle") {
303 SmallVector<OpenBundleType::BundleElement, 4> elements;
305 auto parseBundleElement = [&]() -> ParseResult {
310 if (failed(parser.parseKeywordOrString(&nameStr)))
314 bool isFlip = succeeded(parser.parseOptionalKeyword(
"flip"));
318 elements.push_back({StringAttr::get(
context, name), isFlip, type});
322 if (parser.parseCommaSeparatedList(mlir::AsmParser::Delimiter::LessGreater,
326 result = parser.getChecked<OpenBundleType>(
context, elements,
isConst);
330 if (name ==
"enum") {
331 SmallVector<StringAttr> names;
332 SmallVector<APInt> values;
333 SmallVector<FIRRTLBaseType> types;
334 auto parseEnumElement = [&]() -> ParseResult {
337 if (failed(parser.parseKeywordOrString(&nameStr)))
339 names.push_back(StringAttr::get(
context, nameStr));
345 if (succeeded(parser.parseOptionalEqual())) {
346 if (parser.parseInteger(value))
348 }
else if (values.empty()) {
354 auto &prev = values.back();
355 if (prev.isMaxValue())
356 value = prev.zext(prev.getBitWidth() + 1);
361 values.push_back(std::move(value));
365 if (succeeded(parser.parseOptionalColon())) {
369 type = UIntType::get(parser.getContext(), 0);
371 types.push_back(type);
376 if (parser.parseCommaSeparatedList(mlir::AsmParser::Delimiter::LessGreater,
381 unsigned bitwidth = 0;
382 for (
auto &value : values)
383 bitwidth = std::max(bitwidth, value.getActiveBits());
384 auto tagType = IntegerType::get(
context, bitwidth, IntegerType::Unsigned);
386 SmallVector<FEnumType::EnumElement, 4> elements;
387 for (
auto [name, value, type] : llvm::zip(names, values, types)) {
388 auto tagValue = value.zextOrTrunc(bitwidth);
389 elements.push_back({name, IntegerAttr::get(tagType, tagValue), type});
392 if (failed(FEnumType::verify(
393 [&]() {
return parser.emitError(parser.getNameLoc()); }, elements,
397 result = parser.getChecked<FEnumType>(
context, elements,
isConst);
401 if (name ==
"vector") {
406 parser.parseComma() || parser.parseInteger(width) ||
407 parser.parseGreater())
412 if (name ==
"openvector") {
417 parser.parseComma() || parser.parseInteger(width) ||
418 parser.parseGreater())
427 if (name ==
"ref" || name ==
"probe") {
434 if (parser.parseOptionalComma().succeeded())
435 if (parser.parseOptionalAttribute(layer).value())
436 return parser.emitError(parser.getNameLoc(),
437 "expected symbol reference");
438 if (parser.parseGreater())
441 if (failed(RefType::verify(
442 [&]() {
return parser.emitError(parser.getNameLoc()); }, type,
446 return result = RefType::get(type,
false, layer),
success();
451 parser.parseGreater())
453 if (!isa<FIRRTLBaseType>(type))
454 return parser.emitError(parser.getNameLoc(),
"expected base type");
455 result = parser.getChecked<LHSType>(
context, cast<FIRRTLBaseType>(type));
458 if (name ==
"rwprobe") {
463 if (parser.parseOptionalComma().succeeded())
464 if (parser.parseOptionalAttribute(layer).value())
465 return parser.emitError(parser.getNameLoc(),
466 "expected symbol reference");
467 if (parser.parseGreater())
470 if (failed(RefType::verify(
471 [&]() {
return parser.emitError(parser.getNameLoc()); }, type,
true,
475 return result = RefType::get(type,
true, layer),
success();
477 if (name ==
"class") {
479 return parser.emitError(parser.getNameLoc(),
"classes cannot be const");
481 if (parser.parseLess() || ClassType::parseInterface(parser, classType) ||
482 parser.parseGreater())
487 if (name ==
"anyref") {
489 return parser.emitError(parser.getNameLoc(),
"any refs cannot be const");
491 result = AnyRefType::get(parser.getContext());
494 if (name ==
"string") {
496 parser.emitError(parser.getNameLoc(),
"strings cannot be const");
499 result = StringType::get(parser.getContext());
502 if (name ==
"integer") {
504 parser.emitError(parser.getNameLoc(),
"bigints cannot be const");
507 result = FIntegerType::get(parser.getContext());
510 if (name ==
"bool") {
512 parser.emitError(parser.getNameLoc(),
"bools cannot be const");
515 result = BoolType::get(parser.getContext());
518 if (name ==
"double") {
520 parser.emitError(parser.getNameLoc(),
"doubles cannot be const");
523 result = DoubleType::get(parser.getContext());
526 if (name ==
"list") {
528 parser.emitError(parser.getNameLoc(),
"lists cannot be const");
533 parser.parseGreater())
540 if (name ==
"option") {
542 return parser.emitError(parser.getNameLoc(),
"options cannot be const");
545 parser.parseGreater())
550 if (name ==
"registry") {
552 parser.emitError(parser.getNameLoc(),
"registries cannot be const");
557 parser.parseGreater())
564 if (name ==
"path") {
566 parser.emitError(parser.getNameLoc(),
"path cannot be const");
569 result = PathType::get(parser.getContext());
572 if (name ==
"alias") {
575 if (parser.parseLess() || parser.parseKeyword(&name) ||
577 parser.parseGreater())
581 BaseTypeAliasType::get(StringAttr::get(
context, name), type),
584 if (name ==
"fstring") {
587 if (name ==
"domain") {
590 DomainType domainType;
591 if (parser.parseLess() || DomainType::parseInterface(parser, domainType) ||
592 parser.parseGreater())
607static ParseResult
parseType(Type &result, StringRef name, AsmParser &parser) {
610 if (parseResult.has_value())
611 return parseResult.value();
614 parser.emitError(parser.getNameLoc(),
"unknown FIRRTL dialect type: \"")
626 if (failed(
parseType(type, name, parser)))
631 parser.emitError(parser.getNameLoc(),
"unknown FIRRTL type: \"")
645 parser.emitError(parser.getNameLoc(),
"expected base type, found ") << type;
658 parser.emitError(parser.getNameLoc(),
"expected property type, found ")
671 if (parser.parseKeyword(&name))
681 if (parser.parseKeyword(&name))
691 if (parser.parseKeyword(&name))
702void FIRRTLDialect::printType(Type type, DialectAsmPrinter &os)
const {
707Type FIRRTLDialect::parseType(DialectAsmParser &parser)
const {
710 if (parser.parseKeyword(&name) ||
::parseType(result, name, parser))
754 return TypeSwitch<FIRRTLType, bool>(*
this)
755 .Case<ClockType, ResetType, AsyncResetType, SIntType, UIntType,
756 AnalogType>([](Type) {
return true; })
757 .Case<BundleType, FVectorType, FEnumType, OpenBundleType, OpenVectorType>(
758 [](Type) {
return false; })
759 .Case<BaseTypeAliasType>([](BaseTypeAliasType alias) {
760 return alias.getAnonymousType().isGround();
763 .Case<PropertyType, RefType>([](Type) {
return false; })
765 llvm_unreachable(
"unknown FIRRTL type");
771 return TypeSwitch<FIRRTLType, bool>(*
this)
772 .Case<FIRRTLBaseType, OpenBundleType, OpenVectorType>(
773 [](
auto type) {
return type.isConst(); })
780 return TypeSwitch<FIRRTLType, RecursiveTypeProperties>(*
this)
781 .Case<ClockType, ResetType, AsyncResetType>([](
FIRRTLBaseType type) {
790 .Case<SIntType, UIntType>([](
auto type) {
792 true,
false,
false, type.isConst(),
false, !type.hasWidth(),
false};
794 .Case<AnalogType>([](
auto type) {
795 return RecursiveTypeProperties{
796 true,
false,
true, type.isConst(),
false, !type.hasWidth(),
false};
798 .Case<BundleType, FVectorType, FEnumType, OpenBundleType, OpenVectorType,
799 RefType, BaseTypeAliasType>(
800 [](
auto type) {
return type.getRecursiveTypeProperties(); })
801 .Case<PropertyType>([](
auto type) {
802 return RecursiveTypeProperties{
true,
false,
false,
false,
803 false,
false,
false};
806 [](
auto type) {
return type.getType().getRecursiveTypeProperties(); })
807 .Case<FStringType>([](
auto type) {
808 return RecursiveTypeProperties{
true,
false,
false,
false,
809 false,
false,
false};
811 .Case<DomainType>([](
auto type) {
812 return RecursiveTypeProperties{
true,
false,
false,
false,
813 false,
false,
false};
816 llvm_unreachable(
"unknown FIRRTL type");
817 return RecursiveTypeProperties{};
823 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
824 .Case<ClockType, ResetType, AsyncResetType, SIntType, UIntType,
825 AnalogType>([&](Type) {
return *
this; })
826 .Case<BundleType, FVectorType, FEnumType, BaseTypeAliasType>(
827 [](
auto type) {
return type.getAnonymousType(); })
829 llvm_unreachable(
"unknown FIRRTL type");
836 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
837 .Case<ClockType, ResetType, AsyncResetType, SIntType, UIntType,
838 AnalogType, FEnumType>([&](Type) {
return *
this; })
839 .Case<BundleType, FVectorType, FEnumType, BaseTypeAliasType>(
840 [](
auto type) {
return type.getPassiveType(); })
842 llvm_unreachable(
"unknown FIRRTL type");
849 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
850 .Case<ClockType, ResetType, AsyncResetType, AnalogType, SIntType,
851 UIntType, BundleType, FVectorType, FEnumType, BaseTypeAliasType>(
852 [&](
auto type) {
return type.getConstType(
isConst); })
854 llvm_unreachable(
"unknown FIRRTL type");
861 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
862 .Case<ClockType, ResetType, AsyncResetType, AnalogType, SIntType,
863 UIntType>([&](
auto type) {
return type.getConstType(
false); })
864 .Case<BundleType, FVectorType, FEnumType, BaseTypeAliasType>(
865 [&](
auto type) {
return type.getAllConstDroppedType(); })
867 llvm_unreachable(
"unknown FIRRTL type");
875 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
876 .Case<ClockType, ResetType, AsyncResetType, SIntType, UIntType,
877 AnalogType, FEnumType>([&](Type) {
878 return UIntType::get(this->getContext(), 1, this->
isConst());
880 .Case<BundleType>([&](BundleType bundleType) {
881 SmallVector<BundleType::BundleElement, 4> newElements;
882 newElements.reserve(bundleType.getElements().size());
883 for (
auto elt : bundleType)
884 newElements.push_back(
885 {elt.name,
false , elt.type.getMaskType()});
886 return BundleType::get(this->getContext(), newElements,
887 bundleType.isConst());
889 .Case<FVectorType>([](FVectorType vectorType) {
890 return FVectorType::get(vectorType.getElementType().getMaskType(),
891 vectorType.getNumElements(),
892 vectorType.isConst());
894 .Case<BaseTypeAliasType>([](BaseTypeAliasType base) {
895 return base.getModifiedType(base.getInnerType().getMaskType());
898 llvm_unreachable(
"unknown FIRRTL type");
906 return TypeSwitch<FIRRTLBaseType, FIRRTLBaseType>(*
this)
907 .Case<ClockType, ResetType, AsyncResetType>([](
auto a) {
return a; })
908 .Case<UIntType, SIntType, AnalogType>(
909 [&](
auto a) {
return a.get(this->getContext(), -1, a.isConst()); })
910 .Case<BundleType>([&](
auto a) {
911 SmallVector<BundleType::BundleElement, 4> newElements;
912 newElements.reserve(a.getElements().size());
914 newElements.push_back(
915 {elt.name, elt.isFlip, elt.type.getWidthlessType()});
916 return BundleType::get(this->getContext(), newElements, a.isConst());
918 .Case<FVectorType>([](
auto a) {
919 return FVectorType::get(a.getElementType().getWidthlessType(),
920 a.getNumElements(), a.isConst());
922 .Case<FEnumType>([&](FEnumType a) {
923 SmallVector<FEnumType::EnumElement, 4> newElements;
924 newElements.reserve(a.getNumElements());
926 newElements.push_back(
927 {elt.name, elt.value, elt.type.getWidthlessType()});
928 return FEnumType::get(this->getContext(), newElements, a.isConst());
930 .Case<BaseTypeAliasType>([](BaseTypeAliasType type) {
931 return type.getModifiedType(type.getInnerType().getWidthlessType());
934 llvm_unreachable(
"unknown FIRRTL type");
944 return TypeSwitch<FIRRTLBaseType, int32_t>(*
this)
945 .Case<ClockType, ResetType, AsyncResetType>([](Type) {
return 1; })
946 .Case<SIntType, UIntType>(
949 [](AnalogType analogType) {
return analogType.getWidthOrSentinel(); })
950 .Case<FEnumType>([&](FEnumType fenum) {
return fenum.getBitWidth(); })
951 .Case<BundleType, FVectorType>([](Type) {
return -2; })
952 .Case<BaseTypeAliasType>([](BaseTypeAliasType type) {
954 return type.getAnonymousType().getBitWidthOrSentinel();
957 llvm_unreachable(
"unknown FIRRTL type");
966 return TypeSwitch<FIRRTLType, bool>(*
this)
967 .Case<ResetType, AsyncResetType>([](Type) {
return true; })
969 [](UIntType a) {
return !a.hasWidth() || a.getWidth() == 1; })
970 .Case<BaseTypeAliasType>(
971 [](
auto type) {
return type.getInnerType().isResetType(); })
972 .Default([](Type) {
return false; });
976 return TypeSwitch<Type, bool>(type)
978 [](
auto base) {
return base.isConst(); })
983 return TypeSwitch<Type, bool>(type)
985 [](
auto base) {
return base.containsConst(); })
992 .
Case<BundleType>([&](
auto bundle) {
993 for (
size_t i = 0, e = bundle.getNumElements(); i < e; ++i) {
994 auto elt = bundle.getElement(i);
998 return bundle.getNumElements() == 0;
1000 .Case<FVectorType>([&](
auto vector) {
1001 if (vector.getNumElements() == 0)
1005 .Case<FIRRTLBaseType>([](
auto groundType) {
1008 .Case<RefType>([](
auto ref) {
return hasZeroBitWidth(ref.getType()); })
1009 .Default([](
auto) {
return false; });
1019 BundleType::BundleElement srcElement,
1020 bool destOuterTypeIsConst,
1021 bool srcOuterTypeIsConst,
1022 bool requiresSameWidth) {
1023 if (destElement.name != srcElement.name)
1025 if (destElement.isFlip != srcElement.isFlip)
1028 if (destElement.isFlip) {
1029 std::swap(destElement, srcElement);
1030 std::swap(destOuterTypeIsConst, srcOuterTypeIsConst);
1034 destOuterTypeIsConst, srcOuterTypeIsConst,
1043 bool destOuterTypeIsConst,
1044 bool srcOuterTypeIsConst,
1045 bool requireSameWidths) {
1050 if (!destType || !srcType)
1051 return destFType == srcFType;
1053 bool srcIsConst = srcOuterTypeIsConst || srcFType.
isConst();
1054 bool destIsConst = destOuterTypeIsConst || destFType.
isConst();
1059 if (destVectorType && srcVectorType)
1060 return destVectorType.getNumElements() == srcVectorType.getNumElements() &&
1062 srcVectorType.getElementType(), destIsConst,
1063 srcIsConst, requireSameWidths);
1069 if (destBundleType && srcBundleType) {
1070 auto destElements = destBundleType.getElements();
1071 auto srcElements = srcBundleType.getElements();
1072 size_t numDestElements = destElements.size();
1073 if (numDestElements != srcElements.size())
1076 for (
size_t i = 0; i < numDestElements; ++i) {
1077 auto destElement = destElements[i];
1078 auto srcElement = srcElements[i];
1080 srcIsConst, requireSameWidths))
1091 if (dstEnumType && srcEnumType) {
1092 if (dstEnumType.getNumElements() != srcEnumType.getNumElements())
1095 for (
const auto &[dst, src] : llvm::zip(dstEnumType, srcEnumType)) {
1097 if (dst.name != src.name)
1109 if (destIsConst && !srcIsConst)
1114 return srcType.isResetType();
1118 return destType.isResetType();
1122 if (!requireSameWidths || destType.getBitWidthOrSentinel() == -1)
1123 srcType = srcType.getWidthlessType();
1124 if (!requireSameWidths || srcType.getBitWidthOrSentinel() == -1)
1125 destType = destType.getWidthlessType();
1128 return destType.getConstType(
false) == srcType.getConstType(
false);
1133 bool srcOuterTypeIsConst) {
1135 if (destFType == srcFType)
1142 if (!destType || !srcType)
1146 if (!destType.isPassive() || !srcType.isPassive())
1149 bool srcIsConst = srcType.isConst() || srcOuterTypeIsConst;
1152 if (destType.isConst() && !srcIsConst)
1159 if (destVectorType && srcVectorType)
1160 return destVectorType.getNumElements() == srcVectorType.getNumElements() &&
1162 srcVectorType.getElementType(), srcIsConst);
1163 if (destVectorType != srcVectorType)
1170 if (destBundleType && srcBundleType) {
1171 auto destElements = destBundleType.getElements();
1172 auto srcElements = srcBundleType.getElements();
1173 size_t numDestElements = destElements.size();
1174 if (numDestElements != srcElements.size())
1177 return llvm::all_of_zip(
1178 destElements, srcElements,
1179 [&](
const auto &destElement,
const auto &srcElement) {
1180 return destElement.name == srcElement.name &&
1185 if (destBundleType != srcBundleType)
1190 return destType == srcType.getConstType(destType.isConst());
1196 if (!dstRefType || !srcRefType)
1198 if (dstRefType == srcRefType)
1200 if (dstRefType.getForceable() && !srcRefType.getForceable())
1212 bool srcOuterTypeIsConst) ->
bool {
1218 assert(dest.isPassive() && src.isPassive());
1220 bool srcIsConst = src.isConst() || srcOuterTypeIsConst;
1223 if (dest.isConst() && !srcIsConst)
1231 return srcVectorType &&
1232 destVectorType.getNumElements() ==
1233 srcVectorType.getNumElements() &&
1234 f(f, destVectorType.getElementType(),
1235 srcVectorType.getElementType(), srcIsConst);
1243 auto destElements = destBundleType.getElements();
1244 auto srcElements = srcBundleType.getElements();
1246 return destElements.size() == srcElements.size() &&
1248 destElements, srcElements,
1249 [&](
const auto &destElement,
const auto &srcElement) {
1250 return destElement.name == srcElement.name &&
1251 f(f, destElement.type, srcElement.type, srcIsConst);
1259 auto destElements = destEnumType.getElements();
1260 auto srcElements = srcEnumType.getElements();
1262 return destElements.size() == srcElements.size() &&
1264 destElements, srcElements,
1265 [&](
const auto &destElement,
const auto &srcElement) {
1266 return destElement.name == srcElement.name &&
1267 f(f, destElement.type, srcElement.type, srcIsConst);
1273 return src.isResetType();
1277 src = src.getConstType(dest.isConst());
1280 if (dest.getBitWidthOrSentinel() == -1)
1281 src = src.getWidthlessType();
1286 return recurse(recurse, dstRefType.getType(), srcRefType.getType(),
false);
1293 return TypeSwitch<FIRRTLBaseType, bool>(dstType)
1294 .Case<BundleType>([&](
auto dstBundle) {
1296 for (
size_t i = 0, n = dstBundle.getNumElements(); i < n; ++i) {
1297 auto srcElem = srcBundle.getElement(i);
1298 auto dstElem = dstBundle.getElement(i);
1299 if (dstElem.isFlip) {
1309 .Case<FVectorType>([&](
auto vector) {
1313 .Default([&](
auto dstGround) {
1316 return destWidth <= -1 || srcWidth <= -1 || destWidth >= srcWidth;
1334 srcRefType.getType());
1346 return llvm::TypeSwitch<Type, bool>(type)
1348 return !type.containsReference() &&
1349 (!type.isPassive() || type.containsAnalog());
1357 if (isa<FIRRTLBaseType>(type))
1360 if (
auto bundle = dyn_cast<OpenBundleType>(type))
1361 return llvm::any_of(bundle,
1363 if (
auto vector = dyn_cast<OpenVectorType>(type))
1376 int32_t widthOrSentinel,
bool isConst) {
1384 return sintType.getWidthOrSentinel();
1386 return uintType.getWidthOrSentinel();
1397 using KeyTy = std::tuple<int32_t, char>;
1423SIntType SIntType::get(MLIRContext *
context) {
return get(
context, -1,
false); }
1425SIntType SIntType::get(MLIRContext *
context, std::optional<int32_t> width,
1430LogicalResult SIntType::verify(function_ref<InFlightDiagnostic()> emitError,
1431 int32_t widthOrSentinel,
bool isConst) {
1432 if (widthOrSentinel < -1)
1433 return emitError() <<
"invalid width";
1437int32_t SIntType::getWidthOrSentinel()
const {
return getImpl()->width; }
1439SIntType SIntType::getConstType(
bool isConst)
const {
1442 return get(getContext(), getWidthOrSentinel(),
isConst);
1456LogicalResult UIntType::verify(function_ref<InFlightDiagnostic()> emitError,
1457 int32_t widthOrSentinel,
bool isConst) {
1458 if (widthOrSentinel < -1)
1459 return emitError() <<
"invalid width";
1463int32_t UIntType::getWidthOrSentinel()
const {
return getImpl()->width; }
1465UIntType UIntType::getConstType(
bool isConst)
const {
1468 return get(getContext(), getWidthOrSentinel(),
isConst);
1477 using KeyTy = std::tuple<ArrayRef<BundleType::BundleElement>,
char>;
1482 props{true, false, false,
isConst, false, false, false} {
1483 uint64_t fieldID = 0;
1486 auto type = element.type;
1487 auto eltInfo = type.getRecursiveTypeProperties();
1488 props.isPassive &= eltInfo.isPassive & !element.isFlip;
1489 props.containsAnalog |= eltInfo.containsAnalog;
1490 props.containsReference |= eltInfo.containsReference;
1491 props.containsConst |= eltInfo.containsConst;
1492 props.containsTypeAlias |= eltInfo.containsTypeAlias;
1493 props.hasUninferredWidth |= eltInfo.hasUninferredWidth;
1494 props.hasUninferredReset |= eltInfo.hasUninferredReset;
1514 std::get<0>(key),
static_cast<bool>(std::get<1>(key)));
1528BundleType BundleType::get(MLIRContext *
context,
1529 ArrayRef<BundleElement> elements,
bool isConst) {
1533auto BundleType::getElements() const -> ArrayRef<BundleElement> {
1534 return getImpl()->elements;
1539 return getImpl()->props;
1544 auto *
impl = getImpl();
1547 if (
impl->passiveType)
1548 return impl->passiveType;
1551 if (
impl->props.isPassive) {
1552 impl->passiveType = *
this;
1557 SmallVector<BundleType::BundleElement, 16> newElements;
1558 newElements.reserve(
impl->elements.size());
1559 for (
auto &elt :
impl->elements) {
1560 newElements.push_back({elt.name,
false, elt.type.getPassiveType()});
1563 auto passiveType = BundleType::get(getContext(), newElements,
isConst());
1564 impl->passiveType = passiveType;
1568BundleType BundleType::getConstType(
bool isConst)
const {
1571 return get(getContext(), getElements(),
isConst);
1574BundleType BundleType::getAllConstDroppedType() {
1578 SmallVector<BundleElement> constDroppedElements(
1579 llvm::map_range(getElements(), [](BundleElement element) {
1580 element.type = element.type.getAllConstDroppedType();
1583 return get(getContext(), constDroppedElements,
false);
1586std::optional<unsigned> BundleType::getElementIndex(StringAttr name) {
1587 for (
const auto &it : llvm::enumerate(getElements())) {
1588 auto element = it.value();
1589 if (element.name == name) {
1590 return unsigned(it.index());
1593 return std::nullopt;
1596std::optional<unsigned> BundleType::getElementIndex(StringRef name) {
1597 for (
const auto &it : llvm::enumerate(getElements())) {
1598 auto element = it.value();
1599 if (element.name.getValue() == name) {
1600 return unsigned(it.index());
1603 return std::nullopt;
1606StringAttr BundleType::getElementNameAttr(
size_t index) {
1607 assert(index < getNumElements() &&
1608 "index must be less than number of fields in bundle");
1609 return getElements()[index].name;
1612StringRef BundleType::getElementName(
size_t index) {
1613 return getElementNameAttr(index).getValue();
1616std::optional<BundleType::BundleElement>
1617BundleType::getElement(StringAttr name) {
1618 if (
auto maybeIndex = getElementIndex(name))
1619 return getElements()[*maybeIndex];
1620 return std::nullopt;
1623std::optional<BundleType::BundleElement>
1624BundleType::getElement(StringRef name) {
1625 if (
auto maybeIndex = getElementIndex(name))
1626 return getElements()[*maybeIndex];
1627 return std::nullopt;
1631BundleType::BundleElement BundleType::getElement(
size_t index) {
1632 assert(index < getNumElements() &&
1633 "index must be less than number of fields in bundle");
1634 return getElements()[index];
1638 auto element = getElement(name);
1643 auto element = getElement(name);
1648 assert(index < getNumElements() &&
1649 "index must be less than number of fields in bundle");
1650 return getElements()[index].type;
1653uint64_t BundleType::getFieldID(uint64_t index)
const {
1654 return getImpl()->fieldIDs[index];
1657uint64_t BundleType::getIndexForFieldID(uint64_t fieldID)
const {
1658 assert(!getElements().
empty() &&
"Bundle must have >0 fields");
1659 auto fieldIDs = getImpl()->fieldIDs;
1660 auto *it = std::prev(llvm::upper_bound(fieldIDs, fieldID));
1661 return std::distance(fieldIDs.begin(), it);
1664std::pair<uint64_t, uint64_t>
1665BundleType::getIndexAndSubfieldID(uint64_t fieldID)
const {
1668 return {index, fieldID - elementFieldID};
1671std::pair<Type, uint64_t>
1672BundleType::getSubTypeByFieldID(uint64_t fieldID)
const {
1676 auto subfieldType = getElementType(subfieldIndex);
1677 auto subfieldID = fieldID -
getFieldID(subfieldIndex);
1678 return {subfieldType, subfieldID};
1681uint64_t BundleType::getMaxFieldID()
const {
return getImpl()->maxFieldID; }
1683std::pair<uint64_t, bool>
1684BundleType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
1686 auto rangeEnd = index + 1 >= getNumElements() ?
getMaxFieldID()
1688 return std::make_pair(fieldID - childRoot,
1689 fieldID >= childRoot && fieldID <= rangeEnd);
1692bool BundleType::isConst()
const {
return getImpl()->isConst; }
1694BundleType::ElementType
1695BundleType::getElementTypePreservingConst(
size_t index) {
1696 auto type = getElementType(index);
1697 return type.getConstType(type.isConst() ||
isConst());
1702 auto *
impl = getImpl();
1705 if (
impl->anonymousType)
1706 return impl->anonymousType;
1709 if (!
impl->props.containsTypeAlias) {
1710 impl->anonymousType = *
this;
1716 SmallVector<BundleType::BundleElement, 16> newElements;
1717 newElements.reserve(
impl->elements.size());
1718 for (
auto &elt :
impl->elements)
1719 newElements.push_back({elt.name, elt.isFlip, elt.type.getAnonymousType()});
1721 auto anonymousType = BundleType::get(getContext(), newElements,
isConst());
1722 impl->anonymousType = anonymousType;
1723 return anonymousType;
1726LogicalResult BundleType::verify(function_ref<InFlightDiagnostic()> emitErrorFn,
1727 ArrayRef<BundleElement> elements,
1729 SmallPtrSet<StringAttr, 4> nameSet;
1730 for (
auto &element : elements) {
1731 if (!nameSet.insert(element.name).second)
1732 return emitErrorFn() <<
"duplicate field name " << element.name
1744 using KeyTy = std::tuple<ArrayRef<OpenBundleType::BundleElement>,
char>;
1749 props{true, false, false,
isConst, false, false, false},
1751 uint64_t fieldID = 0;
1754 auto type = element.type;
1755 auto eltInfo = type.getRecursiveTypeProperties();
1756 props.isPassive &= eltInfo.isPassive & !element.isFlip;
1757 props.containsAnalog |= eltInfo.containsAnalog;
1758 props.containsReference |= eltInfo.containsReference;
1759 props.containsConst |= eltInfo.containsConst;
1760 props.containsTypeAlias |= eltInfo.containsTypeAlias;
1761 props.hasUninferredWidth |= eltInfo.hasUninferredWidth;
1762 props.hasUninferredReset |= eltInfo.hasUninferredReset;
1784 static_cast<bool>(std::get<1>(key)));
1787 SmallVector<OpenBundleType::BundleElement, 4>
elements;
1799OpenBundleType OpenBundleType::get(MLIRContext *
context,
1800 ArrayRef<BundleElement> elements,
1806OpenBundleType::getChecked(function_ref<InFlightDiagnostic()> emitErrorFn,
1808 ArrayRef<BundleElement> elements,
bool isConst) {
1809 if (failed(verify(emitErrorFn, elements,
isConst)))
1814auto OpenBundleType::getElements() const -> ArrayRef<BundleElement> {
1815 return getImpl()->elements;
1820 return getImpl()->props;
1823OpenBundleType OpenBundleType::getConstType(
bool isConst)
const {
1826 return get(getContext(), getElements(),
isConst);
1829std::optional<unsigned> OpenBundleType::getElementIndex(StringAttr name) {
1830 for (
const auto &it : llvm::enumerate(getElements())) {
1831 auto element = it.value();
1832 if (element.name == name) {
1833 return unsigned(it.index());
1836 return std::nullopt;
1839std::optional<unsigned> OpenBundleType::getElementIndex(StringRef name) {
1840 for (
const auto &it : llvm::enumerate(getElements())) {
1841 auto element = it.value();
1842 if (element.name.getValue() == name) {
1843 return unsigned(it.index());
1846 return std::nullopt;
1849StringAttr OpenBundleType::getElementNameAttr(
size_t index) {
1850 assert(index < getNumElements() &&
1851 "index must be less than number of fields in bundle");
1852 return getElements()[index].name;
1855StringRef OpenBundleType::getElementName(
size_t index) {
1856 return getElementNameAttr(index).getValue();
1859std::optional<OpenBundleType::BundleElement>
1860OpenBundleType::getElement(StringAttr name) {
1861 if (
auto maybeIndex = getElementIndex(name))
1862 return getElements()[*maybeIndex];
1863 return std::nullopt;
1866std::optional<OpenBundleType::BundleElement>
1867OpenBundleType::getElement(StringRef name) {
1868 if (
auto maybeIndex = getElementIndex(name))
1869 return getElements()[*maybeIndex];
1870 return std::nullopt;
1874OpenBundleType::BundleElement OpenBundleType::getElement(
size_t index) {
1875 assert(index < getNumElements() &&
1876 "index must be less than number of fields in bundle");
1877 return getElements()[index];
1880OpenBundleType::ElementType OpenBundleType::getElementType(StringAttr name) {
1881 auto element = getElement(name);
1885OpenBundleType::ElementType OpenBundleType::getElementType(StringRef name) {
1886 auto element = getElement(name);
1890OpenBundleType::ElementType OpenBundleType::getElementType(
size_t index)
const {
1891 assert(index < getNumElements() &&
1892 "index must be less than number of fields in bundle");
1893 return getElements()[index].type;
1896uint64_t OpenBundleType::getFieldID(uint64_t index)
const {
1897 return getImpl()->fieldIDs[index];
1900uint64_t OpenBundleType::getIndexForFieldID(uint64_t fieldID)
const {
1901 assert(!getElements().
empty() &&
"Bundle must have >0 fields");
1902 auto fieldIDs = getImpl()->fieldIDs;
1903 auto *it = std::prev(llvm::upper_bound(fieldIDs, fieldID));
1904 return std::distance(fieldIDs.begin(), it);
1907std::pair<uint64_t, uint64_t>
1908OpenBundleType::getIndexAndSubfieldID(uint64_t fieldID)
const {
1911 return {index, fieldID - elementFieldID};
1914std::pair<Type, uint64_t>
1915OpenBundleType::getSubTypeByFieldID(uint64_t fieldID)
const {
1919 auto subfieldType = getElementType(subfieldIndex);
1920 auto subfieldID = fieldID -
getFieldID(subfieldIndex);
1921 return {subfieldType, subfieldID};
1924uint64_t OpenBundleType::getMaxFieldID()
const {
return getImpl()->maxFieldID; }
1926std::pair<uint64_t, bool>
1927OpenBundleType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
1929 auto rangeEnd = index + 1 >= getNumElements() ?
getMaxFieldID()
1931 return std::make_pair(fieldID - childRoot,
1932 fieldID >= childRoot && fieldID <= rangeEnd);
1935bool OpenBundleType::isConst()
const {
return getImpl()->isConst; }
1937OpenBundleType::ElementType
1938OpenBundleType::getElementTypePreservingConst(
size_t index) {
1939 auto type = getElementType(index);
1941 return TypeSwitch<FIRRTLType, ElementType>(type)
1942 .Case<
FIRRTLBaseType, OpenBundleType, OpenVectorType>([&](
auto type) {
1943 return type.getConstType(type.isConst() ||
isConst());
1949OpenBundleType::verify(function_ref<InFlightDiagnostic()> emitErrorFn,
1950 ArrayRef<BundleElement> elements,
bool isConst) {
1951 SmallPtrSet<StringAttr, 4> nameSet;
1952 for (
auto &element : elements) {
1953 if (!nameSet.insert(element.name).second)
1954 return emitErrorFn() <<
"duplicate field name " << element.name
1955 <<
" in openbundle";
1957 return emitErrorFn()
1958 <<
"'const' bundle cannot have references, but element "
1959 << element.name <<
" has type " << element.type;
1961 return emitErrorFn() <<
"bundle element " << element.name
1962 <<
" cannot have a left-hand side type";
1964 return emitErrorFn() <<
"bundle element " << element.name
1965 <<
" cannot have a domain type";
1977 using KeyTy = std::tuple<FIRRTLBaseType, size_t, char>;
1995 static_cast<bool>(std::get<2>(key)));
2014 return getImpl()->elementType;
2017size_t FVectorType::getNumElements()
const {
return getImpl()->numElements; }
2021 return getImpl()->props;
2026 auto *
impl = getImpl();
2029 if (
impl->passiveType)
2030 return impl->passiveType;
2033 if (
impl->elementType.getRecursiveTypeProperties().isPassive)
2034 return impl->passiveType = *
this;
2037 auto passiveType = FVectorType::get(getElementType().
getPassiveType(),
2039 impl->passiveType = passiveType;
2043FVectorType FVectorType::getConstType(
bool isConst)
const {
2046 return get(getElementType(), getNumElements(),
isConst);
2049FVectorType FVectorType::getAllConstDroppedType() {
2052 return get(getElementType().getAllConstDroppedType(), getNumElements(),
2058 auto *
impl = getImpl();
2060 if (
impl->anonymousType)
2061 return impl->anonymousType;
2064 if (!
impl->props.containsTypeAlias)
2065 return impl->anonymousType = *
this;
2068 auto anonymousType = FVectorType::get(getElementType().getAnonymousType(),
2070 impl->anonymousType = anonymousType;
2071 return anonymousType;
2074uint64_t FVectorType::getFieldID(uint64_t index)
const {
2078uint64_t FVectorType::getIndexForFieldID(uint64_t fieldID)
const {
2079 assert(fieldID &&
"fieldID must be at least 1");
2084std::pair<uint64_t, uint64_t>
2085FVectorType::getIndexAndSubfieldID(uint64_t fieldID)
const {
2088 return {index, fieldID - elementFieldID};
2091std::pair<Type, uint64_t>
2092FVectorType::getSubTypeByFieldID(uint64_t fieldID)
const {
2098uint64_t FVectorType::getMaxFieldID()
const {
2099 return getNumElements() *
2103std::pair<uint64_t, bool>
2104FVectorType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
2108 return std::make_pair(fieldID - childRoot,
2109 fieldID >= childRoot && fieldID <= rangeEnd);
2112bool FVectorType::isConst()
const {
return getImpl()->isConst; }
2114FVectorType::ElementType FVectorType::getElementTypePreservingConst() {
2115 auto type = getElementType();
2116 return type.getConstType(type.isConst() ||
isConst());
2124 using KeyTy = std::tuple<FIRRTLType, size_t, char>;
2142 static_cast<bool>(std::get<2>(key)));
2158OpenVectorType::getChecked(function_ref<InFlightDiagnostic()> emitErrorFn,
2166FIRRTLType OpenVectorType::getElementType()
const {
2167 return getImpl()->elementType;
2170size_t OpenVectorType::getNumElements()
const {
return getImpl()->numElements; }
2174 return getImpl()->props;
2177OpenVectorType OpenVectorType::getConstType(
bool isConst)
const {
2180 return get(getElementType(), getNumElements(),
isConst);
2183uint64_t OpenVectorType::getFieldID(uint64_t index)
const {
2187uint64_t OpenVectorType::getIndexForFieldID(uint64_t fieldID)
const {
2188 assert(fieldID &&
"fieldID must be at least 1");
2193std::pair<uint64_t, uint64_t>
2194OpenVectorType::getIndexAndSubfieldID(uint64_t fieldID)
const {
2197 return {index, fieldID - elementFieldID};
2200std::pair<Type, uint64_t>
2201OpenVectorType::getSubTypeByFieldID(uint64_t fieldID)
const {
2207uint64_t OpenVectorType::getMaxFieldID()
const {
2209 return getNumElements() *
2213std::pair<uint64_t, bool>
2214OpenVectorType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
2218 return std::make_pair(fieldID - childRoot,
2219 fieldID >= childRoot && fieldID <= rangeEnd);
2222bool OpenVectorType::isConst()
const {
return getImpl()->isConst; }
2224OpenVectorType::ElementType OpenVectorType::getElementTypePreservingConst() {
2225 auto type = getElementType();
2227 return TypeSwitch<FIRRTLType, ElementType>(type)
2228 .Case<
FIRRTLBaseType, OpenBundleType, OpenVectorType>([&](
auto type) {
2229 return type.getConstType(type.isConst() ||
isConst());
2235OpenVectorType::verify(function_ref<InFlightDiagnostic()> emitErrorFn,
2239 return emitErrorFn() <<
"vector cannot be const with references";
2241 return emitErrorFn() <<
"vector cannot have a left-hand side type";
2243 return emitErrorFn() <<
"vector cannot have a domain type";
2252 using KeyTy = std::tuple<ArrayRef<FEnumType::EnumElement>,
char>;
2258 false,
false,
false};
2261 auto type = element.type;
2262 auto eltInfo = type.getRecursiveTypeProperties();
2291FEnumType FEnumType::get(::mlir::MLIRContext *
context,
2292 ArrayRef<EnumElement> elements,
bool isConst) {
2296ArrayRef<FEnumType::EnumElement> FEnumType::getElements()
const {
2297 return getImpl()->elements;
2300FEnumType FEnumType::getConstType(
bool isConst)
const {
2301 return get(getContext(), getElements(),
isConst);
2304FEnumType FEnumType::getAllConstDroppedType() {
2308 SmallVector<EnumElement> constDroppedElements(
2309 llvm::map_range(getElements(), [](EnumElement element) {
2310 element.type = element.type.getAllConstDroppedType();
2313 return get(getContext(), constDroppedElements,
false);
2318 return getImpl()->recProps;
2321std::optional<unsigned> FEnumType::getElementIndex(StringAttr name) {
2322 for (
const auto &it : llvm::enumerate(getElements())) {
2323 auto element = it.value();
2324 if (element.name == name) {
2325 return unsigned(it.index());
2328 return std::nullopt;
2331size_t FEnumType::getBitWidth() {
return getDataWidth() + getTagWidth(); }
2333size_t FEnumType::getDataWidth() {
return getImpl()->dataSize; }
2335size_t FEnumType::getTagWidth() {
2336 if (getElements().size() == 0)
2339 return cast<IntegerType>(getElements()[0].value.getType()).getWidth();
2342std::optional<unsigned> FEnumType::getElementIndex(StringRef name) {
2343 for (
const auto &it : llvm::enumerate(getElements())) {
2344 auto element = it.value();
2345 if (element.name.getValue() == name) {
2346 return unsigned(it.index());
2349 return std::nullopt;
2352StringAttr FEnumType::getElementNameAttr(
size_t index) {
2353 assert(index < getNumElements() &&
2354 "index must be less than number of fields in enum");
2355 return getElements()[index].name;
2358StringRef FEnumType::getElementName(
size_t index) {
2359 return getElementNameAttr(index).getValue();
2362IntegerAttr FEnumType::getElementValueAttr(
size_t index) {
2363 return getElements()[index].value;
2366APInt FEnumType::getElementValue(
size_t index) {
2367 return getElementValueAttr(index).getValue();
2371 return getElements()[index].type;
2374std::optional<FEnumType::EnumElement> FEnumType::getElement(StringAttr name) {
2375 if (
auto maybeIndex = getElementIndex(name))
2376 return getElements()[*maybeIndex];
2377 return std::nullopt;
2380std::optional<FEnumType::EnumElement> FEnumType::getElement(StringRef name) {
2381 if (
auto maybeIndex = getElementIndex(name))
2382 return getElements()[*maybeIndex];
2383 return std::nullopt;
2387FEnumType::EnumElement FEnumType::getElement(
size_t index) {
2388 assert(index < getNumElements() &&
2389 "index must be less than number of fields in enum");
2390 return getElements()[index];
2394 auto element = getElement(name);
2399 auto element = getElement(name);
2404 assert(index < getNumElements() &&
2405 "index must be less than number of fields in enum");
2406 return getElements()[index].type;
2409FIRRTLBaseType FEnumType::getElementTypePreservingConst(
size_t index) {
2410 auto type = getElementType(index);
2411 return type.getConstType(type.isConst() ||
isConst());
2414LogicalResult FEnumType::verify(function_ref<InFlightDiagnostic()> emitErrorFn,
2415 ArrayRef<EnumElement> elements,
bool isConst) {
2417 IntegerAttr previous;
2418 SmallPtrSet<Attribute, 4> nameSet;
2420 for (
auto &elt : elements) {
2421 auto r = elt.type.getRecursiveTypeProperties();
2423 return emitErrorFn() <<
"enum field " << elt.name <<
" not passive";
2424 if (r.containsAnalog)
2425 return emitErrorFn() <<
"enum field " << elt.name <<
" contains analog";
2426 if (r.hasUninferredWidth)
2427 return emitErrorFn() <<
"enum field " << elt.name
2428 <<
" has uninferred width";
2429 if (r.hasUninferredReset)
2430 return emitErrorFn() <<
"enum field " << elt.name
2431 <<
" has uninferred reset";
2432 if (r.containsConst && !
isConst)
2433 return emitErrorFn() <<
"enum with 'const' elements must be 'const'";
2435 if (!nameSet.insert(elt.name).second)
2436 return emitErrorFn() <<
"duplicate variant name " << elt.name
2440 previous = elt.value;
2443 auto current = elt.value;
2444 if (previous.getType() != current.getType())
2445 return emitErrorFn() <<
"enum variant " << elt.name <<
" has type"
2446 << current.getType()
2447 <<
" which is different than previous variant "
2448 << previous.getType();
2450 if (previous.getValue().getBitWidth() != current.getValue().getBitWidth())
2451 return emitErrorFn() <<
"enum variant " << elt.name <<
" has bitwidth"
2452 << current.getValue().getBitWidth()
2453 <<
" which is different than previous variant "
2454 << previous.getValue().getBitWidth();
2455 if (previous.getValue().uge(current.getValue()))
2456 return emitErrorFn()
2457 <<
"enum variant " << elt.name <<
" has value " << current
2458 <<
" which is not greater than previous variant " << previous;
2467 auto *
impl = getImpl();
2469 if (
impl->anonymousType)
2470 return impl->anonymousType;
2472 if (!
impl->recProps.containsTypeAlias)
2473 return impl->anonymousType = *
this;
2475 SmallVector<FEnumType::EnumElement, 4> elements;
2477 for (
auto element : getElements())
2479 {element.name, element.value, element.type.getAnonymousType()});
2480 return impl->anonymousType = FEnumType::get(getContext(), elements);
2489 using KeyTy = std::tuple<StringAttr, FIRRTLBaseType>;
2513auto BaseTypeAliasType::get(StringAttr name,
FIRRTLBaseType innerType)
2514 -> BaseTypeAliasType {
2515 return Base::get(name.getContext(), name, innerType);
2518auto BaseTypeAliasType::getName() const -> StringAttr {
2519 return getImpl()->name;
2523 return getImpl()->innerType;
2527 auto *
impl = getImpl();
2528 if (
impl->anonymousType)
2529 return impl->anonymousType;
2530 return impl->anonymousType = getInnerType().getAnonymousType();
2538 auto rtp = getInnerType().getRecursiveTypeProperties();
2546BaseTypeAliasType::getModifiedType(
FIRRTLBaseType newInnerType)
const {
2547 if (newInnerType == getInnerType())
2549 return newInnerType;
2554 return getModifiedType(getInnerType().getAllConstDroppedType());
2558 return getModifiedType(getInnerType().getConstType(
isConst));
2561std::pair<Type, uint64_t>
2562BaseTypeAliasType::getSubTypeByFieldID(uint64_t fieldID)
const {
2566uint64_t BaseTypeAliasType::getMaxFieldID()
const {
2570std::pair<uint64_t, bool>
2571BaseTypeAliasType::projectToChildFieldID(uint64_t fieldID,
2572 uint64_t index)
const {
2576uint64_t BaseTypeAliasType::getIndexForFieldID(uint64_t fieldID)
const {
2580uint64_t BaseTypeAliasType::getFieldID(uint64_t index)
const {
2584std::pair<uint64_t, uint64_t>
2585BaseTypeAliasType::getIndexAndSubfieldID(uint64_t fieldID)
const {
2594 return LHSType::get(type.getContext(), type);
2597LogicalResult LHSType::verify(function_ref<InFlightDiagnostic()> emitError,
2599 if (type.containsAnalog())
2600 return emitError() <<
"lhs type cannot contain an AnalogType";
2602 return emitError() <<
"lhs type cannot contain a non-passive type";
2603 if (type.containsReference())
2604 return emitError() <<
"lhs type cannot contain a reference";
2606 return emitError() <<
"lhs type cannot contain a lhs type";
2615auto RefType::get(
FIRRTLBaseType type,
bool forceable, SymbolRefAttr layer)
2617 return Base::get(type.getContext(), type, forceable, layer);
2620auto RefType::verify(function_ref<InFlightDiagnostic()> emitErrorFn,
2623 if (!base.isPassive())
2624 return emitErrorFn() <<
"reference base type must be passive";
2625 if (forceable && base.containsConst())
2626 return emitErrorFn()
2627 <<
"forceable reference base type cannot contain const";
2632 auto rtp = getType().getRecursiveTypeProperties();
2635 rtp.isPassive =
false;
2643AnalogType AnalogType::get(mlir::MLIRContext *
context) {
2644 return AnalogType::get(
context, -1,
false);
2647AnalogType AnalogType::get(mlir::MLIRContext *
context,
2648 std::optional<int32_t> width,
bool isConst) {
2652LogicalResult AnalogType::verify(function_ref<InFlightDiagnostic()> emitError,
2653 int32_t widthOrSentinel,
bool isConst) {
2654 if (widthOrSentinel < -1)
2655 return emitError() <<
"invalid width";
2659int32_t AnalogType::getWidthOrSentinel()
const {
return getImpl()->width; }
2661AnalogType AnalogType::getConstType(
bool isConst)
const {
2664 return get(getContext(), getWidthOrSentinel(),
isConst);
2671ClockType ClockType::getConstType(
bool isConst)
const {
2681ResetType ResetType::getConstType(
bool isConst)
const {
2691AsyncResetType AsyncResetType::getConstType(
bool isConst)
const {
2702 using KeyTy = std::tuple<FlatSymbolRefAttr, ArrayRef<ClassElement>>;
2706 auto name = std::get<0>(key);
2707 auto elements = allocator.copyInto(std::get<1>(key));
2710 SmallVector<uint64_t, 4> ids;
2719 auto fieldIDs = allocator.copyInto(ArrayRef(ids));
2741ClassType ClassType::get(FlatSymbolRefAttr name,
2742 ArrayRef<ClassElement> elements) {
2743 return get(name.getContext(), name, elements);
2746StringRef ClassType::getName()
const {
2747 return getNameAttr().getAttr().getValue();
2750FlatSymbolRefAttr ClassType::getNameAttr()
const {
return getImpl()->name; }
2752ArrayRef<ClassElement> ClassType::getElements()
const {
2753 return getImpl()->elements;
2756const ClassElement &ClassType::getElement(IntegerAttr index)
const {
2757 return getElement(index.getValue().getZExtValue());
2760const ClassElement &ClassType::getElement(
size_t index)
const {
2761 return getElements()[index];
2764std::optional<uint64_t> ClassType::getElementIndex(StringRef fieldName)
const {
2765 for (
const auto [i, e] : llvm::enumerate(getElements()))
2766 if (fieldName == e.name)
2771void ClassType::printInterface(AsmPrinter &p)
const {
2775 for (
const auto &element : getElements()) {
2778 p << element.direction <<
" ";
2779 p.printKeywordOrString(element.name);
2780 p <<
": " << element.type;
2786uint64_t ClassType::getFieldID(uint64_t index)
const {
2787 return getImpl()->fieldIDs[index];
2790uint64_t ClassType::getIndexForFieldID(uint64_t fieldID)
const {
2791 assert(!getElements().
empty() &&
"Class must have >0 fields");
2792 auto fieldIDs = getImpl()->fieldIDs;
2793 auto *it = std::prev(llvm::upper_bound(fieldIDs, fieldID));
2794 return std::distance(fieldIDs.begin(), it);
2797std::pair<uint64_t, uint64_t>
2798ClassType::getIndexAndSubfieldID(uint64_t fieldID)
const {
2801 return {index, fieldID - elementFieldID};
2804std::pair<Type, uint64_t>
2805ClassType::getSubTypeByFieldID(uint64_t fieldID)
const {
2809 auto subfieldType = getElement(subfieldIndex).type;
2810 auto subfieldID = fieldID -
getFieldID(subfieldIndex);
2811 return {subfieldType, subfieldID};
2814uint64_t ClassType::getMaxFieldID()
const {
return getImpl()->maxFieldID; }
2816std::pair<uint64_t, bool>
2817ClassType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
2819 auto rangeEnd = index + 1 >= getNumElements() ?
getMaxFieldID()
2821 return std::make_pair(fieldID - childRoot,
2822 fieldID >= childRoot && fieldID <= rangeEnd);
2829struct InterfaceParser {
2832 InterfaceParser(AsmParser &parser) : parser(parser) {}
2835 template <
typename FieldContainer>
2837 function_ref<ParseResult(FieldContainer &, AsmParser &parser)> parseField,
2838 StringAttr &symbolName, FieldContainer &fields) {
2840 if (parser.parseSymbolName(symbolName))
2844 if (parser.parseLParen())
2848 if (failed(parser.parseOptionalRParen())) {
2849 auto parseElement = [&]() -> ParseResult {
2850 return parseField(fields, parser);
2853 if (parser.parseCommaSeparatedList(parseElement) || parser.parseRParen())
2862ParseResult ClassType::parseInterface(AsmParser &parser, ClassType &result) {
2863 InterfaceParser helper(parser);
2865 auto parseField = [](SmallVector<ClassElement> &elements,
2866 AsmParser &parser) -> ParseResult {
2869 if (succeeded(parser.parseOptionalKeyword(
"out")))
2871 else if (succeeded(parser.parseKeyword(
"in",
"or 'out'")))
2877 std::string keyword;
2878 if (parser.parseKeywordOrString(&keyword))
2880 StringAttr name = StringAttr::get(parser.getContext(), keyword);
2884 if (parser.parseColonType(type))
2887 elements.emplace_back(name, type,
direction);
2891 StringAttr symbolName;
2892 SmallVector<ClassElement> elements;
2893 if (helper.parse<SmallVector<ClassElement>>(parseField, symbolName, elements))
2896 result = ClassType::get(FlatSymbolRefAttr::get(symbolName), elements);
2904ParseResult DomainType::parseInterface(AsmParser &parser, DomainType &result) {
2905 InterfaceParser helper(parser);
2907 auto parseField = [](SmallVector<Attribute> &fields,
2908 AsmParser &parser) -> ParseResult {
2909 std::string fieldNameStr;
2911 if (parser.parseKeywordOrString(&fieldNameStr) || parser.parseColon() ||
2912 parser.parseType(fieldTypeRaw))
2915 auto fieldType = dyn_cast<PropertyType>(fieldTypeRaw);
2917 return parser.emitError(parser.getCurrentLocation(),
2918 "expected property type");
2920 auto fieldName = StringAttr::get(parser.getContext(), fieldNameStr);
2922 DomainFieldAttr::get(parser.getContext(), fieldName, fieldType));
2926 StringAttr symbolName;
2927 SmallVector<Attribute> fields;
2928 if (helper.parse<SmallVector<Attribute>>(parseField, symbolName, fields))
2931 result = DomainType::get(FlatSymbolRefAttr::get(symbolName),
2932 ArrayAttr::get(parser.getContext(), fields));
2936DomainType DomainType::get(FlatSymbolRefAttr name, ArrayAttr fields) {
2937 return Base::get(name.getContext(), name, fields);
2940DomainType DomainType::getFromDomainOp(DomainOp domainOp) {
2941 auto name = FlatSymbolRefAttr::get(domainOp.getNameAttr());
2942 return DomainType::get(name, domainOp.getFieldsAttr());
2945DomainFieldAttr DomainType::getField(
size_t index)
const {
2946 assert(index < getNumFields() &&
"index out of bounds");
2947 return cast<DomainFieldAttr>(getFields()[index]);
2950std::optional<uint64_t> DomainType::getFieldIndex(StringRef fieldName)
const {
2951 for (
const auto [i, attr] : llvm::enumerate(getFields())) {
2952 auto field = cast<DomainFieldAttr>(attr);
2953 if (fieldName == field.getName())
2959std::pair<Type, uint64_t>
2960DomainType::getSubTypeByFieldID(uint64_t fieldID)
const {
2966 if (fieldID > getNumFields())
2967 return {Type(), fieldID};
2969 return {getField(fieldID - 1).getType(), 0};
2972uint64_t DomainType::getMaxFieldID()
const {
2974 return getNumFields();
2977std::pair<uint64_t, bool>
2978DomainType::projectToChildFieldID(uint64_t fieldID, uint64_t index)
const {
2980 if (index >= getNumFields())
2983 uint64_t childFieldID = index + 1;
2984 return {0, fieldID == childFieldID};
2987uint64_t DomainType::getFieldID(uint64_t index)
const {
2989 assert(index < getNumFields() &&
"index out of bounds");
2993uint64_t DomainType::getIndexForFieldID(uint64_t fieldID)
const {
2995 assert(fieldID > 0 && fieldID <= getNumFields() &&
"fieldID out of bounds");
2999std::pair<uint64_t, uint64_t>
3000DomainType::getIndexAndSubfieldID(uint64_t fieldID)
const {
3002 assert(fieldID > 0 && fieldID <= getNumFields() &&
"fieldID out of bounds");
3003 return {fieldID - 1, 0};
3007DomainType::verifySymbolUses(Operation *op,
3008 SymbolTableCollection &symbolTable)
const {
3010 auto circuitOp = op->getParentOfType<CircuitOp>();
3012 return op->emitError() <<
"domain type used outside of a circuit";
3015 auto *symbol = symbolTable.lookupSymbolIn(circuitOp,
getName());
3017 return op->emitError() <<
"domain type references undefined symbol '"
3018 <<
getName().getValue() <<
"'";
3021 auto domainOp = dyn_cast<DomainOp>(symbol);
3023 return op->emitError() <<
"domain type references symbol '"
3024 <<
getName().getValue() <<
"' which is not a domain";
3027 auto expectedFields = domainOp.getFieldsAttr();
3028 auto actualFields = getFields();
3031 if (actualFields.size() != expectedFields.size())
3032 return op->emitError() <<
"domain type has " << actualFields.size()
3033 <<
" fields but domain definition has "
3034 << expectedFields.size() <<
" fields";
3037 for (
size_t i = 0; i < actualFields.size(); ++i) {
3038 auto actualField = cast<DomainFieldAttr>(actualFields[i]);
3039 auto expectedField = cast<DomainFieldAttr>(expectedFields[i]);
3042 if (actualField.getName() != expectedField.getName())
3043 return op->emitError() <<
"domain type field " << i <<
" has name '"
3044 << actualField.getName().getValue()
3045 <<
"' but domain definition expects '"
3046 << expectedField.getName().getValue() <<
"'";
3049 if (actualField.getType() != expectedField.getType())
3050 return op->emitError()
3051 <<
"domain type field '" << actualField.getName().getValue()
3052 <<
"' has type " << actualField.getType()
3053 <<
" but domain definition expects " << expectedField.getType();
3063void FIRRTLDialect::registerTypes() {
3065#define GET_TYPEDEF_LIST
3066#include "circt/Dialect/FIRRTL/FIRRTLTypes.cpp.inc"
3080 return TypeSwitch<FIRRTLBaseType, std::optional<int64_t>>(type)
3081 .Case<BundleType>([&](BundleType bundle) -> std::optional<int64_t> {
3083 for (
auto &elt : bundle) {
3084 if (elt.isFlip && !ignoreFlip)
3085 return std::nullopt;
3088 return std::nullopt;
3093 .Case<FEnumType>([&](FEnumType fenum) -> std::optional<int64_t> {
3095 for (
auto &elt : fenum) {
3098 return std::nullopt;
3099 width = std::max(width, *w);
3101 return width + fenum.getTagWidth();
3103 .Case<FVectorType>([&](
auto vector) -> std::optional<int64_t> {
3106 return std::nullopt;
3107 return *w * vector.getNumElements();
3110 .Case<ClockType, ResetType, AsyncResetType>([](Type) {
return 1; })
3111 .Default([&](
auto t) {
return std::nullopt; });
3113 return getWidth(type);
assert(baseType &&"element must be base type")
MlirType uint64_t numElements
static std::unique_ptr< Context > context
static ParseResult parseFIRRTLBaseType(FIRRTLBaseType &result, StringRef name, AsmParser &parser)
static ParseResult parseFIRRTLPropertyType(PropertyType &result, StringRef name, AsmParser &parser)
static LogicalResult customTypePrinter(Type type, AsmPrinter &os)
Print a type with a custom printer implementation.
static OptionalParseResult customTypeParser(AsmParser &parser, StringRef name, Type &result)
Parse a type with a custom parser implementation.
static ParseResult parseType(Type &result, StringRef name, AsmParser &parser)
Parse a type defined by this dialect.
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.
@ ContainsAnalogBitMask
Bit set if the type contains an analog type.
@ HasUninferredWidthBitMask
Bit set fi the type has any uninferred bit widths.
@ IsPassiveBitMask
Bit set if the type only contains passive elements.
static ParseResult parseFIRRTLType(FIRRTLType &result, StringRef name, AsmParser &parser)
Parse a FIRRTLType with a name that has already been parsed.
static unsigned getFieldID(BundleType type, unsigned index)
static unsigned getIndexForFieldID(BundleType type, unsigned fieldID)
static unsigned getMaxFieldID(FIRRTLBaseType type)
false return failure()
Parse an optional keyword or string and set instance into 'result'.
static InstancePath empty
FIRRTLBaseType getConstType(bool isConst) const
Return a 'const' or non-'const' version of this type.
FIRRTLBaseType getAnonymousType()
Return this type with any type alias types recursively removed from itself.
bool isResetType()
Return true if this is a valid "reset" type.
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...
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 getWidthlessType()
Return this type with widths of all ground types removed.
bool isConst() const
Returns true if this is a 'const' type that can only hold compile-time constant values.
This class implements the same functionality as TypeSwitch except that it uses firrtl::type_dyn_cast ...
FIRRTLTypeSwitch< T, ResultT > & Case(CallableT &&caseFn)
Add a case on the given type.
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.
RecursiveTypeProperties getRecursiveTypeProperties() const
Return the recursive properties of the type, containing the isPassive, containsAnalog,...
bool isConst() const
Returns true if this is a 'const' type that can only hold compile-time constant values.
This is the common base class between SIntType and UIntType.
IntType getConstType(bool isConst) const
Return a 'const' or non-'const' version of this 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.
std::optional< int32_t > getWidth() const
Return an optional containing the width, if the width is known (or empty if width is unknown).
Represents a limited word-length unsigned integer in SystemC as described in IEEE 1666-2011 ยง7....
static UIntType get(MLIRContext *context, unsigned width)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
BaseTy type_cast(Type type)
Direction
This represents the direction of a single port.
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.
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.
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 ...
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.
bool isConst(Type type)
Returns true if this is a 'const' type whose value is guaranteed to be unchanging at circuit executio...
bool hasHardwareElements(FIRRTLType type)
Return true if the given type contains any elements of hardware types.
bool areTypesConstCastable(FIRRTLType destType, FIRRTLType srcType, bool srcOuterTypeIsConst=false)
Returns whether the srcType can be const-casted to the destType.
ParseResult parseNestedPropertyType(PropertyType &result, AsmParser &parser)
std::optional< int64_t > getBitWidth(FIRRTLBaseType type, bool ignoreFlip=false)
std::pair< uint64_t, uint64_t > getIndexAndSubfieldID(Type type, uint64_t fieldID)
uint64_t getFieldID(Type type, uint64_t index)
std::pair<::mlir::Type, uint64_t > getSubTypeByFieldID(Type, uint64_t fieldID)
std::pair< uint64_t, bool > projectToChildFieldID(Type, uint64_t fieldID, uint64_t index)
uint64_t getIndexForFieldID(Type type, uint64_t fieldID)
uint64_t getMaxFieldID(Type)
StringAttr getName(ArrayAttr names, size_t idx)
Return the name at the specified index of the ArrayAttr or null if it cannot be determined.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
llvm::hash_code hash_value(const DenseSet< T > &set)
A collection of bits indicating the recursive properties of a type.
bool containsReference
Whether the type contains a reference type.
bool containsTypeAlias
Whether the type contains a type alias.
bool containsConst
Whether the type contains a const type.
bool operator==(const KeyTy &key) const
static BaseTypeAliasStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
BaseTypeAliasStorage(StringAttr name, FIRRTLBaseType innerType)
std::tuple< StringAttr, FIRRTLBaseType > KeyTy
static llvm::hash_code hashKey(const KeyTy &key)
FIRRTLBaseType anonymousType
static BundleTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
std::tuple< ArrayRef< BundleType::BundleElement >, char > KeyTy
SmallVector< BundleType::BundleElement, 4 > elements
static llvm::hash_code hashKey(const KeyTy &key)
RecursiveTypeProperties props
This holds the bits for the type's recursive properties, and can hold a pointer to a passive version ...
BundleTypeStorage(ArrayRef< BundleType::BundleElement > elements, bool isConst)
bool operator==(const KeyTy &key) const
SmallVector< uint64_t, 4 > fieldIDs
std::tuple< FlatSymbolRefAttr, ArrayRef< ClassElement > > KeyTy
bool operator==(const KeyTy &key) const
ArrayRef< uint64_t > fieldIDs
static ClassTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
ArrayRef< ClassElement > elements
ClassTypeStorage(FlatSymbolRefAttr name, ArrayRef< ClassElement > elements, ArrayRef< uint64_t > fieldIDs, uint64_t maxFieldID)
SmallVector< FEnumType::EnumElement, 4 > elements
static llvm::hash_code hashKey(const KeyTy &key)
bool operator==(const KeyTy &key) const
static FEnumTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
FEnumTypeStorage(ArrayRef< FEnumType::EnumElement > elements, bool isConst)
RecursiveTypeProperties recProps
FIRRTLBaseType anonymousType
std::tuple< ArrayRef< FEnumType::EnumElement >, char > KeyTy
bool operator==(const KeyTy &key) const
FIRRTLBaseTypeStorage(bool isConst)
static FIRRTLBaseTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
bool operator==(const KeyTy &key) const
FIRRTLBaseType elementType
RecursiveTypeProperties props
This holds the bits for the type's recursive properties, and can hold a pointer to a passive version ...
FIRRTLBaseType passiveType
static FVectorTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
FIRRTLBaseType anonymousType
std::tuple< FIRRTLBaseType, size_t, char > KeyTy
FVectorTypeStorage(FIRRTLBaseType elementType, size_t numElements, bool isConst)
SmallVector< OpenBundleType::BundleElement, 4 > elements
bool operator==(const KeyTy &key) const
static OpenBundleTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
static llvm::hash_code hashKey(const KeyTy &key)
RecursiveTypeProperties props
This holds the bits for the type's recursive properties, and can hold a pointer to a passive version ...
OpenBundleTypeStorage(ArrayRef< OpenBundleType::BundleElement > elements, bool isConst)
SmallVector< uint64_t, 4 > fieldIDs
std::tuple< ArrayRef< OpenBundleType::BundleElement >, char > KeyTy
std::tuple< FIRRTLType, size_t, char > KeyTy
bool operator==(const KeyTy &key) const
RecursiveTypeProperties props
static OpenVectorTypeStorage * construct(TypeStorageAllocator &allocator, KeyTy key)
OpenVectorTypeStorage(FIRRTLType elementType, size_t numElements, bool isConst)
WidthTypeStorage(int32_t width, bool isConst)
std::tuple< int32_t, char > KeyTy
bool operator==(const KeyTy &key) const
static WidthTypeStorage * construct(TypeStorageAllocator &allocator, const KeyTy &key)