[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / ELF / reloc-directive.s
blob59d7ace40d7e06d7ea56ac9c898e8b9ec1791282
1 ## Target specific relocation support is tested in MC/$target/*reloc-directive*.s
2 # RUN: llvm-mc -triple=x86_64 %s | FileCheck %s --check-prefix=ASM
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
4 # RUN: llvm-readobj -r %t | FileCheck %s
6 # ASM: .Ltmp0:
7 # ASM-NEXT: .reloc (.Ltmp0+3)-2, R_X86_64_NONE, foo
8 # ASM-NEXT: .Ltmp1:
9 # ASM-NEXT: .reloc .Ltmp1-1, R_X86_64_NONE, foo
10 # ASM-NEXT: .Ltmp2:
11 # ASM-NEXT: .reloc 2+.Ltmp2, R_X86_64_NONE, foo
12 # ASM-NEXT: .reloc (1+foo)+3, R_X86_64_NONE, data+1
14 # CHECK: 0x2 R_X86_64_NONE foo 0x0
15 # CHECK-NEXT: 0x0 R_X86_64_NONE foo 0x0
16 # CHECK-NEXT: 0x3 R_X86_64_NONE foo 0x0
17 # CHECK-NEXT: 0x4 R_X86_64_NONE data 0x1
19 .text
20 .globl foo
21 foo:
22 ret
23 .reloc .+3-2, R_X86_64_NONE, foo
24 .reloc .-1, R_X86_64_NONE, foo
25 .reloc 2+., R_X86_64_NONE, foo
26 .reloc 1+foo+3, R_X86_64_NONE, data+1
28 .data
29 .globl data
30 data:
31 .long 0
33 # RUN: not llvm-mc -filetype=obj -triple=x86_64 --defsym=ERR=1 %s 2>&1 | FileCheck %s --check-prefix=ERR
35 .ifdef ERR
36 .text
37 .globl a, b
38 a: ret
39 b: ret
40 x: ret
41 y: ret
43 # ERR: {{.*}}.s:[[#@LINE+1]]:10: error: expected comma
44 .reloc 0 R_X86_64_NONE, a
46 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is negative
47 .reloc -1, R_X86_64_NONE, a
48 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not relocatable
49 .reloc 2*., R_X86_64_NONE, a
50 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not relocatable
51 .reloc a+a, R_X86_64_NONE, a
52 ## GNU as accepts a-a but rejects b-a.
53 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not representable
54 .reloc a-a, R_X86_64_NONE, a
55 ## TODO GNU as accepts x-x and y-x.
56 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: .reloc offset is not representable
57 .reloc x-x, R_X86_64_NONE, a
59 # ERR: {{.*}}.s:[[#@LINE+1]]:8: error: directional label undefined
60 .reloc 1f, R_X86_64_NONE, a
61 .endif