1*700637cbSDimitry Andric//===-- sysv_reenter.arm64.s ------------------------------------*- ASM -*-===// 2*700637cbSDimitry Andric// 3*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 5*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6*700637cbSDimitry Andric// 7*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 8*700637cbSDimitry Andric// 9*700637cbSDimitry Andric// This file is a part of the ORC runtime support library. 10*700637cbSDimitry Andric// 11*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric// The content of this file is arm64-only 14*700637cbSDimitry Andric#if defined(__arm64__) || defined(__aarch64__) 15*700637cbSDimitry Andric 16*700637cbSDimitry Andric .text 17*700637cbSDimitry Andric 18*700637cbSDimitry Andric // Saves GPRs, calls __orc_rt_resolve 19*700637cbSDimitry Andric .globl __orc_rt_sysv_reenter 20*700637cbSDimitry Andric__orc_rt_sysv_reenter: 21*700637cbSDimitry Andric // Save register state, set up new stack frome. 22*700637cbSDimitry Andric stp x27, x28, [sp, #-16]! 23*700637cbSDimitry Andric stp x25, x26, [sp, #-16]! 24*700637cbSDimitry Andric stp x23, x24, [sp, #-16]! 25*700637cbSDimitry Andric stp x21, x22, [sp, #-16]! 26*700637cbSDimitry Andric stp x19, x20, [sp, #-16]! 27*700637cbSDimitry Andric stp x14, x15, [sp, #-16]! 28*700637cbSDimitry Andric stp x12, x13, [sp, #-16]! 29*700637cbSDimitry Andric stp x10, x11, [sp, #-16]! 30*700637cbSDimitry Andric stp x8, x9, [sp, #-16]! 31*700637cbSDimitry Andric stp x6, x7, [sp, #-16]! 32*700637cbSDimitry Andric stp x4, x5, [sp, #-16]! 33*700637cbSDimitry Andric stp x2, x3, [sp, #-16]! 34*700637cbSDimitry Andric stp x0, x1, [sp, #-16]! 35*700637cbSDimitry Andric stp q30, q31, [sp, #-32]! 36*700637cbSDimitry Andric stp q28, q29, [sp, #-32]! 37*700637cbSDimitry Andric stp q26, q27, [sp, #-32]! 38*700637cbSDimitry Andric stp q24, q25, [sp, #-32]! 39*700637cbSDimitry Andric stp q22, q23, [sp, #-32]! 40*700637cbSDimitry Andric stp q20, q21, [sp, #-32]! 41*700637cbSDimitry Andric stp q18, q19, [sp, #-32]! 42*700637cbSDimitry Andric stp q16, q17, [sp, #-32]! 43*700637cbSDimitry Andric stp q14, q15, [sp, #-32]! 44*700637cbSDimitry Andric stp q12, q13, [sp, #-32]! 45*700637cbSDimitry Andric stp q10, q11, [sp, #-32]! 46*700637cbSDimitry Andric stp q8, q9, [sp, #-32]! 47*700637cbSDimitry Andric stp q6, q7, [sp, #-32]! 48*700637cbSDimitry Andric stp q4, q5, [sp, #-32]! 49*700637cbSDimitry Andric stp q2, q3, [sp, #-32]! 50*700637cbSDimitry Andric stp q0, q1, [sp, #-32]! 51*700637cbSDimitry Andric 52*700637cbSDimitry Andric // Look up the return address and subtract 8 from it (on the assumption 53*700637cbSDimitry Andric // that it's a standard arm64 reentry trampoline) to get back the 54*700637cbSDimitry Andric // trampoline's address. 55*700637cbSDimitry Andric sub x0, x30, #8 56*700637cbSDimitry Andric 57*700637cbSDimitry Andric // Call __orc_rt_resolve to look up the implementation corresponding to 58*700637cbSDimitry Andric // the calling stub, then store this in x17 (which we'll return to 59*700637cbSDimitry Andric // below). 60*700637cbSDimitry Andric#if !defined(__APPLE__) 61*700637cbSDimitry Andric bl __orc_rt_resolve 62*700637cbSDimitry Andric#else 63*700637cbSDimitry Andric bl ___orc_rt_resolve 64*700637cbSDimitry Andric#endif 65*700637cbSDimitry Andric mov x17, x0 66*700637cbSDimitry Andric 67*700637cbSDimitry Andric // Restore the register state. 68*700637cbSDimitry Andric ldp q0, q1, [sp], #32 69*700637cbSDimitry Andric ldp q2, q3, [sp], #32 70*700637cbSDimitry Andric ldp q4, q5, [sp], #32 71*700637cbSDimitry Andric ldp q6, q7, [sp], #32 72*700637cbSDimitry Andric ldp q8, q9, [sp], #32 73*700637cbSDimitry Andric ldp q10, q11, [sp], #32 74*700637cbSDimitry Andric ldp q12, q13, [sp], #32 75*700637cbSDimitry Andric ldp q14, q15, [sp], #32 76*700637cbSDimitry Andric ldp q16, q17, [sp], #32 77*700637cbSDimitry Andric ldp q18, q19, [sp], #32 78*700637cbSDimitry Andric ldp q20, q21, [sp], #32 79*700637cbSDimitry Andric ldp q22, q23, [sp], #32 80*700637cbSDimitry Andric ldp q24, q25, [sp], #32 81*700637cbSDimitry Andric ldp q26, q27, [sp], #32 82*700637cbSDimitry Andric ldp q28, q29, [sp], #32 83*700637cbSDimitry Andric ldp q30, q31, [sp], #32 84*700637cbSDimitry Andric ldp x0, x1, [sp], #16 85*700637cbSDimitry Andric ldp x2, x3, [sp], #16 86*700637cbSDimitry Andric ldp x4, x5, [sp], #16 87*700637cbSDimitry Andric ldp x6, x7, [sp], #16 88*700637cbSDimitry Andric ldp x8, x9, [sp], #16 89*700637cbSDimitry Andric ldp x10, x11, [sp], #16 90*700637cbSDimitry Andric ldp x12, x13, [sp], #16 91*700637cbSDimitry Andric ldp x14, x15, [sp], #16 92*700637cbSDimitry Andric ldp x19, x20, [sp], #16 93*700637cbSDimitry Andric ldp x21, x22, [sp], #16 94*700637cbSDimitry Andric ldp x23, x24, [sp], #16 95*700637cbSDimitry Andric ldp x25, x26, [sp], #16 96*700637cbSDimitry Andric ldp x27, x28, [sp], #16 97*700637cbSDimitry Andric ldp x29, x30, [sp], #16 98*700637cbSDimitry Andric 99*700637cbSDimitry Andric // Return to the function implementation (rather than the stub). 100*700637cbSDimitry Andric ret x17 101*700637cbSDimitry Andric 102*700637cbSDimitry Andric#endif // defined(__arm64__) || defined(__aarch64__) 103