| 1 | //===-- orc_rt_elfnix_tls_systemz.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 special thing about the s390 TLS ABI is that we do not have the |
| 14 | // standard __tls_get_addr function but the __tls_get_offset function |
| 15 | // which differs in two important aspects: |
| 16 | // 1) __tls_get_offset gets a got offset instead of a pointer to the |
| 17 | // tls_index structure |
| 18 | // 2) __tls_get_offset returns the offset of the requested variable to |
| 19 | // the thread descriptor instead of a pointer to the variable. |
| 20 | |
| 21 | // The content of this file is systemz-only |
| 22 | |
| 23 | #if defined(__s390x__) |
| 24 | |
| 25 | .text |
| 26 | // returns offset of TLV from TP in %r2. |
| 27 | .globl ___orc_rt_elfnix_tls_get_offset |
| 28 | ___orc_rt_elfnix_tls_get_offset: |
| 29 | stmg %r14, %r15, 112(%r15) |
| 30 | aghi %r15, -160 |
| 31 | // Pass pointer to tls_index. |
| 32 | la %r2, 0(%r2, %r12) |
| 33 | brasl %r14, __orc_rt_elfnix_tls_get_addr_impl |
| 34 | // Return offset from TP. |
| 35 | ear %r0, %a0 |
| 36 | sllg %r0, %r0, 32 |
| 37 | ear %r0, %a1 |
| 38 | sgr %r2, %r0 |
| 39 | lmg %r14, %r15, 272(%r15) |
| 40 | br %r14 |
| 41 | |
| 42 | #endif // defined(__s390x__) |
| 43 | |