Mercurial > lcfOS
diff python/ir/instruction.py @ 258:04c19282a5aa
Added register allocator
author | Windel Bouwman |
---|---|
date | Mon, 05 Aug 2013 19:46:11 +0200 |
parents | c4370696ccc7 |
children | ac603eb66b63 |
line wrap: on
line diff
--- a/python/ir/instruction.py Sun Aug 04 18:34:06 2013 +0200 +++ b/python/ir/instruction.py Mon Aug 05 19:46:11 2013 +0200 @@ -32,6 +32,9 @@ return False return True + def lastUse(self, ins): + assert ins in self.used_by + return all(not ins.precedes(ub) for ub in self.used_by) class Variable(Value): pass @@ -97,7 +100,13 @@ @property def Position(self): - return self.parent.Instructions.index(self) + return self.Block.Instructions.index(self) + + def precedes(self, other): + assert isinstance(other, Instruction) + if self.Block is other.Block: + return other.Position > self.Position + return self.Block.precedes(other.Block) @property def Function(self):