Mercurial > lcfOS
comparison python/ppci/codegen/codegen.py @ 334:6f4753202b9a
Added more recipes
author | Windel Bouwman |
---|---|
date | Thu, 13 Feb 2014 22:02:08 +0100 |
parents | 56e6ff84f646 |
children | d1ecc493384e |
comparison
equal
deleted
inserted
replaced
333:dcae6574c974 | 334:6f4753202b9a |
---|---|
19 self.ra = RegisterAllocator() | 19 self.ra = RegisterAllocator() |
20 self.verifier = Verifier() | 20 self.verifier = Verifier() |
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.info('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(irfunc.name) |
27 | 27 |
28 # Canonicalize the intermediate language: | 28 # Canonicalize the intermediate language: |
29 canonicalize(irfunc, frame) | 29 canonicalize(irfunc, frame) |
30 self.logger.info('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) |
32 self.ins_sel.munchFunction(irfunc, frame) | 32 self.ins_sel.munchFunction(irfunc, frame) |
33 self.logger.info('Selected instructions', extra={'ppci_frame': frame}) | 33 self.logger.debug('Selected instructions', extra={'ppci_frame': frame}) |
34 | 34 |
35 # Do register allocation: | 35 # Do register allocation: |
36 self.ra.allocFrame(frame) | 36 self.ra.allocFrame(frame) |
37 self.logger.info('Registers allocated, now adding final glue') | 37 self.logger.debug('Registers allocated, now adding final glue') |
38 # TODO: Peep-hole here? | 38 # TODO: Peep-hole here? |
39 | 39 |
40 # Add label and return and stack adjustment: | 40 # Add label and return and stack adjustment: |
41 frame.EntryExitGlue3() | 41 frame.EntryExitGlue3() |
42 | 42 |
43 # Materialize the register allocated instructions into a stream of | 43 # Materialize the register allocated instructions into a stream of |
44 # real instructions. | 44 # real instructions. |
45 frame.lower_to(outs) | 45 frame.lower_to(outs) |
46 self.logger.info('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, Module) |