comparison python/codegenarm.py @ 212:62386bcee1ba

Added parser combinator lib
author Windel Bouwman
date Sun, 30 Jun 2013 19:00:41 +0200
parents 99164160fb0b
children 494828a7adf1
comparison
equal deleted inserted replaced
211:99164160fb0b 212:62386bcee1ba
33 def generateInstruction(self, ins): 33 def generateInstruction(self, ins):
34 if type(ins) is ir.Branch: 34 if type(ins) is ir.Branch:
35 self.emit(arm.jmp_ins(ins.target)) 35 self.emit(arm.jmp_ins(ins.target))
36 elif type(ins) is ir.ImmLoad and ins.value < 255: 36 elif type(ins) is ir.ImmLoad and ins.value < 255:
37 self.emit(arm.mov_ins(arm.r0, arm.Imm8(ins.value))) 37 self.emit(arm.mov_ins(arm.r0, arm.Imm8(ins.value)))
38 # determine stack frame..
39 self.emit(arm.mov_ins(arm.r1, arm.Imm8(9)))
40 #self.emit(arm.
41 elif type(ins) is ir.ImmLoad and ins.value < (2**32):
42 print(ins)
38 elif type(ins) is ir.Store: 43 elif type(ins) is ir.Store:
39 print(ins) 44 print(ins)
40 elif type(ins) is ir.Return: 45 elif type(ins) is ir.Return:
41 self.emit(arm.pop_ins(arm.RegisterSet({arm.r2, arm.r3, arm.pc}))) 46 self.emit(arm.pop_ins(arm.RegisterSet({arm.r2, arm.r3, arm.pc})))
42 elif type(ins) is ir.Load: 47 elif type(ins) is ir.Load:
43 print(ins) 48 print(ins)
44 elif type(ins) is ir.BinaryOperator: 49 elif type(ins) is ir.BinaryOperator:
45 print(ins) 50 print(ins)
51 elif type(ins) is ir.ConditionalBranch:
52 print(ins)
46 else: 53 else:
47 print(ins) 54 print(ins)
48 raise CompilerError('IR "{}" not covered'.format(ins)) 55 raise CompilerError('IR "{}" not covered'.format(ins))
49 56
50 57