comparison python/target/arminstructionselector.py @ 318:e84047f29c78

Add burg and yacc initial attempts
author Windel Bouwman
date Tue, 31 Dec 2013 12:38:15 +0100
parents 56e6ff84f646
children 44f336460c2a
comparison
equal deleted inserted replaced
317:e30a77ae359b 318:e84047f29c78
10 10
11 11
12 class ArmInstructionSelector(InstructionSelector): 12 class ArmInstructionSelector(InstructionSelector):
13 """ Instruction selector for the arm architecture """ 13 """ Instruction selector for the arm architecture """
14 def munchExpr(self, e): 14 def munchExpr(self, e):
15 if isinstance(e, ir.Alloc): 15 if isinstance(e, ir.Binop) and e.operation == '+' and \
16 return 0
17 elif isinstance(e, ir.Binop) and e.operation == '+' and \
18 isinstance(e.b, ir.Const) and e.b.value < 8: 16 isinstance(e.b, ir.Const) and e.b.value < 8:
19 a = self.munchExpr(e.a) 17 a = self.munchExpr(e.a)
20 d = self.newTmp() 18 d = self.newTmp()
21 c = Imm3(e.b.value) 19 c = Imm3(e.b.value)
22 self.emit(Add2, others=[c], dst=[d], src=[a]) 20 self.emit(Add2, others=[c], dst=[d], src=[a])
140 self.emit2(jmp_ins) 138 self.emit2(jmp_ins)
141 else: 139 else:
142 raise NotImplementedError('Stmt --> {}'.format(s)) 140 raise NotImplementedError('Stmt --> {}'.format(s))
143 141
144 def move(self, dst, src): 142 def move(self, dst, src):
145 self.emit(Mov2, src=[src], dst=[dst]) 143 self.emit(Mov2, src=[src], dst=[dst], ismove=True)