Skip to content

Commit

Permalink
transforms.artiq_ir_generator: correctly emit IfExpT with control flow.
Browse files Browse the repository at this point in the history
This can happen with nested if expressions, as well as if
the if expression includes delays.
whitequark committed Nov 19, 2015
1 parent b9bb5fb commit 9639a83
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions artiq/compiler/transforms/artiq_ir_generator.py
Original file line number Diff line number Diff line change
@@ -729,23 +729,25 @@ def visit_IfExpT(self, node):
if_true = self.add_block()
self.current_block = if_true
true_result = self.visit(node.body)
post_if_true = self.current_block

if_false = self.add_block()
self.current_block = if_false
false_result = self.visit(node.orelse)
post_if_false = self.current_block

tail = self.add_block()
self.current_block = tail

if not if_true.is_terminated():
if_true.append(ir.Branch(tail))
if not if_false.is_terminated():
if_false.append(ir.Branch(tail))
if not post_if_true.is_terminated():
post_if_true.append(ir.Branch(tail))
if not post_if_false.is_terminated():
post_if_false.append(ir.Branch(tail))
head.append(ir.BranchIf(cond, if_true, if_false))

phi = self.append(ir.Phi(node.type))
phi.add_incoming(true_result, if_true)
phi.add_incoming(false_result, if_false)
phi.add_incoming(true_result, post_if_true)
phi.add_incoming(false_result, post_if_false)
return phi

def visit_NumT(self, node):

0 comments on commit 9639a83

Please sign in to comment.