1 | //===-- orc_rt_macho_tlv.x86-64.s -------------------------------*- ASM -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | // |
9 | // This file is a part of the ORC runtime support library. |
10 | // |
11 | //===----------------------------------------------------------------------===// |
12 | |
13 | // The content of this file is x86_64-only |
14 | #if defined(__x86_64__) |
15 | |
16 | // Save all GRPS except %rsp. |
17 | // This value is also subtracted from %rsp below, despite the fact that %rbp |
18 | // has already been pushed, because we need %rsp to stay 16-byte aligned. |
19 | #define GPR_SAVE_SPACE_SIZE 15 * 8 |
20 | #define FXSAVE64_SAVE_SPACE_SIZE 512 |
21 | #define REGISTER_SAVE_SPACE_SIZE \ |
22 | GPR_SAVE_SPACE_SIZE + FXSAVE64_SAVE_SPACE_SIZE |
23 | |
24 | .text |
25 | |
26 | // returns address of TLV in %rax, all other registers preserved |
27 | .globl __orc_rt_sysv_reenter |
28 | __orc_rt_sysv_reenter: |
29 | pushq %rbp |
30 | movq %rsp, %rbp |
31 | subq $REGISTER_SAVE_SPACE_SIZE, %rsp |
32 | movq %rax, -8(%rbp) |
33 | movq %rbx, -16(%rbp) |
34 | movq %rcx, -24(%rbp) |
35 | movq %rdx, -32(%rbp) |
36 | movq %rsi, -40(%rbp) |
37 | movq %rdi, -48(%rbp) |
38 | movq %r8, -56(%rbp) |
39 | movq %r9, -64(%rbp) |
40 | movq %r10, -72(%rbp) |
41 | movq %r11, -80(%rbp) |
42 | movq %r12, -88(%rbp) |
43 | movq %r13, -96(%rbp) |
44 | movq %r14, -104(%rbp) |
45 | movq %r15, -112(%rbp) |
46 | fxsave64 (%rsp) |
47 | movq 8(%rbp), %rdi |
48 | |
49 | // Load return address and subtract five from it (on the assumption |
50 | // that it's a call instruction). |
51 | subq $5, %rdi |
52 | |
53 | // Call __orc_rt_resolve to look up the implementation corresponding to |
54 | // the calling stub, then store this in x17 (which we'll return to |
55 | // below). |
56 | #if !defined(__APPLE__) |
57 | call __orc_rt_resolve |
58 | #else |
59 | call ___orc_rt_resolve |
60 | #endif |
61 | movq %rax, 8(%rbp) |
62 | fxrstor64 (%rsp) |
63 | movq -112(%rbp), %r15 |
64 | movq -104(%rbp), %r14 |
65 | movq -96(%rbp), %r13 |
66 | movq -88(%rbp), %r12 |
67 | movq -80(%rbp), %r11 |
68 | movq -72(%rbp), %r10 |
69 | movq -64(%rbp), %r9 |
70 | movq -56(%rbp), %r8 |
71 | movq -48(%rbp), %rdi |
72 | movq -40(%rbp), %rsi |
73 | movq -32(%rbp), %rdx |
74 | movq -24(%rbp), %rcx |
75 | movq -16(%rbp), %rbx |
76 | movq -8(%rbp), %rax |
77 | addq $REGISTER_SAVE_SPACE_SIZE, %rsp |
78 | popq %rbp |
79 | ret |
80 | |
81 | #endif // defined(__x86_64__) |
82 | |