From 2a474b7166a73fc6f1622e8ecbd258ed18808721 Mon Sep 17 00:00:00 2001 From: whitequark Date: Wed, 30 Dec 2015 16:06:18 +0800 Subject: [PATCH] ir: fix incoming_{blocks,values,value_for_block}. --- artiq/compiler/ir.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/artiq/compiler/ir.py b/artiq/compiler/ir.py index 82a1bf4d6..c591b759e 100644 --- a/artiq/compiler/ir.py +++ b/artiq/compiler/ir.py @@ -242,13 +242,13 @@ class Phi(Instruction): return def incoming_blocks(self): - return (block for (block, value) in self.incoming()) + return (block for (value, block) in self.incoming()) def incoming_values(self): - return (value for (block, value) in self.incoming()) + return (value for (value, block) in self.incoming()) def incoming_value_for_block(self, target_block): - for (block, value) in self.incoming(): + for (value, block) in self.incoming(): if block == target_block: return value assert False @@ -262,12 +262,14 @@ class Phi(Instruction): def remove_incoming_value(self, value): index = self.operands.index(value) + assert index % 2 == 0 self.operands[index].uses.remove(self) self.operands[index + 1].uses.remove(self) del self.operands[index:index + 2] def remove_incoming_block(self, block): index = self.operands.index(block) + assert index % 2 == 1 self.operands[index - 1].uses.remove(self) self.operands[index].uses.remove(self) del self.operands[index - 1:index + 1]