annotate python/target/armtarget.py @ 327:61c9df5bffce

Changed emulated board to cortex a8 board
author Windel Bouwman
date Sat, 01 Feb 2014 17:21:21 +0100
parents 44f336460c2a
children 6f4753202b9a
rev   line source
261
444b9df2ed99 try to split up code generation
Windel Bouwman
parents: 258
diff changeset
1 import struct
290
7b38782ed496 File moves
Windel Bouwman
parents: 287
diff changeset
2 from .basetarget import Register, Instruction, Target, Label, LabelRef
7b38782ed496 File moves
Windel Bouwman
parents: 287
diff changeset
3 from .basetarget import Imm32, Imm8, Imm7, Imm3
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
4 from .arminstructions import allins, Reg8Op, ArmRegister
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
5 from .arminstructions import Dcd, B
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
6 from .arminstructions import R0, R1, R2, R3, R4, R5, R6, R7, LR, PC, SP
202
f22b431f4113 Added arm add instruction
Windel Bouwman
parents:
diff changeset
7
322
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
8 from .armframe import ArmFrame
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
9 from .arminstructionselector import ArmInstructionSelector
290
7b38782ed496 File moves
Windel Bouwman
parents: 287
diff changeset
10
7b38782ed496 File moves
Windel Bouwman
parents: 287
diff changeset
11 """ ARM target description. """
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 280
diff changeset
12
218
494828a7adf1 added some sort of cache to assembler
Windel Bouwman
parents: 216
diff changeset
13 # TODO: encode this in DSL (domain specific language)
275
6f2423df0675 Fixed serve arm-as
Windel Bouwman
parents: 268
diff changeset
14 # TBD: is this required?
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
15 # TODO: make a difference between armv7 and armv5?
219
1fa3e0050b49 Expanded ad hoc code generator
Windel Bouwman
parents: 218
diff changeset
16
277
046017431c6a Started register allocator
Windel Bouwman
parents: 276
diff changeset
17
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
18 class ArmTarget(Target):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
19 def __init__(self):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
20 super().__init__('arm')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
21 for i in allins:
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
22 self.addInstruction(i)
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
23 # TODO: fix this nicer?
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
24 #setattr(self, i.__name__, i)
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
25 self.check()
322
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
26 self.ins_sel = ArmInstructionSelector()
44f336460c2a Half of use of burg spec for arm
Windel Bouwman
parents: 292
diff changeset
27 self.FrameClass = ArmFrame
277
046017431c6a Started register allocator
Windel Bouwman
parents: 276
diff changeset
28
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
29 def startCode(self, outs):
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
30 """ Emit some startup code in the output stream """
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
31 outs.selectSection('code')
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
32 # assembly glue to make it work:
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
33 # TODO: this must be in source code, not in compiler
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
34 outs.emit(Dcd(Imm32(0x20000678))) # initial SP
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
35 outs.emit(Dcd(Imm32(0x08000009))) # reset vector
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 290
diff changeset
36 outs.emit(B(LabelRef('main')))