ir: IRAssignable add helper property to give a sorted list of all uses (read or write) of the value
This commit is contained in:
parent
4469a94096
commit
393615b234
1 changed files with 9 additions and 0 deletions
|
|
@ -128,6 +128,15 @@ class IRAssignable(IRValue, metaclass=abc.ABCMeta):
|
||||||
super().__init__(location)
|
super().__init__(location)
|
||||||
self.writers: list[IRAction] = []
|
self.writers: list[IRAction] = []
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sorted_users(self) -> list[IRAction]:
|
||||||
|
assert all((x.ir_location.line != -1 for x in self.readers))
|
||||||
|
assert all((x.ir_location.line != -1 for x in self.writers))
|
||||||
|
|
||||||
|
users = self.readers + self.writers
|
||||||
|
users.sort(key=lambda user: user.ir_location)
|
||||||
|
return users
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.codegen()
|
return self.codegen()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue