Mercurial > lcfOS
annotate python/codegen.py @ 280:02385f62f250
Rework from str interface to Instruction interface
author | Windel Bouwman |
---|---|
date | Sat, 02 Nov 2013 10:03:26 +0100 |
parents | ea93e0a7a31e |
children | 7b38782ed496 |
rev | line source |
---|---|
210 | 1 import ir, target |
2 from ppci import CompilerError | |
3 | |
4 class CodeGenerator: | |
5 """ Target independent code generator """ | |
6 def __init__(self, tg): | |
7 assert isinstance(tg, target.Target) | |
8 self.tg = tg | |
9 | |
10 def tryMap(self, ii): | |
11 for mi in self.tg.instructions: | |
12 if mi.irpattern is ii: | |
13 return mi.FromIr(ii) | |
14 raise CompilerError('Cannot map {0}'.format(ii)) | |
15 | |
16 def generate(self, ircode): | |
17 assert isinstance(ircode, ir.Module) | |
18 obj = object() | |
19 for gvar in ircode.Variables: | |
20 print(gvar) | |
280
02385f62f250
Rework from str interface to Instruction interface
Windel Bouwman
parents:
274
diff
changeset
|
21 raise Exception() # TODO |
210 | 22 for f in ircode.Functions: |
274 | 23 for bb in f.Blocks: |
210 | 24 for ins in bb.Instructions: |
25 # Instruction selection: | |
26 #mi = self.tryMap(ins) | |
236 | 27 pass |
210 | 28 return obj |
29 | |
30 |