Mercurial > lcfOS
comparison python/ir/instruction.py @ 221:848c4b15fd0b
pointers
author | Windel Bouwman |
---|---|
date | Mon, 08 Jul 2013 22:21:44 +0200 |
parents | 1fa3e0050b49 |
children | c3f1ce8b638f |
comparison
equal
deleted
inserted
replaced
220:3f6c30a5d234 | 221:848c4b15fd0b |
---|---|
138 self.value = value | 138 self.value = value |
139 self.addDef(value) | 139 self.addDef(value) |
140 self.location = location | 140 self.location = location |
141 self.addUse(self.location) | 141 self.addUse(self.location) |
142 def __repr__(self): | 142 def __repr__(self): |
143 return '{1} = [{0}]'.format(self.location, self.value) | 143 return '{} <= [{}]'.format(self.value, self.location) |
144 | 144 |
145 class Store(Instruction): | 145 class Store(Instruction): |
146 def __init__(self, location, value): | 146 def __init__(self, location, value): |
147 super().__init__() | 147 super().__init__() |
148 assert type(value) is Value | 148 assert type(value) is Value |
150 self.location = location | 150 self.location = location |
151 self.value = value | 151 self.value = value |
152 self.addUse(value) | 152 self.addUse(value) |
153 self.addUse(location) | 153 self.addUse(location) |
154 def __repr__(self): | 154 def __repr__(self): |
155 return '[{0}] = {1}'.format(self.location, self.value) | 155 return '[{}] <= {}'.format(self.location, self.value) |
156 | 156 |
157 # Branching: | 157 # Branching: |
158 class Branch(Terminator): | 158 class Branch(Terminator): |
159 def __init__(self, target): | 159 def __init__(self, target): |
160 super().__init__() | 160 super().__init__() |
172 def __init__(self, a, cond, b, lab1, lab2): | 172 def __init__(self, a, cond, b, lab1, lab2): |
173 super().__init__() | 173 super().__init__() |
174 self.a = a | 174 self.a = a |
175 assert type(a) is Value | 175 assert type(a) is Value |
176 self.cond = cond | 176 self.cond = cond |
177 assert cond in ['==', '<', '>'] | |
177 self.b = b | 178 self.b = b |
178 self.addUse(a) | 179 self.addUse(a) |
179 self.addUse(b) | 180 self.addUse(b) |
180 assert type(b) is Value | 181 assert type(b) is Value |
181 assert type(lab1) is BasicBlock | 182 assert type(lab1) is BasicBlock |