| 1 | //===-- orc_rt_elfnix_tls.mips.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 | #if defined(__mips__) |
| 14 | |
| 15 | #if _MIPS_SIM == _ABI64 |
| 16 | #define PTR_ADDIU daddiu |
| 17 | #define PTR_LA dla |
| 18 | #else |
| 19 | #define PTR_ADDIU addiu |
| 20 | #define PTR_LA la |
| 21 | #endif |
| 22 | |
| 23 | .text |
| 24 | .option pic2 |
| 25 | |
| 26 | // Returns the TLS address in $2, passing the thread pointer in $5. |
| 27 | .globl ___orc_rt_elfnix_tls_get_addr |
| 28 | ___orc_rt_elfnix_tls_get_addr: |
| 29 | #if _MIPS_SIM == _ABIO32 |
| 30 | .set noreorder |
| 31 | .cpload $25 |
| 32 | .set reorder |
| 33 | PTR_ADDIU $sp, $sp, -24 |
| 34 | sw $ra, 20($sp) |
| 35 | #else |
| 36 | PTR_ADDIU $sp, $sp, -16 |
| 37 | .cpsetup $25, 0, ___orc_rt_elfnix_tls_get_addr |
| 38 | sd $ra, 8($sp) |
| 39 | #endif |
| 40 | |
| 41 | .set push |
| 42 | #if !defined(__mips_isa_rev) || __mips_isa_rev < 2 |
| 43 | // Linux trap-and-emulates rdhwr on pre-r2 CPUs, so it is always valid. |
| 44 | .set mips32r2 |
| 45 | #endif |
| 46 | rdhwr $5, $29 |
| 47 | .set pop |
| 48 | |
| 49 | PTR_LA $25, __orc_rt_elfnix_tls_get_addr_impl |
| 50 | jalr $25 |
| 51 | |
| 52 | #if _MIPS_SIM == _ABIO32 |
| 53 | lw $ra, 20($sp) |
| 54 | PTR_ADDIU $sp, $sp, 24 |
| 55 | #else |
| 56 | .cpreturn |
| 57 | ld $ra, 8($sp) |
| 58 | PTR_ADDIU $sp, $sp, 16 |
| 59 | #endif |
| 60 | jr $ra |
| 61 | |
| 62 | #endif // defined(__mips__) |
| 63 | |