Mercurial > lcfOS
comparison python/ppci/codegen/codegen.py @ 336:d1ecc493384e
Added spiffy armtoken class for bit fiddeling. Added cool test that checks for build repeatability
author | Windel Bouwman |
---|---|
date | Wed, 19 Feb 2014 22:32:15 +0100 |
parents | 6f4753202b9a |
children | 86b02c98a717 |
comparison
equal
deleted
inserted
replaced
335:582a1aaa3983 | 336:d1ecc493384e |
---|---|
1 from ..ir import Module | 1 from .. import ir |
2 from ..irutils import Verifier | 2 from ..irutils import Verifier |
3 from target import Target | 3 from target import Target |
4 from ppci import CompilerError | 4 from ppci import CompilerError |
5 from .canon import make as canonicalize | 5 from .canon import make as canonicalize |
6 from .registerallocator import RegisterAllocator | 6 from .registerallocator import RegisterAllocator |
21 | 21 |
22 def generateFunc(self, irfunc, outs): | 22 def generateFunc(self, irfunc, outs): |
23 """ Generate code for one function into a frame """ | 23 """ Generate code for one function into a frame """ |
24 self.logger.debug('Generating code for {}'.format(irfunc.name)) | 24 self.logger.debug('Generating code for {}'.format(irfunc.name)) |
25 # Create a frame for this function: | 25 # Create a frame for this function: |
26 frame = self.target.FrameClass(irfunc.name) | 26 frame = self.target.FrameClass(ir.label_name(irfunc)) |
27 | 27 |
28 # Canonicalize the intermediate language: | 28 # Canonicalize the intermediate language: |
29 canonicalize(irfunc, frame) | 29 canonicalize(irfunc, frame) |
30 self.logger.debug('after canonicalize', extra={'irfunc': irfunc}) | 30 self.logger.debug('after canonicalize', extra={'irfunc': irfunc}) |
31 self.verifier.verify_function(irfunc) | 31 self.verifier.verify_function(irfunc) |
46 self.logger.debug('Instructions materialized') | 46 self.logger.debug('Instructions materialized') |
47 return frame | 47 return frame |
48 | 48 |
49 def generate(self, ircode, outs): | 49 def generate(self, ircode, outs): |
50 """ Generate code into output stream """ | 50 """ Generate code into output stream """ |
51 assert isinstance(ircode, Module) | 51 assert isinstance(ircode, ir.Module) |
52 outs.selectSection('code') | 52 outs.selectSection('code') |
53 | 53 |
54 # Munch program into a bunch of frames. One frame per function. | 54 # Munch program into a bunch of frames. One frame per function. |
55 # Each frame has a flat list of abstract instructions. | 55 # Each frame has a flat list of abstract instructions. |
56 # Generate code for all functions: | 56 # Generate code for all functions: |