from abc import ABCMeta, abstractmethod
from collections import defaultdict
-from enum import Enum, unique
+from enum import Enum, unique, EnumMeta
from functools import lru_cache
from typing import (Sequence, AbstractSet, Iterable, Mapping,
- TYPE_CHECKING, Sequence, TypeVar, Generic)
+ TYPE_CHECKING, Sequence, Sized, TypeVar, Generic)
from nmutil.plain_data import plain_data
return v
-@plain_data(frozen=True, unsafe_hash=True)
+class ABCEnumMeta(EnumMeta, ABCMeta):
+ pass
+
+
class PhysLoc(metaclass=ABCMeta):
__slots__ = ()
-@plain_data(frozen=True, unsafe_hash=True)
class RegLoc(PhysLoc):
__slots__ = ()
...
-@plain_data(frozen=True, unsafe_hash=True)
-class GPRRangeOrStackLoc(PhysLoc):
+class GPRRangeOrStackLoc(PhysLoc, Sized):
__slots__ = ()
- @abstractmethod
- def __len__(self):
- # type: () -> int
- ...
-
GPR_COUNT = 128
@final
@unique
-class XERBit(Enum, RegLoc):
+class XERBit(RegLoc, Enum, metaclass=ABCEnumMeta):
CY = "CY"
def conflicts(self, other):
@final
@unique
-class GlobalMem(Enum, RegLoc):
+class GlobalMem(RegLoc, Enum, metaclass=ABCEnumMeta):
"""singleton representing all non-StackSlot memory -- treated as a single
physical register for register allocation purposes.
"""