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=medium -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: 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 ptr @dst, ptr @ptr
21 %tmp.s = load i32, ptr @src
22 store i32 %tmp.s, ptr @dst
26 @ptr2 = global ptr 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 ptr @dst2, ptr @ptr2
41 %tmp.s = load i32, ptr @src2
42 store i32 %tmp.s, ptr @dst2
46 declare ptr @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 ptr @malloc(i32 40)
61 @pfoo = external global ptr
62 declare ptr @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 (pfoo@GOTPCREL,%pc), %a1
70 ; CHECK-NEXT: move.l %a0, (%a1)
71 ; CHECK-NEXT: jsr (%a0)
72 ; CHECK-NEXT: adda.l #4, %sp
75 %tmp = call ptr(...) @afoo()
76 store ptr %tmp, ptr @pfoo
77 %tmp1 = load ptr, ptr @pfoo
78 call void(...) %tmp1()
82 declare void @foo(...)
84 define void @test4() nounwind {
86 ; CHECK: ; %bb.0: ; %entry
87 ; CHECK-NEXT: suba.l #4, %sp
88 ; CHECK-NEXT: jsr (foo@PLT,%pc)
89 ; CHECK-NEXT: adda.l #4, %sp
96 @ptr6 = internal global ptr null
97 @dst6 = internal global i32 0
98 @src6 = internal global i32 0
100 define void @test5() nounwind {
101 ; CHECK-LABEL: test5:
102 ; CHECK: ; %bb.0: ; %entry
103 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
104 ; CHECK-NEXT: move.l %a0, %a1
105 ; CHECK-NEXT: adda.l #dst6@GOTOFF, %a1
106 ; CHECK-NEXT: move.l #ptr6@GOTOFF, %d0
107 ; CHECK-NEXT: move.l %a1, (0,%a0,%d0)
108 ; CHECK-NEXT: move.l #src6@GOTOFF, %d0
109 ; CHECK-NEXT: move.l #dst6@GOTOFF, %d1
110 ; CHECK-NEXT: move.l (0,%a0,%d0), (0,%a0,%d1)
113 store ptr @dst6, ptr @ptr6
114 %tmp.s = load i32, ptr @src6
115 store i32 %tmp.s, ptr @dst6
119 define void @test7(i32 %n.u) nounwind {
120 ; CHECK-LABEL: test7:
121 ; CHECK: ; %bb.0: ; %entry
122 ; CHECK-NEXT: move.l (4,%sp), %d0
123 ; CHECK-NEXT: add.l #-1, %d0
124 ; CHECK-NEXT: move.l %d0, %d1
125 ; CHECK-NEXT: sub.l #12, %d1
126 ; CHECK-NEXT: bhi .LBB6_12
127 ; CHECK-NEXT: ; %bb.1: ; %entry
128 ; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_@GOTPCREL,%pc), %a0
129 ; CHECK-NEXT: lsl.l #2, %d0
130 ; CHECK-NEXT: move.l %a0, %a1
131 ; CHECK-NEXT: adda.l #.LJTI6_0@GOTOFF, %a1
132 ; CHECK-NEXT: move.l %a0, %d1
133 ; CHECK-NEXT: add.l (0,%a1,%d0), %d1
134 ; CHECK-NEXT: move.l %d1, %a0
135 ; CHECK-NEXT: jmp (%a0)
136 ; CHECK-NEXT: .LBB6_12: ; %bb2
137 ; CHECK-NEXT: bra foo6@PLT ; TAILCALL
138 ; CHECK-NEXT: .LBB6_3: ; %bb5
139 ; CHECK-NEXT: bra foo5@PLT ; TAILCALL
140 ; CHECK-NEXT: .LBB6_5: ; %bb1
141 ; CHECK-NEXT: bra foo2@PLT ; TAILCALL
142 ; CHECK-NEXT: .LBB6_2: ; %bb
143 ; CHECK-NEXT: bra foo1@PLT ; TAILCALL
144 ; CHECK-NEXT: .LBB6_9: ; %bb4
145 ; CHECK-NEXT: bra foo4@PLT ; TAILCALL
146 ; CHECK-NEXT: .LBB6_8: ; %bb3
147 ; CHECK-NEXT: bra foo3@PLT ; TAILCALL
149 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 ]
151 tail call void(...) @foo1()
154 tail call void(...) @foo2()
157 tail call void(...) @foo6()
160 tail call void(...) @foo3()
163 tail call void(...) @foo4()
166 tail call void(...) @foo5()
169 tail call void(...) @foo1()
172 tail call void(...) @foo2()
175 tail call void(...) @foo6()
178 tail call void(...) @foo3()
181 tail call void(...) @foo4()
184 tail call void(...) @foo5()
187 tail call void(...) @foo6()
191 declare void @foo1(...)
192 declare void @foo2(...)
193 declare void @foo6(...)
194 declare void @foo3(...)
195 declare void @foo4(...)
196 declare void @foo5(...)