1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -O2 -mtriple=m68k-linux-gnu -verify-machineinstrs \
3 ; RUN: -code-model=small -relocation-model=pic \
6 @ptr = external global i32*
7 @dst = external global i32
8 @src = external global i32
10 define void @test0() nounwind {
12 ; CHECK: ; %bb.0: ; %entry
13 ; CHECK-NEXT: move.l (dst@GOTPCREL,%pc), %a0
14 ; CHECK-NEXT: move.l (ptr@GOTPCREL,%pc), %a1
15 ; CHECK-NEXT: move.l %a0, (%a1)
16 ; CHECK-NEXT: move.l (src@GOTPCREL,%pc), %a1
17 ; CHECK-NEXT: move.l (%a1), (%a0)
20 store i32* @dst, i32** @ptr
21 %tmp.s = load i32, i32* @src
22 store i32 %tmp.s, i32* @dst
26 @ptr2 = global i32* null
30 define void @test1() nounwind {
32 ; CHECK: ; %bb.0: ; %entry
33 ; CHECK-NEXT: move.l (dst2@GOTPCREL,%pc), %a0
34 ; CHECK-NEXT: move.l (ptr2@GOTPCREL,%pc), %a1
35 ; CHECK-NEXT: move.l %a0, (%a1)
36 ; CHECK-NEXT: move.l (src2@GOTPCREL,%pc), %a1
37 ; CHECK-NEXT: move.l (%a1), (%a0)
40 store i32* @dst2, i32** @ptr2
41 %tmp.s = load i32, i32* @src2
42 store i32 %tmp.s, i32* @dst2
46 declare i8* @malloc(i32)
48 define void @test2() nounwind {
50 ; CHECK: ; %bb.0: ; %entry
51 ; CHECK-NEXT: suba.l #4, %sp
52 ; CHECK-NEXT: move.l #40, (%sp)
53 ; CHECK-NEXT: jsr (malloc@PLT,%pc)
54 ; CHECK-NEXT: adda.l #4, %sp
57 %ptr = call i8* @malloc(i32 40)
61 @pfoo = external global void(...)*
62 declare void(...)* @afoo(...)
64 define void @test3() nounwind {
66 ; CHECK: ; %bb.0: ; %entry
67 ; CHECK-NEXT: suba.l #4, %sp
68 ; CHECK-NEXT: jsr (afoo@PLT,%pc)
69 ; CHECK-NEXT: move.l %d0, %a0
70 ; CHECK-NEXT: move.l (pfoo@GOTPCREL,%pc), %a1
71 ; CHECK-NEXT: move.l %a0, (%a1)
72 ; CHECK-NEXT: jsr (%a0)
73 ; CHECK-NEXT: adda.l #4, %sp
76 %tmp = call void(...)*(...) @afoo()
77 store void(...)* %tmp, void(...)** @pfoo
78 %tmp1 = load void(...)*, void(...)** @pfoo
79 call void(...) %tmp1()
83 declare void @foo(...)
85 define void @test4() nounwind {
87 ; CHECK: ; %bb.0: ; %entry
88 ; CHECK-NEXT: suba.l #4, %sp
89 ; CHECK-NEXT: jsr (foo@PLT,%pc)
90 ; CHECK-NEXT: adda.l #4, %sp
97 @ptr6 = internal global i32* null
98 @dst6 = internal global i32 0
99 @src6 = internal global i32 0
101 define void @test5() nounwind {
102 ; CHECK-LABEL: test5:
103 ; CHECK: ; %bb.0: ; %entry
104 ; CHECK-NEXT: lea (dst6,%pc), %a0
105 ; CHECK-NEXT: move.l %a0, (ptr6,%pc)
106 ; CHECK-NEXT: move.l (src6,%pc), (dst6,%pc)
109 store i32* @dst6, i32** @ptr6
110 %tmp.s = load i32, i32* @src6
111 store i32 %tmp.s, i32* @dst6
115 define void @test7(i32 %n.u) nounwind {
116 ; CHECK-LABEL: test7:
117 ; CHECK: ; %bb.0: ; %entry
118 ; CHECK-NEXT: move.l (4,%sp), %d0
119 ; CHECK-NEXT: add.l #-1, %d0
120 ; CHECK-NEXT: move.l %d0, %d1
121 ; CHECK-NEXT: sub.l #12, %d1
122 ; CHECK-NEXT: bhi .LBB6_12
123 ; CHECK-NEXT: ; %bb.1: ; %entry
124 ; CHECK-NEXT: lsl.l #2, %d0
125 ; CHECK-NEXT: lea (.LJTI6_0,%pc), %a0
126 ; CHECK-NEXT: move.l %a0, %d1
127 ; CHECK-NEXT: add.l (0,%a0,%d0), %d1
128 ; CHECK-NEXT: move.l %d1, %a0
129 ; CHECK-NEXT: jmp (%a0)
130 ; CHECK-NEXT: .LBB6_12: ; %bb2
131 ; CHECK-NEXT: bra foo6@PLT ; TAILCALL
132 ; CHECK-NEXT: .LBB6_3: ; %bb6
133 ; CHECK-NEXT: bra foo1@PLT ; TAILCALL
134 ; CHECK-NEXT: .LBB6_8: ; %bb1
135 ; CHECK-NEXT: bra foo2@PLT ; TAILCALL
136 ; CHECK-NEXT: .LBB6_9: ; %bb3
137 ; CHECK-NEXT: bra foo3@PLT ; TAILCALL
138 ; CHECK-NEXT: .LBB6_10: ; %bb4
139 ; CHECK-NEXT: bra foo4@PLT ; TAILCALL
140 ; CHECK-NEXT: .LBB6_14: ; %bb11
141 ; CHECK-NEXT: bra foo5@PLT ; TAILCALL
143 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 ]
145 tail call void(...) @foo1()
148 tail call void(...) @foo2()
151 tail call void(...) @foo6()
154 tail call void(...) @foo3()
157 tail call void(...) @foo4()
160 tail call void(...) @foo5()
163 tail call void(...) @foo1()
166 tail call void(...) @foo2()
169 tail call void(...) @foo6()
172 tail call void(...) @foo3()
175 tail call void(...) @foo4()
178 tail call void(...) @foo5()
181 tail call void(...) @foo6()
185 declare void @foo1(...)
186 declare void @foo2(...)
187 declare void @foo6(...)
188 declare void @foo3(...)
189 declare void @foo4(...)
190 declare void @foo5(...)