comparison python/ppci/irmach.py @ 346:3bb7dcfe5529

expanded arm target
author Windel Bouwman
date Fri, 07 Mar 2014 17:05:32 +0100
parents 86b02c98a717
children 39bf68bf1891
comparison
equal deleted inserted replaced
345:b4882ff0ed06 346:3bb7dcfe5529
22 self.stacksize = 0 22 self.stacksize = 0
23 23
24 def __repr__(self): 24 def __repr__(self):
25 return 'Frame {}'.format(self.name) 25 return 'Frame {}'.format(self.name)
26 26
27 def lower_to(self, outs):
28 for im in self.instructions:
29 if isinstance(im.assem, Instruction):
30 outs.emit(im.assem)
31 else:
32 outs.emit(im.assem.fromim(im))
33
34 27
35 class AbstractInstruction: 28 class AbstractInstruction:
36 """ 29 """
37 Abstract machine instruction class. This is a very simple 30 Abstract machine instruction class. This is a very simple
38 abstraction of machine instructions. 31 abstraction of machine instructions.
46 self.jumps = tuple(jumps) 39 self.jumps = tuple(jumps)
47 self.others = tuple(others) 40 self.others = tuple(others)
48 self.ismove = ismove 41 self.ismove = ismove
49 42
50 def __repr__(self): 43 def __repr__(self):
51 return self.render() 44 """ Substitutes source, dst and labels in the string """
52
53 def render(self):
54 """
55 Substitutes source, dst and labels in the string
56 """
57 if isinstance(self.assem, Instruction): 45 if isinstance(self.assem, Instruction):
58 x = str(self.assem) 46 x = str(self.assem)
59 else: 47 else:
60 cn = self.assem.__name__ 48 cn = self.assem.__name__
61 x = '{}, def={}, use={}, other={}' 49 x = '{}, def={}, use={}, other={}'
62 x = x.format(cn, self.dst, self.src, self.others) 50 x = x.format(cn, self.dst, self.src, self.others)
63 return x 51 return x
64 52
65
66 makeIns = AbstractInstruction