[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / ELF / offset.s
blobd98405eda9901de0e12a0fe72a8e6e61a8939191
1 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj --symbols - | FileCheck %s
3 // Test that a variable declared with "var = other_var + cst" is in the same
4 // section as other_var and its value is the value of other_var + cst.
6 .data
7 .globl sym_a
8 .size sym_a, 42
9 .byte 42
10 .type sym_a, @object
11 sym_a:
13 // CHECK: Symbol {
14 // CHECK: Name: sym_a
15 // CHECK-NEXT: Value: 0x1
16 // CHECK-NEXT: Size: 42
17 // CHECK-NEXT: Binding: Global
18 // CHECK-NEXT: Type: Object
19 // CHECK-NEXT: Other: 0
20 // CHECK-NEXT: Section: .data
21 // CHECK-NEXT: }
23 .long 42
24 .globl sym_b
25 sym_b:
26 .globl sym_c
27 sym_c = sym_a
28 // CHECK: Symbol {
29 // CHECK: Name: sym_c
30 // CHECK-NEXT: Value: 0x1
31 // CHECK-NEXT: Size: 42
32 // CHECK-NEXT: Binding: Global
33 // CHECK-NEXT: Type: Object
34 // CHECK-NEXT: Other: 0
35 // CHECK-NEXT: Section: .data
36 // CHECK-NEXT: }
38 .globl sym_d
39 sym_d = sym_a + 1
40 // CHECK: Symbol {
41 // CHECK: Name: sym_d
42 // CHECK-NEXT: Value: 0x2
43 // CHECK-NEXT: Size: 42
44 // CHECK-NEXT: Binding: Global
45 // CHECK-NEXT: Type: Object
46 // CHECK-NEXT: Other: 0
47 // CHECK-NEXT: Section: .data
48 // CHECK-NEXT: }
50 .globl sym_e
51 sym_e = sym_a + (sym_b - sym_a) * 3
52 // CHECK: Symbol {
53 // CHECK: Name: sym_e
54 // CHECK-NEXT: Value: 0xD
55 // CHECK-NEXT: Size: 42
56 // CHECK-NEXT: Binding: Global
57 // CHECK-NEXT: Type: Object
58 // CHECK-NEXT: Other: 0
59 // CHECK-NEXT: Section: .data
60 // CHECK-NEXT: }
63 .globl sym_f
64 sym_f = sym_a + (1 - 1)
65 // CHECK: Symbol {
66 // CHECK: Name: sym_f
67 // CHECK-NEXT: Value: 0x1
68 // CHECK-NEXT: Size: 42
69 // CHECK-NEXT: Binding: Global
70 // CHECK-NEXT: Type: Object
71 // CHECK-NEXT: Other: 0
72 // CHECK-NEXT: Section: .data
73 // CHECK-NEXT: }
76 .globl test2_a
77 .globl test2_b
78 .globl test2_c
79 .globl test2_d
80 .globl test2_e
81 test2_a:
82 .long 0
83 test2_b = test2_a
84 test2_c:
85 .long 0
86 test2_d = test2_c
87 test2_e = test2_d - test2_b
88 // CHECK: Symbol {
89 // CHECK: Name: test2_a
90 // CHECK-NEXT: Value: 0x5
91 // CHECK-NEXT: Size: 0
92 // CHECK-NEXT: Binding: Global
93 // CHECK-NEXT: Type: None
94 // CHECK-NEXT: Other: 0
95 // CHECK-NEXT: Section: .data
96 // CHECK-NEXT: }
97 // CHECK-NEXT: Symbol {
98 // CHECK-NEXT: Name: test2_b
99 // CHECK-NEXT: Value: 0x5
100 // CHECK-NEXT: Size: 0
101 // CHECK-NEXT: Binding: Global
102 // CHECK-NEXT: Type: None
103 // CHECK-NEXT: Other: 0
104 // CHECK-NEXT: Section: .data
105 // CHECK-NEXT: }
106 // CHECK-NEXT: Symbol {
107 // CHECK-NEXT: Name: test2_c
108 // CHECK-NEXT: Value: 0x9
109 // CHECK-NEXT: Size: 0
110 // CHECK-NEXT: Binding: Global
111 // CHECK-NEXT: Type: None
112 // CHECK-NEXT: Other: 0
113 // CHECK-NEXT: Section: .data
114 // CHECK-NEXT: }
115 // CHECK-NEXT: Symbol {
116 // CHECK-NEXT: Name: test2_d
117 // CHECK-NEXT: Value: 0x9
118 // CHECK-NEXT: Size: 0
119 // CHECK-NEXT: Binding: Global
120 // CHECK-NEXT: Type: None
121 // CHECK-NEXT: Other: 0
122 // CHECK-NEXT: Section: .data
123 // CHECK-NEXT: }
124 // CHECK-NEXT: Symbol {
125 // CHECK-NEXT: Name: test2_e
126 // CHECK-NEXT: Value: 0x4
127 // CHECK-NEXT: Size: 0
128 // CHECK-NEXT: Binding: Global
129 // CHECK-NEXT: Type: None
130 // CHECK-NEXT: Other: 0
131 // CHECK-NEXT: Section: Absolute
132 // CHECK-NEXT: }