1 ; Test each TLS size option
2 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -tls-size=12 < %s | FileCheck %s --check-prefix=CHECK-12
3 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -tls-size=12 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-12-RELOC %s
4 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny -tls-size=24 < %s | FileCheck %s --check-prefix=CHECK-24
5 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny -tls-size=24 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
6 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-32
7 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
8 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=large -tls-size=48 < %s | FileCheck %s --check-prefix=CHECK-48
9 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=large -tls-size=48 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-48-RELOC %s
11 ; Test the maximum TLS size for each code model (fallback to a smaller size from the specified size)
12 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-32
13 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
14 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny -tls-size=32 < %s | FileCheck %s --check-prefix=CHECK-24
15 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny -tls-size=32 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
16 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small -tls-size=48 < %s | FileCheck %s --check-prefix=CHECK-32
17 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small -tls-size=48 | llvm-objdump -r - | FileCheck --check-prefix=CHECK-32-RELOC %s
19 ; Test the default TLS size for each code model
20 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding < %s | FileCheck --check-prefix=CHECK-24 %s
21 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
22 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=tiny < %s | FileCheck %s --check-prefix=CHECK-24
23 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=tiny | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
24 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=small < %s | FileCheck %s --check-prefix=CHECK-24
25 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=small | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
26 ; RUN: llc -mtriple=arm64-none-linux-gnu -verify-machineinstrs -show-mc-encoding -code-model=large < %s | FileCheck %s --check-prefix=CHECK-24
27 ; RUN: llc -mtriple=arm64-none-linux-gnu -filetype=obj < %s -code-model=large | llvm-objdump -r - | FileCheck --check-prefix=CHECK-24-RELOC %s
29 @local_exec_var = thread_local(localexec) global i32 0
31 define i32 @test_local_exec() {
32 ; CHECK-LABEL: test_local_exec:
33 %val = load i32, ptr @local_exec_var
35 ; CHECK-12: mrs x[[R1:[0-9]+]], TPIDR_EL0
36 ; CHECK-12: add x[[R2:[0-9]+]], x[[R1]], :tprel_lo12:local_exec_var
37 ; CHECK-12: ldr w0, [x[[R2]]]
39 ; CHECK-12-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12
41 ; CHECK-24: mrs x[[R1:[0-9]+]], TPIDR_EL0
42 ; CHECK-24: add x[[R2:[0-9]+]], x[[R1]], :tprel_hi12:local_exec_var
43 ; CHECK-24: add x[[R3:[0-9]+]], x[[R2]], :tprel_lo12_nc:local_exec_var
44 ; CHECK-24: ldr w0, [x[[R3]]]
46 ; CHECK-24-RELOC: R_AARCH64_TLSLE_ADD_TPREL_HI12
47 ; CHECK-24-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12_NC
49 ; CHECK-32: movz x[[R2:[0-9]+]], #:tprel_g1:local_exec_var
50 ; CHECK-32: mrs x[[R1:[0-9]+]], TPIDR_EL0
51 ; CHECK-32: movk x[[R2]], #:tprel_g0_nc:local_exec_var
52 ; CHECK-32: ldr w0, [x[[R1]], x[[R2]]]
54 ; CHECK-32-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1
55 ; CHECK-32-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC
57 ; CHECK-48: movz x[[R2:[0-9]+]], #:tprel_g2:local_exec_var
58 ; CHECK-48: mrs x[[R1:[0-9]+]], TPIDR_EL0
59 ; CHECK-48: movk x[[R2]], #:tprel_g1_nc:local_exec_var
60 ; CHECK-48: movk x[[R2]], #:tprel_g0_nc:local_exec_var
61 ; CHECK-48: ldr w0, [x[[R1]], x[[R2]]]
63 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G2
64 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
65 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC
69 define ptr @test_local_exec_addr() {
70 ; CHECK-LABEL: test_local_exec_addr:
71 ret ptr @local_exec_var
73 ; CHECK-12: mrs x[[R1:[0-9]+]], TPIDR_EL0
74 ; CHECK-12: add x0, x[[R1]], :tprel_lo12:local_exec_var
77 ; CHECK-12-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12
79 ; CHECK-24: mrs x[[R1:[0-9]+]], TPIDR_EL0
80 ; CHECK-24: add x[[R2:[0-9]+]], x[[R1]], :tprel_hi12:local_exec_var
81 ; CHECK-24: add x0, x[[R2]], :tprel_lo12_nc:local_exec_var
84 ; CHECK-24-RELOC: R_AARCH64_TLSLE_ADD_TPREL_HI12
85 ; CHECK-24-RELOC: R_AARCH64_TLSLE_ADD_TPREL_LO12_NC
87 ; CHECK-32: movz x[[R2:[0-9]+]], #:tprel_g1:local_exec_var
88 ; CHECK-32: mrs x[[R1:[0-9]+]], TPIDR_EL0
89 ; CHECK-32: movk x[[R2]], #:tprel_g0_nc:local_exec_var
90 ; CHECK-32: add x0, x[[R1]], x[[R2]]
93 ; CHECK-32-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1
94 ; CHECK-32-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC
96 ; CHECK-48: movz x[[R2:[0-9]+]], #:tprel_g2:local_exec_var
97 ; CHECK-48: mrs x[[R1:[0-9]+]], TPIDR_EL0
98 ; CHECK-48: movk x[[R2]], #:tprel_g1_nc:local_exec_var
99 ; CHECK-48: movk x[[R2]], #:tprel_g0_nc:local_exec_var
100 ; CHECK-48: add x0, x[[R1]], x[[R2]]
103 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G2
104 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G1_NC
105 ; CHECK-48-RELOC: R_AARCH64_TLSLE_MOVW_TPREL_G0_NC