nodes: add a TrueDivision node making use of the explicit IRDiv ir item

This commit is contained in:
Antoine Viallon 2024-04-12 16:40:10 +02:00
parent 6630fa13a5
commit 8f26b393d1
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -199,6 +199,23 @@ class Product(Node):
return list(self.values) return list(self.values)
class TrueDivision(Node):
def intermediate_representation(self) -> list[ir.IRItem]:
result: list[ir.IRAction] = []
values_results = Node._prepare_sources_ir(result=result, values=self.values)
dest = ir.IRRegister(location=self.location())
result += [ir.IRDiv(self.location(), dest, *values_results)]
return result
def __init__(self, *values: Value):
super().__init__()
self.values = values
def _values(self) -> list[Node | Any]:
return list(self.values)
class Division(Node): class Division(Node):
def intermediate_representation(self) -> list[ir.IRItem]: def intermediate_representation(self) -> list[ir.IRItem]:
result: list[ir.IRAction] = [] result: list[ir.IRAction] = []
@ -228,7 +245,7 @@ class Division(Node):
return [self.first_value] + list(self.values) return [self.first_value] + list(self.values)
BinaryOperation = Sum | Sub | Product | Division BinaryOperation = Sum | Sub | Product | Division | TrueDivision
@typecheck @typecheck