340
|
1
|
|
2 from .basetarget import Register
|
|
3
|
|
4 class ArmRegister(Register):
|
|
5 def __init__(self, num, name):
|
|
6 super().__init__(name)
|
|
7 self.num = num
|
|
8
|
|
9 def __repr__(self):
|
|
10 return self.name
|
|
11
|
|
12
|
|
13 class Reg8Op(ArmRegister):
|
|
14 pass
|
|
15
|
|
16
|
|
17 class Reg16Op(ArmRegister):
|
|
18 pass
|
|
19
|
341
|
20 def get_register(n):
|
|
21 for x in registers:
|
|
22 if x.num == n:
|
|
23 return x
|
|
24 raise Exception()
|
|
25
|
|
26 def register_range(a, b):
|
|
27 """ Return set of registers from a to b """
|
|
28 assert a.num < b.num
|
|
29 return {get_register(n) for n in range(a.num, b.num + 1)}
|
|
30
|
340
|
31
|
|
32 R0 = Reg8Op(0, 'r0')
|
|
33 R1 = Reg8Op(1, 'r1')
|
|
34 R2 = Reg8Op(2, 'r2')
|
|
35 R3 = Reg8Op(3, 'r3')
|
|
36 R4 = Reg8Op(4, 'r4')
|
|
37 R5 = Reg8Op(5, 'r5')
|
|
38 R6 = Reg8Op(6, 'r6')
|
|
39 R7 = Reg8Op(7, 'r7')
|
341
|
40 R8 = Reg8Op(8, 'r8')
|
|
41 R9 = Reg8Op(9, 'r9')
|
|
42 R10 = Reg8Op(10, 'r10')
|
|
43 R11 = Reg8Op(11, 'r11')
|
|
44 R12 = Reg8Op(12, 'r12')
|
340
|
45
|
|
46 # Other registers:
|
|
47 # TODO
|
|
48 SP = ArmRegister(13, 'sp')
|
|
49 LR = ArmRegister(14, 'lr')
|
|
50 PC = ArmRegister(15, 'pc')
|
|
51
|
|
52 registers = [R0, R1, R2, R3, R4, R5, R6, R7, SP, LR, PC]
|