nodes: add a TrueDivision node making use of the explicit IRDiv ir item
This commit is contained in:
parent
6630fa13a5
commit
8f26b393d1
1 changed files with 18 additions and 1 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue