summaryrefslogtreecommitdiffstats
path: root/testsuite/tests/asmcomp/power-elf.S
blob: 7ff87c5911b78503044b328b30c8bd6f639cfa18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*********************************************************************/
/*                                                                   */
/*                               OCaml                               */
/*                                                                   */
/*           Xavier Leroy, projet Cristal, INRIA Rocquencourt        */
/*                                                                   */
/* Copyright 1996 Institut National de Recherche en Informatique et  */
/* en Automatique.  All rights reserved.  This file is distributed   */
/* under the terms of the Q Public License version 1.0.              */
/*                                                                   */
/*********************************************************************/

/* Save and restore all callee-save registers */
/* GPR 14 at sp+16 ... GPR 31 at sp+84
   FPR 14 at sp+92 ... FPR 31 at sp+228 */

#define Save_callee_save \
        addic   11, 1, 16-4; \
        stwu    14, 4(11); \
        stwu    15, 4(11); \
        stwu    16, 4(11); \
        stwu    17, 4(11); \
        stwu    18, 4(11); \
        stwu    19, 4(11); \
        stwu    20, 4(11); \
        stwu    21, 4(11); \
        stwu    22, 4(11); \
        stwu    23, 4(11); \
        stwu    24, 4(11); \
        stwu    25, 4(11); \
        stwu    26, 4(11); \
        stwu    27, 4(11); \
        stwu    28, 4(11); \
        stwu    29, 4(11); \
        stwu    30, 4(11); \
        stwu    31, 4(11); \
        stfdu   14, 8(11); \
        stfdu   15, 8(11); \
        stfdu   16, 8(11); \
        stfdu   17, 8(11); \
        stfdu   18, 8(11); \
        stfdu   19, 8(11); \
        stfdu   20, 8(11); \
        stfdu   21, 8(11); \
        stfdu   22, 8(11); \
        stfdu   23, 8(11); \
        stfdu   24, 8(11); \
        stfdu   25, 8(11); \
        stfdu   26, 8(11); \
        stfdu   27, 8(11); \
        stfdu   28, 8(11); \
        stfdu   29, 8(11); \
        stfdu   30, 8(11); \
        stfdu   31, 8(11)

#define Restore_callee_save \
        addic   11, 1, 16-4; \
        lwzu    14, 4(11); \
        lwzu    15, 4(11); \
        lwzu    16, 4(11); \
        lwzu    17, 4(11); \
        lwzu    18, 4(11); \
        lwzu    19, 4(11); \
        lwzu    20, 4(11); \
        lwzu    21, 4(11); \
        lwzu    22, 4(11); \
        lwzu    23, 4(11); \
        lwzu    24, 4(11); \
        lwzu    25, 4(11); \
        lwzu    26, 4(11); \
        lwzu    27, 4(11); \
        lwzu    28, 4(11); \
        lwzu    29, 4(11); \
        lwzu    30, 4(11); \
        lwzu    31, 4(11); \
        lfdu    14, 8(11); \
        lfdu    15, 8(11); \
        lfdu    16, 8(11); \
        lfdu    17, 8(11); \
        lfdu    18, 8(11); \
        lfdu    19, 8(11); \
        lfdu    20, 8(11); \
        lfdu    21, 8(11); \
        lfdu    22, 8(11); \
        lfdu    23, 8(11); \
        lfdu    24, 8(11); \
        lfdu    25, 8(11); \
        lfdu    26, 8(11); \
        lfdu    27, 8(11); \
        lfdu    28, 8(11); \
        lfdu    29, 8(11); \
        lfdu    30, 8(11); \
        lfdu    31, 8(11)

        .section ".text"

        .globl  call_gen_code
        .type   call_gen_code, @function
call_gen_code:
    /* Allocate and link stack frame */
        stwu    1, -256(1)
    /* Save return address */
        mflr    0
        stw     0, 256+4(1)
    /* Save all callee-save registers */
        Save_callee_save
    /* Shuffle arguments */
        mtlr    3
        mr 3, 4
        mr 4, 5
        mr 5, 6
        mr 6, 7
    /* Call the function */
        blrl
    /* Restore callee-save registers */
        Restore_callee_save
    /* Reload return address */
        lwz     0, 256+4(1)
        mtlr    0
    /* Return */
        addi    1, 1, 256
        blr

        .globl  caml_c_call
        .type   caml_c_call, @function
caml_c_call:
    /* Jump to C function (address in 11) */
        mtctr   11
        bctr