Mercurial > lcfOS
comparison python/ppci/irmach.py @ 323:e9fe6988497c
Used burg for generating expressions
author | Windel Bouwman |
---|---|
date | Thu, 30 Jan 2014 19:03:24 +0100 |
parents | 6753763d3bec |
children | 86b02c98a717 |
comparison
equal
deleted
inserted
replaced
322:44f336460c2a | 323:e9fe6988497c |
---|---|
9 | 9 |
10 from target import Instruction | 10 from target import Instruction |
11 | 11 |
12 | 12 |
13 class Frame: | 13 class Frame: |
14 """ | 14 """ |
15 Activation record abstraction. This class contains a flattened | 15 Activation record abstraction. This class contains a flattened |
16 function. Instructions are selected and scheduled at this stage. | 16 function. Instructions are selected and scheduled at this stage. |
17 Frames differ per machine. | 17 Frames differ per machine. |
18 """ | 18 """ |
19 def __init__(self, name): | 19 def __init__(self, name): |
52 | 52 |
53 def render(self): | 53 def render(self): |
54 """ | 54 """ |
55 Substitutes source, dst and labels in the string | 55 Substitutes source, dst and labels in the string |
56 """ | 56 """ |
57 x = str(self.assem) | 57 if isinstance(self.assem, Instruction): |
58 for i, s in enumerate(self.src): | 58 x = str(self.assem) |
59 p = '%s{}'.format(i) | 59 else: |
60 x = x.replace(p, str(s)) | 60 cn = self.assem.__name__ |
61 for i, d in enumerate(self.dst): | 61 x = '{}, def={}, use={}, other={}' |
62 p = '%d{}'.format(i) | 62 x = x.format(cn, self.dst, self.src, self.others) |
63 x = x.replace(p, str(d)) | |
64 for i, j in enumerate(self.jumps): | |
65 p = '%l{}'.format(i) | |
66 x = x.replace(p, str(j)) | |
67 return x | 63 return x |
68 | 64 |
69 | 65 |
70 makeIns = AbstractInstruction | 66 makeIns = AbstractInstruction |