• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic < %s | FileCheck %s
2; RUN: llc -mtriple=aarch64-none-linux-gnu -relocation-model=pic -filetype=obj < %s | llvm-objdump -r - | FileCheck --check-prefix=CHECK-ELF %s
3
4@var_simple = hidden global i32 0
5@var_got = global i32 0
6@var_tlsgd = thread_local global i32 0
7@var_tlsld = thread_local(localdynamic) global i32 0
8@var_tlsie = thread_local(initialexec) global i32 0
9@var_tlsle = thread_local(localexec) global i32 0
10
11define void @test_inline_modifier_L() nounwind {
12; CHECK-LABEL: test_inline_modifier_L:
13  call void asm sideeffect "add x0, x0, ${0:L}", "S,~{x0}"(i32* @var_simple)
14  call void asm sideeffect "ldr x0, [x0, ${0:L}]", "S,~{x0}"(i32* @var_got)
15  call void asm sideeffect "add x0, x0, ${0:L}", "S,~{x0}"(i32* @var_tlsgd)
16  call void asm sideeffect "add x0, x0, ${0:L}", "S,~{x0}"(i32* @var_tlsld)
17  call void asm sideeffect "ldr x0, [x0, ${0:L}]", "S,~{x0}"(i32* @var_tlsie)
18  call void asm sideeffect "add x0, x0, ${0:L}", "S,~{x0}"(i32* @var_tlsle)
19; CHECK: add x0, x0, #:lo12:var_simple
20; CHECK: ldr x0, [x0, #:got_lo12:var_got]
21; CHECK: add x0, x0, #:tlsdesc_lo12:var_tlsgd
22; CHECK: add x0, x0, #:dtprel_lo12:var_tlsld
23; CHECK: ldr x0, [x0, #:gottprel_lo12:var_tlsie]
24; CHECK: add x0, x0, #:tprel_lo12:var_tlsle
25
26; CHECK-ELF: R_AARCH64_ADD_ABS_LO12_NC var_simple
27; CHECK-ELF: R_AARCH64_LD64_GOT_LO12_NC var_got
28; CHECK-ELF: R_AARCH64_TLSDESC_ADD_LO12_NC var_tlsgd
29; CHECK-ELF: R_AARCH64_TLSLD_ADD_DTPREL_LO12 var_tlsld
30; CHECK-ELF: R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC var_tlsie
31; CHECK-ELF: R_AARCH64_TLSLE_ADD_TPREL_LO12 var_tlsle
32
33  ret void
34}
35
36define void @test_inline_modifier_G() nounwind {
37; CHECK-LABEL: test_inline_modifier_G:
38  call void asm sideeffect "add x0, x0, ${0:G}, lsl #12", "S,~{x0}"(i32* @var_tlsld)
39  call void asm sideeffect "add x0, x0, ${0:G}, lsl #12", "S,~{x0}"(i32* @var_tlsle)
40; CHECK: add x0, x0, #:dtprel_hi12:var_tlsld, lsl #12
41; CHECK: add x0, x0, #:tprel_hi12:var_tlsle, lsl #12
42
43; CHECK-ELF: R_AARCH64_TLSLD_ADD_DTPREL_HI12 var_tlsld
44; CHECK-ELF: R_AARCH64_TLSLE_ADD_TPREL_HI12 var_tlsle
45
46  ret void
47}
48
49define void @test_inline_modifier_A() nounwind {
50; CHECK-LABEL: test_inline_modifier_A:
51  call void asm sideeffect "adrp x0, ${0:A}", "S,~{x0}"(i32* @var_simple)
52  call void asm sideeffect "adrp x0, ${0:A}", "S,~{x0}"(i32* @var_got)
53  call void asm sideeffect "adrp x0, ${0:A}", "S,~{x0}"(i32* @var_tlsgd)
54  call void asm sideeffect "adrp x0, ${0:A}", "S,~{x0}"(i32* @var_tlsie)
55  ; N.b. All tprel and dtprel relocs are modified: lo12 or granules.
56; CHECK: adrp x0, var_simple
57; CHECK: adrp x0, :got:var_got
58; CHECK: adrp x0, :tlsdesc:var_tlsgd
59; CHECK: adrp x0, :gottprel:var_tlsie
60
61; CHECK-ELF: R_AARCH64_ADR_PREL_PG_HI21 var_simple
62; CHECK-ELF: R_AARCH64_ADR_GOT_PAGE var_got
63; CHECK-ELF: R_AARCH64_TLSDESC_ADR_PAGE var_tlsgd
64; CHECK-ELF: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 var_tlsie
65
66  ret void
67}
68
69define void @test_inline_modifier_wx(i32 %small, i64 %big) nounwind {
70; CHECK-LABEL: test_inline_modifier_wx:
71  call i32 asm sideeffect "add $0, $0, $0", "=r,0"(i32 %small)
72  call i32 asm sideeffect "add ${0:w}, ${0:w}, ${0:w}", "=r,0"(i32 %small)
73  call i32 asm sideeffect "add ${0:x}, ${0:x}, ${0:x}", "=r,0"(i32 %small)
74; CHECK: //APP
75; CHECK: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
76; CHECK: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
77; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
78
79  call i64 asm sideeffect "add $0, $0, $0", "=r,0"(i64 %big)
80  call i64 asm sideeffect "add ${0:w}, ${0:w}, ${0:w}", "=r,0"(i64 %big)
81  call i64 asm sideeffect "add ${0:x}, ${0:x}, ${0:x}", "=r,0"(i64 %big)
82; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
83; CHECK: add {{w[0-9]+}}, {{w[0-9]+}}, {{w[0-9]+}}
84; CHECK: add {{x[0-9]+}}, {{x[0-9]+}}, {{x[0-9]+}}
85
86  call i32 asm sideeffect "add ${0:w}, ${1:w}, ${1:w}", "=r,r"(i32 0)
87  call i32 asm sideeffect "add ${0:x}, ${1:x}, ${1:x}", "=r,r"(i32 0)
88; CHECK: add {{w[0-9]+}}, wzr, wzr
89; CHECK: add {{x[0-9]+}}, xzr, xzr
90  ret void
91}
92
93define void @test_inline_modifier_bhsdq() nounwind {
94; CHECK-LABEL: test_inline_modifier_bhsdq:
95  call float asm sideeffect "ldr ${0:b}, [sp]", "=w"()
96  call float asm sideeffect "ldr ${0:h}, [sp]", "=w"()
97  call float asm sideeffect "ldr ${0:s}, [sp]", "=w"()
98  call float asm sideeffect "ldr ${0:d}, [sp]", "=w"()
99  call float asm sideeffect "ldr ${0:q}, [sp]", "=w"()
100; CHECK: ldr b0, [sp]
101; CHECK: ldr h0, [sp]
102; CHECK: ldr s0, [sp]
103; CHECK: ldr d0, [sp]
104; CHECK: ldr q0, [sp]
105
106  call double asm sideeffect "ldr ${0:b}, [sp]", "=w"()
107  call double asm sideeffect "ldr ${0:h}, [sp]", "=w"()
108  call double asm sideeffect "ldr ${0:s}, [sp]", "=w"()
109  call double asm sideeffect "ldr ${0:d}, [sp]", "=w"()
110  call double asm sideeffect "ldr ${0:q}, [sp]", "=w"()
111; CHECK: ldr b0, [sp]
112; CHECK: ldr h0, [sp]
113; CHECK: ldr s0, [sp]
114; CHECK: ldr d0, [sp]
115; CHECK: ldr q0, [sp]
116  ret void
117}
118
119define void @test_inline_modifier_c() nounwind {
120; CHECK-LABEL: test_inline_modifier_c:
121  call void asm sideeffect "adr x0, ${0:c}", "i"(i32 3)
122; CHECK: adr x0, 3
123
124  ret void
125}
126