comparison python/ppci/target/arm/__init__.py @ 356:52492b304adf

Added newline to print
author Windel Bouwman
date Fri, 14 Mar 2014 13:02:16 +0100
parents 5477e499b039
children 818be710e13d
comparison
equal deleted inserted replaced
355:c2ddc8a36f5e 356:52492b304adf
3 from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7 3 from ..arm.registers import R0, R1, R2, R3, R4, R5, R6, R7
4 from ..arm.registers import R8, R9, R10, R11, R12, SP, LR, PC 4 from ..arm.registers import R8, R9, R10, R11, R12, SP, LR, PC
5 from ..arm.registers import register_range 5 from ..arm.registers import register_range
6 6
7 from .instructions import Dcd, Mov, Add, Sub, Orr1, Mul, Mov2, Add1, Mul1 7 from .instructions import Dcd, Mov, Add, Sub, Orr1, Mul, Mov2, Add1, Mul1
8 from .instructions import Lsr1, Lsl1, And1, Sub1
8 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2 9 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2
9 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr 10 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr
10 from .selector import ArmInstructionSelector 11 from .selector import ArmInstructionSelector
11 from .frame import ArmFrame 12 from .frame import ArmFrame
12 13
22 self.add_lowering(Ldr1, lambda im: Ldr1(im.dst[0], im.src[0], im.others[0])) 23 self.add_lowering(Ldr1, lambda im: Ldr1(im.dst[0], im.src[0], im.others[0]))
23 self.add_lowering(Adr, lambda im: Adr(im.dst[0], im.others[0])) 24 self.add_lowering(Adr, lambda im: Adr(im.dst[0], im.others[0]))
24 self.add_lowering(Mov2, lambda im: Mov2(im.dst[0], im.src[0])) 25 self.add_lowering(Mov2, lambda im: Mov2(im.dst[0], im.src[0]))
25 self.add_lowering(Cmp2, lambda im: Cmp2(im.src[0], im.src[1])) 26 self.add_lowering(Cmp2, lambda im: Cmp2(im.src[0], im.src[1]))
26 self.add_lowering(Add1, lambda im: Add1(im.dst[0], im.src[0], im.src[1])) 27 self.add_lowering(Add1, lambda im: Add1(im.dst[0], im.src[0], im.src[1]))
28 self.add_lowering(Sub1, lambda im: Sub1(im.dst[0], im.src[0], im.src[1]))
27 self.add_lowering(Mul1, lambda im: Mul1(im.dst[0], im.src[0], im.src[1])) 29 self.add_lowering(Mul1, lambda im: Mul1(im.dst[0], im.src[0], im.src[1]))
30 self.add_lowering(Lsr1, lambda im: Lsr1(im.dst[0], im.src[0], im.src[1]))
31 self.add_lowering(And1, lambda im: And1(im.dst[0], im.src[0], im.src[1]))
28 32
29 def make_parser(self): 33 def make_parser(self):
30 # Assembly grammar: 34 # Assembly grammar:
31 self.add_keyword('r0') 35 self.add_keyword('r0')
32 self.add_keyword('r1') 36 self.add_keyword('r1')
97 101
98 self.add_keyword('orr') 102 self.add_keyword('orr')
99 self.add_instruction(['orr', 'reg', ',', 'reg', ',', 'reg'], 103 self.add_instruction(['orr', 'reg', ',', 'reg', ',', 'reg'],
100 lambda rhs: Orr1(rhs[1], rhs[3], rhs[5])) 104 lambda rhs: Orr1(rhs[1], rhs[3], rhs[5]))
101 105
106 self.add_keyword('and')
107 self.add_instruction(['and', 'reg', ',', 'reg', ',', 'reg'],
108 lambda rhs: And1(rhs[1], rhs[3], rhs[5]))
109
110 self.add_keyword('lsr')
111 self.add_instruction(['lsr', 'reg', ',', 'reg', ',', 'reg'],
112 lambda rhs: Lsr1(rhs[1], rhs[3], rhs[5]))
113
114 self.add_keyword('lsl')
115 self.add_instruction(['lsl', 'reg', ',', 'reg', ',', 'reg'],
116 lambda rhs: Lsl1(rhs[1], rhs[3], rhs[5]))
117
102 118
103 # Jumping: 119 # Jumping:
104 self.add_keyword('b') 120 self.add_keyword('b')
105 self.add_instruction(['b', 'ID'], lambda rhs: B(rhs[1].val)) 121 self.add_instruction(['b', 'ID'], lambda rhs: B(rhs[1].val))
106 self.add_keyword('ble') 122 self.add_keyword('ble')