Mercurial > lcfOS
comparison python/codegen.py @ 210:67b0feafe5ae
Added missing file
author | Windel Bouwman |
---|---|
date | Sat, 29 Jun 2013 10:09:50 +0200 |
parents | |
children | 8786811a5a59 |
comparison
equal
deleted
inserted
replaced
209:07bfea4c1ed7 | 210:67b0feafe5ae |
---|---|
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) | |
21 print('TODO') | |
22 for f in ircode.Functions: | |
23 for bb in f.BasicBlocks: | |
24 print(bb) | |
25 for ins in bb.Instructions: | |
26 # Instruction selection: | |
27 print(ins) | |
28 #mi = self.tryMap(ins) | |
29 return obj | |
30 | |
31 |