ir: automatically add read-from/written-to values in IRAction if declared

This commit is contained in:
Antoine Viallon 2024-01-05 23:22:37 +01:00
parent 39c12a360c
commit 6af9c367c6
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -5,7 +5,7 @@ from abc import abstractmethod
from .errors import OverrideMandatoryError
from .logger import Logger
from .source import SourceLocation
from .source import SourceLocation, IRLocation as Location
from .typechecking import typecheck
logger = Logger(__name__)
@ -28,7 +28,19 @@ class IRItem:
class IRAction(IRItem, abc.ABC):
pass
def __init__(self, location: SourceLocation, reads: list[IRValue], writes: list[IRAssignable]):
super().__init__(location)
# Must be changed updated in a second pass, when every item has been generated
self.ir_location: Location = Location(-1, [])
self.reads = reads
self.writes = writes
for read in reads:
read.readers += [self]
for write in writes:
write.writers += [self]
class IRNop(IRAction):