Mercurial > lcfOS
diff python/ppci/codegen/codegen.py @ 312:2c9768114877
Added cool logging formatter
author | Windel Bouwman |
---|---|
date | Mon, 16 Dec 2013 17:58:15 +0100 |
parents | 6753763d3bec |
children | 56e6ff84f646 |
line wrap: on
line diff
--- a/python/ppci/codegen/codegen.py Mon Dec 16 12:49:24 2013 +0100 +++ b/python/ppci/codegen/codegen.py Mon Dec 16 17:58:15 2013 +0100 @@ -1,8 +1,10 @@ from ..ir import Module +from ..irutils import Verifier from target import Target from ppci import CompilerError from .canon import make as canonicalize from .registerallocator import RegisterAllocator +import logging class CodeGenerator: @@ -11,21 +13,28 @@ # TODO: schedule traces in better order. # This is optional! assert isinstance(target, Target), target + self.logger = logging.getLogger('codegen') self.target = target self.ins_sel = target.ins_sel self.ra = RegisterAllocator() + self.verifier = Verifier() def generateFunc(self, irfunc, outs): """ Generate code for one function into a frame """ + self.logger.info('Generating code for {}'.format(irfunc.name)) # Create a frame for this function: frame = self.target.FrameClass(irfunc.name) # Canonicalize the intermediate language: canonicalize(irfunc, frame) + self.logger.info('after canonicalize', extra={'irfunc':irfunc}) + self.verifier.verify_function(irfunc) self.ins_sel.munchFunction(irfunc, frame) + self.logger.info('Selected instructions', extra={'ppci_frame':frame}) # Do register allocation: self.ra.allocFrame(frame) + self.logger.info('Registers allocated, now adding final glue') # TODO: Peep-hole here? # Add label and return and stack adjustment: @@ -34,6 +43,7 @@ # Materialize the register allocated instructions into a stream of # real instructions. frame.lower_to(outs) + self.logger.info('Instructions materialized') return frame def generate(self, ircode, outs):