super().__init__(length=1)
+@plain_data(frozen=True, unsafe_hash=True)
+@final
+class FixedGPRRangeType(GPRRangeType):
+ __slots__ = "reg",
+
+ def __init__(self, reg):
+ # type: (GPRRange) -> None
+ super().__init__(length=reg.length)
+ self.reg = reg
+
+ @property
+ def reg_class(self):
+ # type: () -> RegClass
+ return RegClass([self.reg])
+
+
@plain_data(frozen=True, unsafe_hash=True)
@final
class CYType(RegType):
# type: () -> dict[str, SSAVal]
return {"dest": self.dest}
- def __init__(self, src):
- # type: (SSAVal[_RegT_co]) -> None
- self.dest = SSAVal(self, "dest", src.ty)
+ def __init__(self, src, dest_ty=None):
+ # type: (SSAVal[_RegT_co], _RegT_co | None) -> None
+ if dest_ty is None:
+ dest_ty = src.ty
+ if isinstance(src.ty, GPRRangeType) \
+ and isinstance(dest_ty, GPRRangeType):
+ if src.ty.length != dest_ty.length:
+ raise ValueError(f"incompatible source and destination "
+ f"types: {src.ty} and {dest_ty}")
+ elif src.ty != dest_ty:
+ raise ValueError(f"incompatible source and destination "
+ f"types: {src.ty} and {dest_ty}")
+
+ self.dest = SSAVal(self, "dest", dest_ty)
self.src = src
return {"out": self.out}
def __init__(self, ty):
- # type: (RegType) -> None
+ # type: (FixedGPRRangeType) -> None
self.out = SSAVal(self, "out", ty)