[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / Sparc / sparc-tls-relocations.s
blob257fda74120c511d8ae63a220263a7a51634e1cc
1 ! Testing Sparc TLS relocations emission
2 ! (for now a couple local ones).
4 ! RUN: llvm-mc %s -arch=sparc -show-encoding | FileCheck %s --check-prefix=ASM
5 ! RUN: llvm-mc %s -arch=sparcv9 -show-encoding | FileCheck %s --check-prefix=ASM
6 ! RUN: llvm-mc %s -arch=sparc -filetype=obj | llvm-readobj -r - | FileCheck %s --check-prefix=REL
7 ! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r - | FileCheck %s --check-prefix=REL
8 ! RUN: llvm-mc %s -arch=sparc -filetype=obj | llvm-objdump -r -d - | FileCheck %s --check-prefix=OBJDUMP
9 ! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-objdump -r -d - | FileCheck %s --check-prefix=OBJDUMP
11 ! REL: Arch: sparc
12 ! REL: Relocations [
13 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LE_HIX22 Local 0x0
14 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LE_LOX10 Local 0x0
15 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDO_HIX22 Local 0x0
16 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDM_HI22 Local 0x0
17 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDM_LO10 Local 0x0
18 ! REL: 0x{{[0-9,A-F]+}} R_SPARC_TLS_LDO_LOX10 Local 0x0
19 ! REL: ]
22 ! OBJDUMP: <foo>:
23 foo:
24 ! Here we use two different sequences to get the address of a static TLS variable 'Local'
25 ! (note - there is no intent to have valid assembler function here,
26 ! we just check how TLS relocations are emitted)
28 ! Sequence for Local Executable model:
29 ! LE_HIX22/LE_LOX10
31 ! OBJDUMP: {{[0-9,a-f]+}}: 31 00 00 00 sethi 0, %i0
32 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LE_HIX22 Local
33 ! ASM: sethi %tle_hix22(Local), %i0 ! encoding: [0x31,0x00,0x00,0x00]
34 ! ASM: ! fixup A - offset: 0, value: %tle_hix22(Local), kind: fixup_sparc_tls_le_hix22
35 sethi %tle_hix22(Local), %i0
37 ! OBJDUMP: {{[0-9,a-f]+}}: b0 1e 20 00 xor %i0, 0, %i0
38 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LE_LOX10 Local
39 ! ASM: xor %i0, %tle_lox10(Local), %i0 ! encoding: [0xb0,0x1e,0x20,0x00]
40 ! ASM: ! fixup A - offset: 0, value: %tle_lox10(Local), kind: fixup_sparc_tls_le_lox10
41 xor %i0, %tle_lox10(Local), %i0
44 ! Second sequence is for PIC, so it is more complicated.
45 ! Local Dynamic model:
46 ! LDO_HIX22/LDO_LOX10/LDO_ADD/LDM_HI22/LDM_LO10/LDM_ADD/LDM_CALL
48 ! OBJDUMP: {{[0-9,a-f]+}}: 33 00 00 00 sethi 0, %i1
49 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDO_HIX22 Local
50 ! ASM: sethi %tldo_hix22(Local), %i1 ! encoding: [0x33,0b00AAAAAA,A,A]
51 ! ASM: ! fixup A - offset: 0, value: %tldo_hix22(Local), kind: fixup_sparc_tls_ldo_hix22
52 sethi %tldo_hix22(Local), %i1
54 ! OBJDUMP: {{[0-9,a-f]+}}: 35 00 00 00 sethi 0, %i2
55 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDM_HI22 Local
56 ! ASM: sethi %tldm_hi22(Local), %i2 ! encoding: [0x35,0b00AAAAAA,A,A]
57 ! ASM: ! fixup A - offset: 0, value: %tldm_hi22(Local), kind: fixup_sparc_tls_ldm_hi22
58 sethi %tldm_hi22(Local), %i2
60 ! OBJDUMP: {{[0-9,a-f]+}}: b4 06 a0 00 add %i2, 0, %i2
61 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDM_LO10 Local
62 ! ASM: add %i2, %tldm_lo10(Local), %i2 ! encoding: [0xb4,0x06,0b101000AA,A]
63 ! ASM: ! fixup A - offset: 0, value: %tldm_lo10(Local), kind: fixup_sparc_tls_ldm_lo10
64 add %i2, %tldm_lo10(Local), %i2
66 ! OBJDUMP: {{[0-9,a-f]+}}: 90 06 00 1a add %i0, %i2, %o0
67 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDM_ADD Local
68 ! ASM: add %i0, %i2, %o0, %tldm_add(Local) ! encoding: [0x90,0x06,0x00,0x1a]
69 ! ASM: ! fixup A - offset: 0, value: %tldm_add(Local), kind: fixup_sparc_tls_ldm_add
70 add %i0, %i2, %o0, %tldm_add(Local)
72 ! OBJDUMP: {{[0-9,a-f]+}}: b0 1e 60 00 xor %i1, 0, %i0
73 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDO_LOX10 Local
74 ! ASM: xor %i1, %tldo_lox10(Local), %i0 ! encoding: [0xb0,0x1e,0b011000AA,A]
75 ! ASM: ! fixup A - offset: 0, value: %tldo_lox10(Local), kind: fixup_sparc_tls_ldo_lox10
76 xor %i1, %tldo_lox10(Local), %i0
78 ! OBJDUMP: {{[0-9,a-f]+}}: 40 00 00 00 call 0
79 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDM_CALL Local
80 ! ASM: call __tls_get_addr, %tldm_call(Local) ! encoding: [0x40,0x00,0x00,0x00]
81 ! ASM: ! fixup A - offset: 0, value: %tldm_call(Local), kind: fixup_sparc_tls_ldm_call
82 call __tls_get_addr, %tldm_call(Local)
83 nop
85 ! OBJDUMP: {{[0-9,a-f]+}}: 90 02 00 18 add %o0, %i0, %o0
86 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_LDO_ADD Local
87 ! ASM: add %o0, %i0, %o0, %tldo_add(Local) ! encoding: [0x90,0x02,0x00,0x18]
88 ! ASM: ! fixup A - offset: 0, value: %tldo_add(Local), kind: fixup_sparc_tls_ldo_add
89 add %o0, %i0, %o0, %tldo_add(Local)
91 ! Next two sequences are for extern symbols.
92 ! Initial Executable model:
93 ! IE_HI22/IE_LO10/IE_LD (or IE_LDX)/IE_ADD
95 ! OBJDUMP: {{[0-9,a-f]+}}: 33 00 00 00 sethi 0, %i1
96 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_IE_HI22 Extern
97 ! ASM: sethi %tie_hi22(Extern), %i1 ! encoding: [0x33,0b00AAAAAA,A,A]
98 ! ASM: ! fixup A - offset: 0, value: %tie_hi22(Extern), kind: fixup_sparc_tls_ie_hi22
99 sethi %tie_hi22(Extern), %i1
101 ! OBJDUMP: {{[0-9,a-f]+}}: b2 06 60 00 add %i1, 0, %i1
102 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_IE_LO10 Extern
103 ! ASM: add %i1, %tie_lo10(Extern), %i1 ! encoding: [0xb2,0x06,0b011000AA,A]
104 ! ASM: ! fixup A - offset: 0, value: %tie_lo10(Extern), kind: fixup_sparc_tls_ie_lo10
105 add %i1, %tie_lo10(Extern), %i1
107 ! OBJDUMP: {{[0-9,a-f]+}}: f0 06 00 19 ld [%i0+%i1], %i0
108 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_IE_LD Extern
109 ! ASM: ld [%i0+%i1], %i0, %tie_ld(Extern) ! encoding: [0xf0,0x06,0x00,0x19]
110 ! ASM: ! fixup A - offset: 0, value: %tie_ld(Extern), kind: fixup_sparc_tls_ie_ld
111 ld [%i0+%i1], %i0, %tie_ld(Extern)
113 ! OBJDUMP: {{[0-9,a-f]+}}: f0 5e 00 19 ldx [%i0+%i1], %i0
114 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_IE_LDX Extern
115 ! ASM: ldx [%i0+%i1], %i0, %tie_ldx(Extern) ! encoding: [0xf0,0x5e,0x00,0x19]
116 ! ASM: ! fixup A - offset: 0, value: %tie_ldx(Extern), kind: fixup_sparc_tls_ie_ldx
117 ldx [%i0+%i1], %i0, %tie_ldx(Extern)
119 ! OBJDUMP: {{[0-9,a-f]+}}: 90 01 c0 18 add %g7, %i0, %o0
120 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_IE_ADD Extern
121 ! ASM: add %g7, %i0, %o0, %tie_add(Extern) ! encoding: [0x90,0x01,0xc0,0x18]
122 ! ASM: ! fixup A - offset: 0, value: %tie_add(Extern), kind: fixup_sparc_tls_ie_add
123 add %g7, %i0, %o0, %tie_add(Extern)
125 ! General Dynamic model
126 ! GD_HI22/GD_LO10/GD_ADD/GD_CALL
128 ! OBJDUMP: {{[0-9,a-f]+}}: 33 00 00 00 sethi 0, %i1
129 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_GD_HI22 Extern
130 ! ASM: sethi %tgd_hi22(Extern), %i1 ! encoding: [0x33,0b00AAAAAA,A,A]
131 ! ASM: ! fixup A - offset: 0, value: %tgd_hi22(Extern), kind: fixup_sparc_tls_gd_hi22
132 sethi %tgd_hi22(Extern), %i1
134 ! OBJDUMP: {{[0-9,a-f]+}}: b2 06 60 00 add %i1, 0, %i1
135 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_GD_LO10 Extern
136 ! ASM: add %i1, %tgd_lo10(Extern), %i1 ! encoding: [0xb2,0x06,0b011000AA,A]
137 ! ASM: ! fixup A - offset: 0, value: %tgd_lo10(Extern), kind: fixup_sparc_tls_gd_lo10
138 add %i1, %tgd_lo10(Extern), %i1
140 ! OBJDUMP: {{[0-9,a-f]+}}: 90 06 00 19 add %i0, %i1, %o0
141 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_GD_ADD Extern
142 ! ASM: add %i0, %i1, %o0, %tgd_add(Extern) ! encoding: [0x90,0x06,0x00,0x19]
143 ! ASM: ! fixup A - offset: 0, value: %tgd_add(Extern), kind: fixup_sparc_tls_gd_add
144 add %i0, %i1, %o0, %tgd_add(Extern)
146 ! OBJDUMP: {{[0-9,a-f]+}}: 40 00 00 00 call 0
147 ! OBJDUMP: {{[0-9,a-f]+}}: R_SPARC_TLS_GD_CALL Extern
148 ! ASM: call __tls_get_addr, %tgd_call(Extern) ! encoding: [0x40,0x00,0x00,0x00]
149 ! ASM: ! fixup A - offset: 0, value: %tgd_call(Extern), kind: fixup_sparc_tls_gd_call
150 call __tls_get_addr, %tgd_call(Extern)
152 .type Local,@object
153 .section .tbss,#alloc,#write,#tls
154 Local:
155 .word 0
156 .size Local, 4