source: src/libcfa/concurrency/CtxSwitch-armv7l.S @ c20fafd

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change on this file since c20fafd was ccbf683, checked in by Alan Kennedy <afakenne@…>, 7 years ago

forgot ARM context switch

  • Property mode set to 100644
File size: 1.6 KB
Line 
1        @ 32 bit ARM context switch
2        @ This function assumes that r9 has no special meaning on the platform it's
3        @ being built on.
4        @ If r9 is special, uncomment the following line and it will be left alone
5
6        @ #define R9_SPECIAL
7
8        #define PTR_BYTE        4
9        #define SP_OFFSET       ( 0 * PTR_BYTE )
10        #define FP_OFFSET       ( 1 * PTR_BYTE )
11        #define PC_OFFSET       ( 2 * PTR_BYTE )
12
13        .text
14        .align  2
15        .global CtxSwitch
16        .type   CtxSwitch, %function
17
18CtxSwitch:
19        @ save callee-saved registers: r4-r8, r10, r11, r13(sp) (plus r9 depending on platform specification)
20        @ I've seen reference to 31 registers on 64-bit, if this is the case, more need to be saved
21        @ save thread state registers: r14(lr)
22        @ r12(ip) is intra-procedure-call scratch register, does not need saving between function calls
23
24        #ifdef R9_SPECIAL
25        stmfd r13!, {r4-r8,r10,r11,r14}
26        #else
27        stmfd r13!, {r4-r11,r14}
28        #endif // R9_SPECIAL
29
30        @ save floating point registers: s16-s31
31        vstmdb r13!, {s16-s31}
32
33        @ save frame pointer and stack pointer to outgoing datastructure
34        str sp, [r0, #SP_OFFSET]
35        str fp, [r0, #FP_OFFSET]
36
37        @ restore frame pointer and stack pointer from incoming datastructure
38        ldr fp, [r1, #FP_OFFSET]
39        ldr sp, [r1, #SP_OFFSET]
40
41        @ restore floating point registers: s16-s31
42        vldm r13!, {s16-s31}
43        @ restore r14(lr)
44        @ restore 64-bit extra registers?
45        @ restore callee-saved registers: r4-r8, r10, r11, r13
46
47        #ifdef R9_SPECIAL
48        ldmfd r13!, {r4-r8,r10,r11,r15}
49        #else
50        ldmfd r13!, {r4-r11,r14}    @ loading r14 back into r15 returns
51
52        mov r15, r14
53        #endif // R9_SPECIAL
54       
55        .text
56        .align  2
57        .global CtxInvokeStub
58        .type   CtxInvokeStub, %function
59
60CtxInvokeStub:
61        ldmfd r13!, {r0-r1}
62        mov r15, r1
Note: See TracBrowser for help on using the repository browser.