Mercurial > lcfOS
diff python/codegenarm.py @ 240:6259856841a0
Remove project
author | Windel Bouwman |
---|---|
date | Mon, 22 Jul 2013 22:37:33 +0200 |
parents | 81752b0f85a5 |
children | ef683881c64e |
line wrap: on
line diff
--- a/python/codegenarm.py Mon Jul 22 17:57:25 2013 +0200 +++ b/python/codegenarm.py Mon Jul 22 22:37:33 2013 +0200 @@ -34,6 +34,7 @@ self.emit(Label('reset')) for f in ircode.Functions: + self.localVars = [] # Add global variable addresses to immediate list: for gvar in ircode.Variables: pass #self.imms.append(( @@ -87,18 +88,27 @@ self.imms.append((lname, ins.value)) self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.addStack(ins.target)))) elif type(ins) is ir.Store: + print('STORE', ins, self.localVars) # Load value in r0: self.loadStack(arm.r0, ins.value) # store in memory: # TODO: split globals and locals?? #self.getGlobal(arm.r1, ins.location) - self.loadStack(arm.r1, ins.location) - self.emit(arm.storeimm5_ins(arm.r0, arm.MemR8Rel(arm.r1, 0))) + # Horrible hack with localVars + if ins.location in self.localVars: + print('local', ins.location) + self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.getStack(ins.location)))) + else: + self.loadStack(arm.r1, ins.location) + self.emit(arm.storeimm5_ins(arm.r0, arm.MemR8Rel(arm.r1, 0))) elif type(ins) is ir.Load: # TODO: differ global and local?? #self.getGlobal(arm.r0, ins.location) - self.loadStack(arm.r0, ins.location) - self.emit(arm.loadimm5_ins(arm.r0, arm.MemR8Rel(arm.r0, 0))) + if ins.location in self.localVars: + self.emit(arm.ldr_sprel(arm.r0, arm.MemSpRel(self.getStack(ins.location)))) + else: + self.loadStack(arm.r0, ins.location) + self.emit(arm.loadimm5_ins(arm.r0, arm.MemR8Rel(arm.r0, 0))) # Store value on stack: self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.addStack(ins.value)))) elif type(ins) is ir.BinaryOperator: @@ -132,6 +142,8 @@ elif type(ins) is ir.Alloc: # Local variables are added to stack self.addStack(ins.value) + self.localVars.append(ins.value) + # load address into variable: else: raise NotImplementedError('IR "{}" not covered'.format(ins))