| 1 |
.global dumpregs |
| 2 |
.global myfunc |
| 3 |
.type dumpregs,%function |
| 4 |
.type myfunc,%function |
| 5 |
|
| 6 |
#ifdef __LP64__ |
| 7 |
#define PTR_REG(n) x##n |
| 8 |
#else |
| 9 |
#define PTR_REG(n) w##n |
| 10 |
#endif |
| 11 |
|
| 12 |
dumpregs: |
| 13 |
myfunc: |
| 14 |
mov x16, sp |
| 15 |
mov x17, sp |
| 16 |
sub sp, sp, 368 // 352 for registers and 16 for old sp and lr |
| 17 |
|
| 18 |
sub x17, x17, 8 |
| 19 |
st4 { v4.h, v5.h, v6.h, v7.h }[0], [x17] //344 |
| 20 |
sub x17, x17, 8 |
| 21 |
st4 { v0.h, v1.h, v2.h, v3.h }[0], [x17] //336 |
| 22 |
|
| 23 |
stp x8, x9, [x17, #-16]! //320 |
| 24 |
|
| 25 |
stp q6, q7, [x17, #-32]! //288 |
| 26 |
stp q4, q5, [x17, #-32]! //256 |
| 27 |
stp q2, q3, [x17, #-32]! //224 |
| 28 |
stp q0, q1, [x17, #-32]! //192 |
| 29 |
|
| 30 |
stp x6, x7, [x17, #-16]! //176 |
| 31 |
stp x4, x5, [x17, #-16]! //160 |
| 32 |
stp x2, x3, [x17, #-16]! //144 |
| 33 |
stp x0, x1, [x17, #-16]! //128 |
| 34 |
|
| 35 |
stp w6, w7, [x17, #-8]! //120 |
| 36 |
stp w4, w5, [x17, #-8]! //112 |
| 37 |
stp w2, w3, [x17, #-8]! //104 |
| 38 |
stp w0, w1, [x17, #-8]! // 96 |
| 39 |
|
| 40 |
stp s6, s7, [x17, #-8]! // 88 |
| 41 |
stp s4, s5, [x17, #-8]! // 80 |
| 42 |
stp s2, s3, [x17, #-8]! // 72 |
| 43 |
stp s0, s1, [x17, #-8]! // 64 |
| 44 |
|
| 45 |
stp d6, d7, [x17, #-16]! // 48 |
| 46 |
stp d4, d5, [x17, #-16]! // 32 |
| 47 |
stp d2, d3, [x17, #-16]! // 16 |
| 48 |
stp d0, d1, [x17, #-16]! // 0 |
| 49 |
|
| 50 |
add x0, sp, #16 |
| 51 |
stp x16, x30, [x17, #-16]! |
| 52 |
|
| 53 |
adrp x9, which_kind_of_test // determine the type of test |
| 54 |
add x9, x9, :lo12:which_kind_of_test |
| 55 |
ldr w9, [x9, #0] |
| 56 |
cmp w9, #1 |
| 57 |
bgt LABEL_TEST_FUNC_RETURN |
| 58 |
bl testfunc // parameter passing test or va_arg code gen test |
| 59 |
b LABEL_RET |
| 60 |
LABEL_TEST_FUNC_RETURN: |
| 61 |
adrp x9, testfunc_ptr |
| 62 |
add x9, x9, :lo12:testfunc_ptr |
| 63 |
ldr PTR_REG(9), [x9, #0] |
| 64 |
blr x9 // function return value test |
| 65 |
adrp x9, saved_return_address |
| 66 |
add x9, x9, :lo12:saved_return_address |
| 67 |
ldr x9, [x9, #0] |
| 68 |
str x9, [sp, #8] // Update the copy of LR reg saved on stack |
| 69 |
LABEL_RET: |
| 70 |
ldp x0, x30, [sp] |
| 71 |
mov sp, x0 |
| 72 |
ret |
| 73 |
|
| 74 |
.weak testfunc |
| 75 |
.weak testfunc_ptr |
| 76 |
.weak saved_return_address |