summaryrefslogtreecommitdiff
path: root/testsuite/tests/asmcomp/ia64.S
blob: 49de1b194777d78818e1723c3b4b1c928f41c007 (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
/***********************************************************************/
/*                                                                     */
/*                           Objective Caml                            */
/*                                                                     */
/*            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.               */
/*                                                                     */
/***********************************************************************/

/* $Id: ia64.S 3573 2001-07-12 12:54:24Z doligez $ */

#define ST8OFF(a,b,d) st8 [a] = b, d
#define LD8OFF(a,b,d) ld8 a = [b], d
#define STFDOFF(a,b,d) stfd [a] = b, d
#define LDFDOFF(a,b,d) ldfd a = [b], d
#define STFSPILLOFF(a,b,d) stf.spill [a] = b, d
#define LDFFILLOFF(a,b,d) ldf.fill a = [b], d

        .text
        .align 16

        .global call_gen_code#
        .proc   call_gen_code#

call_gen_code:
        /* Allocate 64 "out" registers (for the Caml code) and no locals */
        alloc   r3 = ar.pfs, 0, 0, 64, 0

        /* Save PFS, return address and GP on stack */
        add     sp = -368, sp ;;
        add     r2 = 16, sp ;;
        ST8OFF(r2,r3,8) ;;
        mov     r3 = b0 ;;
        ST8OFF(r2,r3,8) ;;
        ST8OFF(r2,gp,8) ;;

        /* Save predicates on stack */
        mov     r3 = pr ;;
        st8     [r2] = r3

        /* Save callee-save floating-point registers on stack */
        add     r2 = 48, sp
        add     r3 = 64, sp ;;
        STFSPILLOFF(r2,f2,16) ;;
        STFSPILLOFF(r3,f3,16) ;;
        STFSPILLOFF(r2,f4,16) ;;
        STFSPILLOFF(r3,f5,16) ;;
        STFSPILLOFF(r2,f16,16) ;;
        STFSPILLOFF(r3,f17,16) ;;
        STFSPILLOFF(r2,f18,16) ;;
        STFSPILLOFF(r3,f19,16) ;;
        STFSPILLOFF(r2,f20,16) ;;
        STFSPILLOFF(r3,f21,16) ;;
        STFSPILLOFF(r2,f22,16) ;;
        STFSPILLOFF(r3,f23,16) ;;
        STFSPILLOFF(r2,f24,16) ;;
        STFSPILLOFF(r3,f25,16) ;;
        STFSPILLOFF(r2,f26,16) ;;
        STFSPILLOFF(r3,f27,16) ;;
        STFSPILLOFF(r2,f28,16) ;;
        STFSPILLOFF(r3,f29,16) ;;
        STFSPILLOFF(r2,f30,16) ;;
        STFSPILLOFF(r3,f31,16) ;;

        /* Recover entry point and gp from the function pointer in in0 */
        LD8OFF(r2,r32,8) ;;
        ld8     r3 = [r32] ;;
        mov     b6 = r2
        mov     gp = r3 ;;

        /* Shift arguments r33 ... r35 to r32 ... r34 */
        mov     r32 = r33
        mov     r33 = r34
        mov     r34 = r35

        /* Do the call */
        br.call.sptk b0 = b6 ;;

        /* Restore the saved floating-point registers */
        add     r2 = 48, sp
        add     r3 = 64, sp ;;
        LDFFILLOFF(f2,r2,16) ;;
        LDFFILLOFF(f3,r3,16) ;;
        LDFFILLOFF(f4,r2,16) ;;
        LDFFILLOFF(f5,r3,16) ;;
        LDFFILLOFF(f16,r2,16) ;;
        LDFFILLOFF(f17,r3,16) ;;
        LDFFILLOFF(f18,r2,16) ;;
        LDFFILLOFF(f19,r3,16) ;;
        LDFFILLOFF(f20,r2,16) ;;
        LDFFILLOFF(f21,r3,16) ;;
        LDFFILLOFF(f22,r2,16) ;;
        LDFFILLOFF(f23,r3,16) ;;
        LDFFILLOFF(f24,r2,16) ;;
        LDFFILLOFF(f25,r3,16) ;;
        LDFFILLOFF(f26,r2,16) ;;
        LDFFILLOFF(f27,r3,16) ;;
        LDFFILLOFF(f28,r2,16) ;;
        LDFFILLOFF(f29,r3,16) ;;
        LDFFILLOFF(f30,r2,16) ;;
        LDFFILLOFF(f31,r3,16) ;;

        /* Restore gp, predicates and return */
        add     r2 = 16, sp ;;
        LD8OFF(r3,r2,8) ;;
        mov     ar.pfs = r3
        LD8OFF(r3,r2,8) ;;
        mov     b0 = r3
        LD8OFF(gp,r2,8) ;;
        LD8OFF(r3,r2,8) ;;
        mov     pr = r3, -1

        br.ret.sptk.many b0 ;;

        .endp   call_gen_code#