1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -O2 -mtriple=m68k -verify-machineinstrs \
3 ; RUN: -code-model=large -relocation-model=pic \
6 @ptr = external global ptr
7 @dst = external global i32
8 @src = external global i32
10 define void @test0() nounwind {
12 ; CHECK: ; %bb.0: ; %entry
13 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
14 ; CHECK-NEXT: move.l %a0, %a1
15 ; CHECK-NEXT: adda.l #dst@GOTOFF, %a1
16 ; CHECK-NEXT: move.l #ptr@GOTOFF, %d0
17 ; CHECK-NEXT: move.l %a1, (0,%a0,%d0)
18 ; CHECK-NEXT: move.l #src@GOTOFF, %d0
19 ; CHECK-NEXT: move.l #dst@GOTOFF, %d1
20 ; CHECK-NEXT: move.l (0,%a0,%d0), (0,%a0,%d1)
23 store ptr @dst, ptr @ptr
24 %tmp.s = load i32, ptr @src
25 store i32 %tmp.s, ptr @dst
29 @ptr2 = global ptr null
33 define void @test1() nounwind {
35 ; CHECK: ; %bb.0: ; %entry
36 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
37 ; CHECK-NEXT: move.l %a0, %a1
38 ; CHECK-NEXT: adda.l #dst2@GOTOFF, %a1
39 ; CHECK-NEXT: move.l #ptr2@GOTOFF, %d0
40 ; CHECK-NEXT: move.l %a1, (0,%a0,%d0)
41 ; CHECK-NEXT: move.l #src2@GOTOFF, %d0
42 ; CHECK-NEXT: move.l #dst2@GOTOFF, %d1
43 ; CHECK-NEXT: move.l (0,%a0,%d0), (0,%a0,%d1)
46 store ptr @dst2, ptr @ptr2
47 %tmp.s = load i32, ptr @src2
48 store i32 %tmp.s, ptr @dst2
52 declare ptr @malloc(i32)
54 define void @test2() nounwind {
56 ; CHECK: ; %bb.0: ; %entry
57 ; CHECK-NEXT: suba.l #4, %sp
58 ; CHECK-NEXT: move.l #40, (%sp)
59 ; CHECK-NEXT: jsr (malloc@PLT,%pc)
60 ; CHECK-NEXT: adda.l #4, %sp
63 %ptr = call ptr @malloc(i32 40)
67 @pfoo = external global ptr
68 declare ptr @afoo(...)
70 define void @test3() nounwind {
72 ; CHECK: ; %bb.0: ; %entry
73 ; CHECK-NEXT: suba.l #4, %sp
74 ; CHECK-NEXT: movem.l %a2, (0,%sp) ; 8-byte Folded Spill
75 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a2
76 ; CHECK-NEXT: jsr (afoo@PLT,%pc)
77 ; CHECK-NEXT: move.l #pfoo@GOTOFF, %d0
78 ; CHECK-NEXT: move.l %a0, (0,%a2,%d0)
79 ; CHECK-NEXT: jsr (%a0)
80 ; CHECK-NEXT: movem.l (0,%sp), %a2 ; 8-byte Folded Reload
81 ; CHECK-NEXT: adda.l #4, %sp
84 %tmp = call ptr(...) @afoo()
85 store ptr %tmp, ptr @pfoo
86 %tmp1 = load ptr, ptr @pfoo
87 call void(...) %tmp1()
91 declare void @foo(...)
93 define void @test4() nounwind {
95 ; CHECK: ; %bb.0: ; %entry
96 ; CHECK-NEXT: suba.l #4, %sp
97 ; CHECK-NEXT: jsr (foo@PLT,%pc)
98 ; CHECK-NEXT: adda.l #4, %sp
101 call void(...) @foo()
105 @ptr6 = internal global ptr null
106 @dst6 = internal global i32 0
107 @src6 = internal global i32 0
109 define void @test5() nounwind {
110 ; CHECK-LABEL: test5:
111 ; CHECK: ; %bb.0: ; %entry
112 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
113 ; CHECK-NEXT: move.l %a0, %a1
114 ; CHECK-NEXT: adda.l #dst6@GOTOFF, %a1
115 ; CHECK-NEXT: move.l #ptr6@GOTOFF, %d0
116 ; CHECK-NEXT: move.l %a1, (0,%a0,%d0)
117 ; CHECK-NEXT: move.l #src6@GOTOFF, %d0
118 ; CHECK-NEXT: move.l #dst6@GOTOFF, %d1
119 ; CHECK-NEXT: move.l (0,%a0,%d0), (0,%a0,%d1)
122 store ptr @dst6, ptr @ptr6
123 %tmp.s = load i32, ptr @src6
124 store i32 %tmp.s, ptr @dst6
128 define void @test7(i32 %n.u) nounwind {
129 ; CHECK-LABEL: test7:
130 ; CHECK: ; %bb.0: ; %entry
131 ; CHECK-NEXT: move.l (4,%sp), %d0
132 ; CHECK-NEXT: add.l #-1, %d0
133 ; CHECK-NEXT: move.l %d0, %d1
134 ; CHECK-NEXT: sub.l #12, %d1
135 ; CHECK-NEXT: bhi .LBB6_12
136 ; CHECK-NEXT: ; %bb.1: ; %entry
137 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
138 ; CHECK-NEXT: lsl.l #2, %d0
139 ; CHECK-NEXT: move.l %a0, %a1
140 ; CHECK-NEXT: adda.l #.LJTI6_0@GOTOFF, %a1
141 ; CHECK-NEXT: move.l %a0, %d1
142 ; CHECK-NEXT: add.l (0,%a1,%d0), %d1
143 ; CHECK-NEXT: move.l %d1, %a0
144 ; CHECK-NEXT: jmp (%a0)
145 ; CHECK-NEXT: .LBB6_12: ; %bb2
146 ; CHECK-NEXT: bra foo6@PLT ; TAILCALL
147 ; CHECK-NEXT: .LBB6_3: ; %bb5
148 ; CHECK-NEXT: bra foo5@PLT ; TAILCALL
149 ; CHECK-NEXT: .LBB6_5: ; %bb1
150 ; CHECK-NEXT: bra foo2@PLT ; TAILCALL
151 ; CHECK-NEXT: .LBB6_2: ; %bb
152 ; CHECK-NEXT: bra foo1@PLT ; TAILCALL
153 ; CHECK-NEXT: .LBB6_9: ; %bb4
154 ; CHECK-NEXT: bra foo4@PLT ; TAILCALL
155 ; CHECK-NEXT: .LBB6_8: ; %bb3
156 ; CHECK-NEXT: bra foo3@PLT ; TAILCALL
158 switch i32 %n.u, label %bb12 [i32 1, label %bb i32 2, label %bb6 i32 4, label %bb7 i32 5, label %bb8 i32 6, label %bb10 i32 7, label %bb1 i32 8, label %bb3 i32 9, label %bb4 i32 10, label %bb9 i32 11, label %bb2 i32 12, label %bb5 i32 13, label %bb11 ]
160 tail call void(...) @foo1()
163 tail call void(...) @foo2()
166 tail call void(...) @foo6()
169 tail call void(...) @foo3()
172 tail call void(...) @foo4()
175 tail call void(...) @foo5()
178 tail call void(...) @foo1()
181 tail call void(...) @foo2()
184 tail call void(...) @foo6()
187 tail call void(...) @foo3()
190 tail call void(...) @foo4()
193 tail call void(...) @foo5()
196 tail call void(...) @foo6()
200 declare void @foo1(...)
201 declare void @foo2(...)
202 declare void @foo6(...)
203 declare void @foo3(...)
204 declare void @foo4(...)
205 declare void @foo5(...)