comparison python/ppci/target/arm/__init__.py @ 375:19eacf4f7270

Started on memory manager
author Windel Bouwman
date Sun, 23 Mar 2014 15:44:06 +0100
parents c49459768aaa
children 6df89163e114
comparison
equal deleted inserted replaced
374:72a3b646d543 375:19eacf4f7270
7 from .instructions import Dcd, Mov, Mov1, Add, Add2, Sub, Orr1, Mul, Mov2, Add1, Mul1 7 from .instructions import Dcd, Mov, Mov1, Add, Add2, Sub, Orr1, Mul, Mov2, Add1, Mul1
8 from .instructions import Lsr1, Lsl1, And1, Sub1 8 from .instructions import Lsr1, Lsl1, And1, Sub1
9 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2 9 from .instructions import B, Bl, Ble, Bgt, Beq, Blt, Cmp, Cmp2
10 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr 10 from .instructions import Push, Pop, Str, Ldr, Ldr3, Str1, Ldr1, Adr
11 from .instructions import Mcr, Mrc 11 from .instructions import Mcr, Mrc
12 from .instructions import LdrPseudo
12 from .selector import ArmInstructionSelector 13 from .selector import ArmInstructionSelector
13 from .frame import ArmFrame 14 from .frame import ArmFrame
14 15
15 class ArmTarget(Target): 16 class ArmTarget(Target):
16 def __init__(self): 17 def __init__(self):
152 lambda rhs: Ldr(rhs[1], rhs[4], rhs[6])) 153 lambda rhs: Ldr(rhs[1], rhs[4], rhs[6]))
153 154
154 self.add_instruction(['ldr', 'reg', ',', 'ID'], 155 self.add_instruction(['ldr', 'reg', ',', 'ID'],
155 lambda rhs: Ldr(rhs[1], rhs[3].val)) 156 lambda rhs: Ldr(rhs[1], rhs[3].val))
156 157
158 # This is a pseudo instruction:
159 self.add_instruction(['ldr', 'reg', ',', '=', 'ID'],
160 lambda rhs: LdrPseudo(rhs[1], rhs[4].val))
161
157 self.add_keyword('str') 162 self.add_keyword('str')
158 self.add_instruction(['str', 'reg', ',', '[', 'reg', ',', 'imm8', ']'], 163 self.add_instruction(['str', 'reg', ',', '[', 'reg', ',', 'imm8', ']'],
159 lambda rhs: Str(rhs[1], rhs[4], rhs[6])) 164 lambda rhs: Str(rhs[1], rhs[4], rhs[6]))
160 165
161 self.add_instruction(['str', 'reg', ',', '[', 'reg', ',', 'reg', ']'], 166 self.add_instruction(['str', 'reg', ',', '[', 'reg', ',', 'reg', ']'],
162 lambda rhs: Str(rhs[1], rhs[4], rhs[6])) 167 lambda rhs: Str(rhs[1], rhs[4], rhs[6]))
163 168
164 self.add_keyword('adr') 169 self.add_keyword('adr')
165 self.add_instruction(['adr', 'reg', ',', 'ID'], 170 self.add_instruction(['adr', 'reg', ',', 'ID'],
166 lambda rhs: Adr(rhs[1], rhs[3].val)) 171 lambda rhs: Adr(rhs[1], rhs[3].val))
172
167 173
168 # Register list grammar: 174 # Register list grammar:
169 self.add_rule('reg_list', ['{', 'reg_list_inner', '}'], 175 self.add_rule('reg_list', ['{', 'reg_list_inner', '}'],
170 lambda rhs: rhs[1]) 176 lambda rhs: rhs[1])
171 self.add_rule('reg_list_inner', ['reg_or_range'], 177 self.add_rule('reg_list_inner', ['reg_or_range'],