Mercurial > lcfOS
comparison python/transform.py @ 261:444b9df2ed99
try to split up code generation
author | Windel Bouwman |
---|---|
date | Fri, 09 Aug 2013 09:05:13 +0200 |
parents | 7416c923a02a |
children | ea93e0a7a31e |
comparison
equal
deleted
inserted
replaced
260:b2f94b4951f1 | 261:444b9df2ed99 |
---|---|
105 if isinstance(i, ImmLoad): | 105 if isinstance(i, ImmLoad): |
106 if i.value in constMap: | 106 if i.value in constMap: |
107 t_new = constMap[i.value] | 107 t_new = constMap[i.value] |
108 t_old = i.target | 108 t_old = i.target |
109 logging.debug('Replacing {} with {}'.format(t_old, t_new)) | 109 logging.debug('Replacing {} with {}'.format(t_old, t_new)) |
110 for ui in t_old.used_by: | 110 t_old.replaceby(t_new) |
111 ui.replaceValue(t_old, t_new) | |
112 to_remove.append(i) | 111 to_remove.append(i) |
113 else: | 112 else: |
114 constMap[i.value] = i.target | 113 constMap[i.value] = i.target |
115 elif isinstance(i, BinaryOperator): | 114 elif isinstance(i, BinaryOperator): |
116 k = (i.value1, i.operation, i.value2) | 115 k = (i.value1, i.operation, i.value2) |
117 if k in constMap: | 116 if k in constMap: |
118 t_old = i.result | 117 t_old = i.result |
119 t_new = constMap[k] | 118 t_new = constMap[k] |
120 logging.debug('Replacing {} with {}'.format(t_old, t_new)) | 119 logging.debug('Replacing {} with {}'.format(t_old, t_new)) |
121 for ui in t_old.used_by: | 120 t_old.replaceby(t_new) |
122 ui.replaceValue(t_old, t_new) | |
123 to_remove.append(i) | 121 to_remove.append(i) |
124 else: | 122 else: |
125 constMap[k] = i.result | 123 constMap[k] = i.result |
126 for i in to_remove: | 124 for i in to_remove: |
127 logging.debug('removing {}'.format(i)) | 125 logging.debug('removing {}'.format(i)) |