File: sysv_reenter.x86-64.S

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (81 lines) | stat: -rw-r--r-- 3,174 bytes parent folder | download | duplicates (9)
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
//===-- orc_rt_macho_tlv.x86-64.s -------------------------------*- ASM -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is a part of the ORC runtime support library.
//
//===----------------------------------------------------------------------===//

// The content of this file is x86_64-only
#if defined(__x86_64__)

// Save all GRPS except %rsp.
// This value is also subtracted from %rsp below, despite the fact that %rbp
// has already been pushed, because we need %rsp to stay 16-byte aligned.
#define GPR_SAVE_SPACE_SIZE             15 * 8
#define FXSAVE64_SAVE_SPACE_SIZE        512
#define REGISTER_SAVE_SPACE_SIZE        \
        GPR_SAVE_SPACE_SIZE + FXSAVE64_SAVE_SPACE_SIZE

        .text

        // returns address of TLV in %rax, all other registers preserved
        .globl __orc_rt_sysv_reenter
__orc_rt_sysv_reenter:
        pushq           %rbp
        movq            %rsp,        %rbp
        subq            $REGISTER_SAVE_SPACE_SIZE, %rsp
        movq            %rax,     -8(%rbp)
        movq            %rbx,    -16(%rbp)
        movq            %rcx,    -24(%rbp)
        movq            %rdx,    -32(%rbp)
        movq            %rsi,    -40(%rbp)
        movq            %rdi,    -48(%rbp)
        movq            %r8,     -56(%rbp)
        movq            %r9,     -64(%rbp)
        movq            %r10,    -72(%rbp)
        movq            %r11,    -80(%rbp)
        movq            %r12,    -88(%rbp)
        movq            %r13,    -96(%rbp)
        movq            %r14,   -104(%rbp)
        movq            %r15,   -112(%rbp)
        fxsave64        (%rsp)
        movq            8(%rbp), %rdi

        // Load return address and subtract five from it (on the assumption
        // that it's a call instruction).
        subq            $5, %rdi

        // Call __orc_rt_resolve to look up the implementation corresponding to
        // the calling stub, then store this in x17 (which we'll return to
        // below).
#if !defined(__APPLE__)
        call            __orc_rt_resolve
#else
        call            ___orc_rt_resolve
#endif
        movq            %rax,   8(%rbp)
        fxrstor64       (%rsp)
        movq            -112(%rbp),     %r15
        movq            -104(%rbp),     %r14
        movq            -96(%rbp),      %r13
        movq            -88(%rbp),      %r12
        movq            -80(%rbp),      %r11
        movq            -72(%rbp),      %r10
        movq            -64(%rbp),      %r9
        movq            -56(%rbp),      %r8
        movq            -48(%rbp),      %rdi
        movq            -40(%rbp),      %rsi
        movq            -32(%rbp),      %rdx
        movq            -24(%rbp),      %rcx
        movq            -16(%rbp),      %rbx
        movq            -8(%rbp),       %rax
        addq            $REGISTER_SAVE_SPACE_SIZE, %rsp
        popq            %rbp
        ret

#endif // defined(__x86_64__)