comparison 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
comparison
equal deleted inserted replaced
257:703321743e8a 258:04c19282a5aa
30 ins = use 30 ins = use
31 if ins.parent != bb: 31 if ins.parent != bb:
32 return False 32 return False
33 return True 33 return True
34 34
35 def lastUse(self, ins):
36 assert ins in self.used_by
37 return all(not ins.precedes(ub) for ub in self.used_by)
35 38
36 class Variable(Value): 39 class Variable(Value):
37 pass 40 pass
38 41
39 42
95 def replaceValue(self, old, new): 98 def replaceValue(self, old, new):
96 raise NotImplementedError('{}'.format(type(self))) 99 raise NotImplementedError('{}'.format(type(self)))
97 100
98 @property 101 @property
99 def Position(self): 102 def Position(self):
100 return self.parent.Instructions.index(self) 103 return self.Block.Instructions.index(self)
104
105 def precedes(self, other):
106 assert isinstance(other, Instruction)
107 if self.Block is other.Block:
108 return other.Position > self.Position
109 return self.Block.precedes(other.Block)
101 110
102 @property 111 @property
103 def Function(self): 112 def Function(self):
104 return self.Block.parent 113 return self.Block.parent
105 114