@@ -37,7 +37,7 @@ void MooreDialect::registerTypes() {
37
37
addTypes<IntType, RealType, PackedNamedType, PackedRefType, UnpackedNamedType,
38
38
UnpackedRefType, PackedUnsizedDim, PackedRangeDim,
39
39
UnpackedUnsizedDim, UnpackedArrayDim, UnpackedRangeDim,
40
- UnpackedAssocDim, UnpackedQueueDim, EnumType, PackedStructType,
40
+ UnpackedAssocDim, UnpackedQueueDim, PackedStructType,
41
41
UnpackedStructType>();
42
42
43
43
addTypes<
@@ -260,7 +260,6 @@ Domain PackedType::getDomain() const {
260
260
.Case <IntType>([&](auto type) { return type.getDomain (); })
261
261
.Case <PackedIndirectType, PackedDim>(
262
262
[&](auto type) { return type.getInner ().getDomain (); })
263
- .Case <EnumType>([](auto type) { return type.getBase ().getDomain (); })
264
263
.Case <PackedStructType>(
265
264
[](auto type) { return type.getStruct ().domain ; });
266
265
}
@@ -271,8 +270,7 @@ Sign PackedType::getSign() const {
271
270
.Case <IntType, PackedStructType>(
272
271
[&](auto type) { return type.getSign (); })
273
272
.Case <PackedIndirectType, PackedDim>(
274
- [&](auto type) { return type.getInner ().getSign (); })
275
- .Case <EnumType>([](auto type) { return type.getBase ().getSign (); });
273
+ [&](auto type) { return type.getInner ().getSign (); });
276
274
}
277
275
278
276
std::optional<unsigned > PackedType::getBitSize () const {
@@ -287,16 +285,15 @@ std::optional<unsigned> PackedType::getBitSize() const {
287
285
})
288
286
.Case <PackedIndirectType>(
289
287
[](auto type) { return type.getInner ().getBitSize (); })
290
- .Case <EnumType>([](auto type) { return type.getBase ().getBitSize (); })
291
288
.Case <PackedStructType>(
292
289
[](auto type) { return type.getStruct ().bitSize ; });
293
290
}
294
291
295
292
void PackedType::format (llvm::raw_ostream &os) const {
296
293
TypeSwitch<PackedType>(*this )
297
294
.Case <VoidType>([&](auto ) { os << " void" ; })
298
- .Case <IntType, PackedRangeDim, PackedUnsizedDim, EnumType,
299
- PackedStructType>( [&](auto type) { type.format (os); })
295
+ .Case <IntType, PackedRangeDim, PackedUnsizedDim, PackedStructType>(
296
+ [&](auto type) { type.format (os); })
300
297
.Case <PackedNamedType>(
301
298
[&](auto type) { os << type.getName ().getValue (); })
302
299
.Case <PackedRefType>(
@@ -938,66 +935,6 @@ std::optional<unsigned> UnpackedQueueDim::getBound() const {
938
935
return bound;
939
936
}
940
937
941
- // ===----------------------------------------------------------------------===//
942
- // Enumerations
943
- // ===----------------------------------------------------------------------===//
944
-
945
- namespace circt {
946
- namespace moore {
947
- namespace detail {
948
-
949
- struct EnumTypeStorage : TypeStorage {
950
- using KeyTy = std::tuple<StringAttr, Location, PackedType, char >;
951
-
952
- EnumTypeStorage (KeyTy key)
953
- : name(std::get<0 >(key)), loc(std::get<1 >(key)), base(std::get<2 >(key)),
954
- explicitBase (std::get<3 >(key)) {}
955
- bool operator ==(const KeyTy &key) const {
956
- return std::get<0 >(key) == name && std::get<1 >(key) == loc &&
957
- std::get<2 >(key) == base && std::get<3 >(key) == explicitBase;
958
- }
959
- static EnumTypeStorage *construct (TypeStorageAllocator &allocator,
960
- const KeyTy &key) {
961
- return new (allocator.allocate <EnumTypeStorage>()) EnumTypeStorage (key);
962
- }
963
-
964
- StringAttr name;
965
- Location loc;
966
- PackedType base;
967
- bool explicitBase;
968
- };
969
-
970
- } // namespace detail
971
- } // namespace moore
972
- } // namespace circt
973
-
974
- EnumType EnumType::get (StringAttr name, Location loc, PackedType base) {
975
- return Base::get (loc.getContext (), name, loc,
976
- base ? base : IntType::getInt (loc.getContext ()), !!base);
977
- }
978
-
979
- PackedType EnumType::getBase () const { return getImpl ()->base ; }
980
-
981
- bool EnumType::isBaseExplicit () const { return getImpl ()->explicitBase ; }
982
-
983
- StringAttr EnumType::getName () const { return getImpl ()->name ; }
984
-
985
- Location EnumType::getLoc () const { return getImpl ()->loc ; }
986
-
987
- void EnumType::format (llvm::raw_ostream &os) const {
988
- os << " enum" ;
989
-
990
- // If the enum is part of a typedefm simply print it as `enum <name>`.
991
- if (auto name = getName ()) {
992
- os << " " << name.getValue ();
993
- return ;
994
- }
995
-
996
- // Otherwise print `enum <base-type>` or just `enum`.
997
- if (isBaseExplicit ())
998
- os << " " << getBase ();
999
- }
1000
-
1001
938
// ===----------------------------------------------------------------------===//
1002
939
// Packed and Unpacked Structs
1003
940
// ===----------------------------------------------------------------------===//
@@ -1227,31 +1164,6 @@ static OptionalParseResult customTypeParser(DialectAsmParser &parser,
1227
1164
if (auto kind = RealType::getKindFromKeyword (mnemonic))
1228
1165
return yieldUnpacked (RealType::get (context, *kind));
1229
1166
1230
- // Enums
1231
- if (mnemonic == " enum" ) {
1232
- if (parser.parseLess ())
1233
- return failure ();
1234
- StringAttr name;
1235
- auto result = parser.parseOptionalAttribute (name);
1236
- if (result.has_value ())
1237
- if (*result || parser.parseComma ())
1238
- return failure ();
1239
- LocationAttr loc;
1240
- PackedType base;
1241
- result = parser.parseOptionalAttribute (loc);
1242
- if (result.has_value ()) {
1243
- if (*result)
1244
- return failure ();
1245
- } else {
1246
- if (parseMooreType (parser, {Subset::Packed, false }, base) ||
1247
- parser.parseComma () || parser.parseAttribute (loc))
1248
- return failure ();
1249
- }
1250
- if (parser.parseGreater ())
1251
- return failure ();
1252
- return yieldPacked (EnumType::get (name, loc, base));
1253
- }
1254
-
1255
1167
// Everything that follows can be packed or unpacked. The packing is inferred
1256
1168
// from the last `packed<...>` or `unpacked<...>` that we've seen. The
1257
1169
// `yieldImplied` function will call the first lambda to construct a packed
@@ -1441,19 +1353,6 @@ static LogicalResult customTypePrinter(Type type, DialectAsmPrinter &printer,
1441
1353
.Case <RealType>(
1442
1354
[&](auto type) { return printer << type.getKeyword (), success (); })
1443
1355
1444
- // Enums
1445
- .Case <EnumType>([&](auto type) {
1446
- printer << " enum<" ;
1447
- if (type.getName ())
1448
- printer << type.getName () << " , " ;
1449
- if (type.isBaseExplicit ()) {
1450
- printMooreType (type.getBase (), printer, subset);
1451
- printer << " , " ;
1452
- }
1453
- printer << type.getLoc () << " >" ;
1454
- return success ();
1455
- })
1456
-
1457
1356
// Type indirections
1458
1357
.Case <PackedNamedType, UnpackedNamedType>([&](auto type) {
1459
1358
printer << " named<" << type.getName () << " , " ;
0 commit comments