forked from M-Labs/artiq
Generate more compact ARTIQ IR for else-less if.
This commit is contained in:
parent
e96bc3c36c
commit
255ffec483
|
@ -238,17 +238,22 @@ class IRGenerator(algorithm.Visitor):
|
||||||
self.current_block = if_true
|
self.current_block = if_true
|
||||||
self.visit(node.body)
|
self.visit(node.body)
|
||||||
|
|
||||||
if_false = self.add_block()
|
if any(node.orelse):
|
||||||
self.current_block = if_false
|
if_false = self.add_block()
|
||||||
self.visit(node.orelse)
|
self.current_block = if_false
|
||||||
|
self.visit(node.orelse)
|
||||||
|
|
||||||
tail = self.add_block()
|
tail = self.add_block()
|
||||||
self.current_block = tail
|
self.current_block = tail
|
||||||
if not if_true.is_terminated():
|
if not if_true.is_terminated():
|
||||||
if_true.append(ir.Branch(tail))
|
if_true.append(ir.Branch(tail))
|
||||||
if not if_false.is_terminated():
|
|
||||||
if_false.append(ir.Branch(tail))
|
if any(node.orelse):
|
||||||
head.append(ir.BranchIf(cond, if_true, if_false))
|
if not if_false.is_terminated():
|
||||||
|
if_false.append(ir.Branch(tail))
|
||||||
|
head.append(ir.BranchIf(cond, if_true, if_false))
|
||||||
|
else:
|
||||||
|
head.append(ir.BranchIf(cond, if_true, tail))
|
||||||
|
|
||||||
def visit_While(self, node):
|
def visit_While(self, node):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue