Mercurial > lcfOS
diff python/instructionselector.py @ 274:ea93e0a7a31e
Move docs
author | Windel Bouwman |
---|---|
date | Wed, 04 Sep 2013 17:35:06 +0200 |
parents | 5f8c04a8d26b |
children | 6f2423df0675 |
line wrap: on
line diff
--- a/python/instructionselector.py Mon Sep 02 17:40:21 2013 +0200 +++ b/python/instructionselector.py Wed Sep 04 17:35:06 2013 +0200 @@ -25,20 +25,23 @@ # Entry point for instruction selection self.temps = genTemps() assert isinstance(p, ir.Module) - self.result = [] + self.frames = [] self.targets = {} self.tempMap = {} # Mapping from temporaries to infinite register for f in p.Functions: + # Enter a frame per function: + self.frame = self.newFrame(f.name) + self.frames.append(self.frame) # First define labels: - for bb in f.BasicBlocks: + for bb in f.Blocks: itgt = self.makeIns('{}:'.format(bb.name)) self.targets[bb] = itgt - for bb in f.BasicBlocks: + for bb in f.Blocks: self.emit2(self.targets[bb]) for i in bb.Instructions: self.munchStm(i) - bb.machIns = self.result - return self.result + #bb.machIns = self.result + return self.frames def makeIns(self, *args, **kwargs): return irmach.AbstractInstruction(*args, **kwargs) @@ -49,12 +52,17 @@ return self.emit2(i) def emit2(self, i): - self.result.append(i) + self.frame.instructions.append(i) return i + def newFrame(self, name): + raise NotImplementedError() + def munchStm(self, s): + """ Implement this in the target specific back-end """ raise NotImplementedError() def munchExpr(self, e): + """ Implement this in the target specific back-end """ raise NotImplementedError()