1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -O0 -mtriple=mipsel-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32
6 @val_with_local_linkage = internal global i32 1
8 declare i32 @f(i32, i32)
9 define internal void @f_with_local_linkage() {entry: ret void}
10 define void @call_global() {entry: ret void}
11 define void @call_global_with_local_linkage() {entry: ret void}
12 define void @ret_global_int() {entry: ret void}
13 define void @ret_global_int_with_local_linkage() {entry: ret void}
17 name: f_with_local_linkage
21 tracksRegLiveness: true
26 ; MIPS32-LABEL: name: f_with_local_linkage
27 ; MIPS32: liveins: $a0, $a1
28 ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
29 ; MIPS32: [[COPY1:%[0-9]+]]:gpr32 = COPY $a1
30 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu [[COPY1]], [[COPY]]
31 ; MIPS32: $v0 = COPY [[ADDu]]
32 ; MIPS32: RetRA implicit $v0
33 %0:gprb(s32) = COPY $a0
34 %1:gprb(s32) = COPY $a1
35 %2:gprb(s32) = G_ADD %1, %0
45 tracksRegLiveness: true
48 liveins: $a0, $a1, $t9, $v0
50 ; MIPS32-LABEL: name: call_global
51 ; MIPS32: liveins: $a0, $a1, $t9, $v0, $t9, $v0
52 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
53 ; MIPS32: [[ADDu1:%[0-9]+]]:gpr32 = ADDu $v0, $t9
54 ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
55 ; MIPS32: [[COPY1:%[0-9]+]]:gpr32 = COPY $a1
56 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
57 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got-call) @f :: (load 4 from got)
58 ; MIPS32: $a0 = COPY [[COPY]]
59 ; MIPS32: $a1 = COPY [[COPY1]]
60 ; MIPS32: $gp = COPY [[ADDu1]]
61 ; MIPS32: JALRPseudo [[LW]], csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v0
62 ; MIPS32: [[COPY2:%[0-9]+]]:gpr32 = COPY $v0
63 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
64 ; MIPS32: $v0 = COPY [[COPY2]]
65 ; MIPS32: RetRA implicit $v0
66 %4:gpr32 = ADDu $v0, $t9
67 %0:gprb(s32) = COPY $a0
68 %1:gprb(s32) = COPY $a1
69 ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
70 %3:gpr32(p0) = G_GLOBAL_VALUE target-flags(mips-got-call) @f
74 JALRPseudo %3(p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v0
75 %2:gprb(s32) = COPY $v0
76 ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
82 name: call_global_with_local_linkage
86 tracksRegLiveness: true
89 liveins: $a0, $a1, $t9, $v0
91 ; MIPS32-LABEL: name: call_global_with_local_linkage
92 ; MIPS32: liveins: $a0, $a1, $t9, $v0, $t9, $v0
93 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
94 ; MIPS32: [[ADDu1:%[0-9]+]]:gpr32 = ADDu $v0, $t9
95 ; MIPS32: [[COPY:%[0-9]+]]:gpr32 = COPY $a0
96 ; MIPS32: [[COPY1:%[0-9]+]]:gpr32 = COPY $a1
97 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
98 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) @f_with_local_linkage :: (load 4 from got)
99 ; MIPS32: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu [[LW]], target-flags(mips-abs-lo) @f_with_local_linkage
100 ; MIPS32: $a0 = COPY [[COPY]]
101 ; MIPS32: $a1 = COPY [[COPY1]]
102 ; MIPS32: $gp = COPY [[ADDu1]]
103 ; MIPS32: JALRPseudo [[ADDiu]], csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v0
104 ; MIPS32: [[COPY2:%[0-9]+]]:gpr32 = COPY $v0
105 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
106 ; MIPS32: $v0 = COPY [[COPY2]]
107 ; MIPS32: RetRA implicit $v0
108 %4:gpr32 = ADDu $v0, $t9
109 %0:gprb(s32) = COPY $a0
110 %1:gprb(s32) = COPY $a1
111 ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp
112 %3:gpr32(p0) = G_GLOBAL_VALUE @f_with_local_linkage
116 JALRPseudo %3(p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v0
117 %2:gprb(s32) = COPY $v0
118 ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp
127 regBankSelected: true
128 tracksRegLiveness: true
131 ; MIPS32-LABEL: name: ret_global_int
132 ; MIPS32: liveins: $t9, $v0
133 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
134 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) @val :: (load 4 from got)
135 ; MIPS32: [[LW1:%[0-9]+]]:gpr32 = LW [[LW]], 0 :: (load 4 from @val)
136 ; MIPS32: $v0 = COPY [[LW1]]
137 ; MIPS32: RetRA implicit $v0
138 %1:gprb(p0) = G_GLOBAL_VALUE @val
139 %0:gprb(s32) = G_LOAD %1(p0) :: (load 4 from @val)
145 name: ret_global_int_with_local_linkage
148 regBankSelected: true
149 tracksRegLiveness: true
152 ; MIPS32-LABEL: name: ret_global_int_with_local_linkage
153 ; MIPS32: liveins: $t9, $v0
154 ; MIPS32: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9
155 ; MIPS32: [[LW:%[0-9]+]]:gpr32 = LW [[ADDu]], target-flags(mips-got) @val_with_local_linkage :: (load 4 from got)
156 ; MIPS32: [[ADDiu:%[0-9]+]]:gpr32 = ADDiu [[LW]], target-flags(mips-abs-lo) @val_with_local_linkage
157 ; MIPS32: [[LW1:%[0-9]+]]:gpr32 = LW [[ADDiu]], 0 :: (load 4 from @val_with_local_linkage)
158 ; MIPS32: $v0 = COPY [[LW1]]
159 ; MIPS32: RetRA implicit $v0
160 %1:gprb(p0) = G_GLOBAL_VALUE @val_with_local_linkage
161 %0:gprb(s32) = G_LOAD %1(p0) :: (load 4 from @val_with_local_linkage)