mirror of https://github.com/m-labs/artiq.git
transforms.artiq_ir_generator: correctly emit IfExpT with control flow.
This can happen with nested if expressions, as well as if the if expression includes delays.
This commit is contained in:
parent
b9bb5fba6a
commit
9639a831bc
|
@ -729,23 +729,25 @@ class ARTIQIRGenerator(algorithm.Visitor):
|
||||||
if_true = self.add_block()
|
if_true = self.add_block()
|
||||||
self.current_block = if_true
|
self.current_block = if_true
|
||||||
true_result = self.visit(node.body)
|
true_result = self.visit(node.body)
|
||||||
|
post_if_true = self.current_block
|
||||||
|
|
||||||
if_false = self.add_block()
|
if_false = self.add_block()
|
||||||
self.current_block = if_false
|
self.current_block = if_false
|
||||||
false_result = self.visit(node.orelse)
|
false_result = self.visit(node.orelse)
|
||||||
|
post_if_false = self.current_block
|
||||||
|
|
||||||
tail = self.add_block()
|
tail = self.add_block()
|
||||||
self.current_block = tail
|
self.current_block = tail
|
||||||
|
|
||||||
if not if_true.is_terminated():
|
if not post_if_true.is_terminated():
|
||||||
if_true.append(ir.Branch(tail))
|
post_if_true.append(ir.Branch(tail))
|
||||||
if not if_false.is_terminated():
|
if not post_if_false.is_terminated():
|
||||||
if_false.append(ir.Branch(tail))
|
post_if_false.append(ir.Branch(tail))
|
||||||
head.append(ir.BranchIf(cond, if_true, if_false))
|
head.append(ir.BranchIf(cond, if_true, if_false))
|
||||||
|
|
||||||
phi = self.append(ir.Phi(node.type))
|
phi = self.append(ir.Phi(node.type))
|
||||||
phi.add_incoming(true_result, if_true)
|
phi.add_incoming(true_result, post_if_true)
|
||||||
phi.add_incoming(false_result, if_false)
|
phi.add_incoming(false_result, post_if_false)
|
||||||
return phi
|
return phi
|
||||||
|
|
||||||
def visit_NumT(self, node):
|
def visit_NumT(self, node):
|
||||||
|
|
Loading…
Reference in New Issue