194 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -stop-after=irtranslator -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS323; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -stop-after=irtranslator -relocation-model=pic -verify-machineinstrs %s -o - | FileCheck %s -check-prefixes=MIPS32_PIC4 5declare i32 @f(i32 %a, i32 %b);6 7define i32 @call_global(i32 %a0, i32 %a1, i32 %x, i32 %y) {8 ; MIPS32-LABEL: name: call_global9 ; MIPS32: bb.1.entry:10 ; MIPS32: liveins: $a0, $a1, $a2, $a311 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a012 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a113 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a214 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a315 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp16 ; MIPS32: $a0 = COPY [[COPY2]](s32)17 ; MIPS32: $a1 = COPY [[COPY3]](s32)18 ; MIPS32: JAL @f, csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $v019 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY $v020 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp21 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY4]], [[COPY4]]22 ; MIPS32: $v0 = COPY [[ADD]](s32)23 ; MIPS32: RetRA implicit $v024 ; MIPS32_PIC-LABEL: name: call_global25 ; MIPS32_PIC: bb.1.entry:26 ; MIPS32_PIC: liveins: $a0, $a1, $a2, $a3, $t9, $v027 ; MIPS32_PIC: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t928 ; MIPS32_PIC: [[COPY:%[0-9]+]]:_(s32) = COPY $a029 ; MIPS32_PIC: [[COPY1:%[0-9]+]]:_(s32) = COPY $a130 ; MIPS32_PIC: [[COPY2:%[0-9]+]]:_(s32) = COPY $a231 ; MIPS32_PIC: [[COPY3:%[0-9]+]]:_(s32) = COPY $a332 ; MIPS32_PIC: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp33 ; MIPS32_PIC: [[GV:%[0-9]+]]:gpr32(p0) = G_GLOBAL_VALUE target-flags(mips-got-call) @f34 ; MIPS32_PIC: $a0 = COPY [[COPY2]](s32)35 ; MIPS32_PIC: $a1 = COPY [[COPY3]](s32)36 ; MIPS32_PIC: $gp = COPY [[ADDu]]37 ; MIPS32_PIC: JALRPseudo [[GV]](p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v038 ; MIPS32_PIC: [[COPY4:%[0-9]+]]:_(s32) = COPY $v039 ; MIPS32_PIC: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp40 ; MIPS32_PIC: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY4]], [[COPY4]]41 ; MIPS32_PIC: $v0 = COPY [[ADD]](s32)42 ; MIPS32_PIC: RetRA implicit $v043entry:44 %z = call i32 @f(i32 %x, i32 %y)45 %doublez = add i32 %z, %z46 ret i32 %doublez47}48 49define internal i32 @f_with_local_linkage(i32 %x, i32 %y) {50 ; MIPS32-LABEL: name: f_with_local_linkage51 ; MIPS32: bb.1.entry:52 ; MIPS32: liveins: $a0, $a153 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a054 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a155 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]56 ; MIPS32: $v0 = COPY [[ADD]](s32)57 ; MIPS32: RetRA implicit $v058 ; MIPS32_PIC-LABEL: name: f_with_local_linkage59 ; MIPS32_PIC: bb.1.entry:60 ; MIPS32_PIC: liveins: $a0, $a161 ; MIPS32_PIC: [[COPY:%[0-9]+]]:_(s32) = COPY $a062 ; MIPS32_PIC: [[COPY1:%[0-9]+]]:_(s32) = COPY $a163 ; MIPS32_PIC: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY1]], [[COPY]]64 ; MIPS32_PIC: $v0 = COPY [[ADD]](s32)65 ; MIPS32_PIC: RetRA implicit $v066entry:67 %add = add i32 %y, %x68 ret i32 %add69}70 71define i32 @call_global_with_local_linkage(i32 %a0, i32 %a1, i32 %x, i32 %y) {72 ; MIPS32-LABEL: name: call_global_with_local_linkage73 ; MIPS32: bb.1.entry:74 ; MIPS32: liveins: $a0, $a1, $a2, $a375 ; MIPS32: [[COPY:%[0-9]+]]:_(s32) = COPY $a076 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a177 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a278 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $a379 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp80 ; MIPS32: $a0 = COPY [[COPY2]](s32)81 ; MIPS32: $a1 = COPY [[COPY3]](s32)82 ; MIPS32: JAL @f_with_local_linkage, csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $v083 ; MIPS32: [[COPY4:%[0-9]+]]:_(s32) = COPY $v084 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp85 ; MIPS32: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY4]], [[COPY4]]86 ; MIPS32: $v0 = COPY [[ADD]](s32)87 ; MIPS32: RetRA implicit $v088 ; MIPS32_PIC-LABEL: name: call_global_with_local_linkage89 ; MIPS32_PIC: bb.1.entry:90 ; MIPS32_PIC: liveins: $a0, $a1, $a2, $a3, $t9, $v091 ; MIPS32_PIC: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t992 ; MIPS32_PIC: [[COPY:%[0-9]+]]:_(s32) = COPY $a093 ; MIPS32_PIC: [[COPY1:%[0-9]+]]:_(s32) = COPY $a194 ; MIPS32_PIC: [[COPY2:%[0-9]+]]:_(s32) = COPY $a295 ; MIPS32_PIC: [[COPY3:%[0-9]+]]:_(s32) = COPY $a396 ; MIPS32_PIC: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp97 ; MIPS32_PIC: [[GV:%[0-9]+]]:gpr32(p0) = G_GLOBAL_VALUE @f_with_local_linkage98 ; MIPS32_PIC: $a0 = COPY [[COPY2]](s32)99 ; MIPS32_PIC: $a1 = COPY [[COPY3]](s32)100 ; MIPS32_PIC: $gp = COPY [[ADDu]]101 ; MIPS32_PIC: JALRPseudo [[GV]](p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $gp, implicit-def $v0102 ; MIPS32_PIC: [[COPY4:%[0-9]+]]:_(s32) = COPY $v0103 ; MIPS32_PIC: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp104 ; MIPS32_PIC: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[COPY4]], [[COPY4]]105 ; MIPS32_PIC: $v0 = COPY [[ADD]](s32)106 ; MIPS32_PIC: RetRA implicit $v0107entry:108 %z = call i32 @f_with_local_linkage(i32 %x, i32 %y)109 %doublez = add i32 %z, %z110 ret i32 %doublez111}112 113define i32 @call_reg(ptr %f_ptr, i32 %x, i32 %y) {114 ; MIPS32-LABEL: name: call_reg115 ; MIPS32: bb.1.entry:116 ; MIPS32: liveins: $a0, $a1, $a2117 ; MIPS32: [[COPY:%[0-9]+]]:gpr32(p0) = COPY $a0118 ; MIPS32: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1119 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2120 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp121 ; MIPS32: $a0 = COPY [[COPY1]](s32)122 ; MIPS32: $a1 = COPY [[COPY2]](s32)123 ; MIPS32: JALRPseudo [[COPY]](p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $v0124 ; MIPS32: [[COPY3:%[0-9]+]]:_(s32) = COPY $v0125 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp126 ; MIPS32: $v0 = COPY [[COPY3]](s32)127 ; MIPS32: RetRA implicit $v0128 ; MIPS32_PIC-LABEL: name: call_reg129 ; MIPS32_PIC: bb.1.entry:130 ; MIPS32_PIC: liveins: $a0, $a1, $a2131 ; MIPS32_PIC: [[COPY:%[0-9]+]]:gpr32(p0) = COPY $a0132 ; MIPS32_PIC: [[COPY1:%[0-9]+]]:_(s32) = COPY $a1133 ; MIPS32_PIC: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2134 ; MIPS32_PIC: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp135 ; MIPS32_PIC: $a0 = COPY [[COPY1]](s32)136 ; MIPS32_PIC: $a1 = COPY [[COPY2]](s32)137 ; MIPS32_PIC: JALRPseudo [[COPY]](p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit $a0, implicit $a1, implicit-def $v0138 ; MIPS32_PIC: [[COPY3:%[0-9]+]]:_(s32) = COPY $v0139 ; MIPS32_PIC: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp140 ; MIPS32_PIC: $v0 = COPY [[COPY3]](s32)141 ; MIPS32_PIC: RetRA implicit $v0142entry:143 %call = call i32 %f_ptr(i32 %x, i32 %y)144 ret i32 %call145}146 147declare void @llvm.memcpy.p0.p0.i32(ptr nocapture writeonly, ptr nocapture readonly, i32, i1 immarg)148 149define void @call_symbol(ptr nocapture readonly %src, ptr nocapture %dest, i32 signext %length) {150 ; MIPS32-LABEL: name: call_symbol151 ; MIPS32: bb.1.entry:152 ; MIPS32: liveins: $a0, $a1, $a2153 ; MIPS32: [[COPY:%[0-9]+]]:_(p0) = COPY $a0154 ; MIPS32: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1155 ; MIPS32: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2156 ; MIPS32: G_MEMCPY [[COPY1]](p0), [[COPY]](p0), [[COPY2]](s32), 0 :: (store (s8) into %ir.dest), (load (s8) from %ir.src)157 ; MIPS32: RetRA158 ; MIPS32_PIC-LABEL: name: call_symbol159 ; MIPS32_PIC: bb.1.entry:160 ; MIPS32_PIC: liveins: $a0, $a1, $a2161 ; MIPS32_PIC: [[COPY:%[0-9]+]]:_(p0) = COPY $a0162 ; MIPS32_PIC: [[COPY1:%[0-9]+]]:_(p0) = COPY $a1163 ; MIPS32_PIC: [[COPY2:%[0-9]+]]:_(s32) = COPY $a2164 ; MIPS32_PIC: G_MEMCPY [[COPY1]](p0), [[COPY]](p0), [[COPY2]](s32), 0 :: (store (s8) into %ir.dest), (load (s8) from %ir.src)165 ; MIPS32_PIC: RetRA166entry:167 call void @llvm.memcpy.p0.p0.i32(ptr align 1 %dest, ptr align 1 %src, i32 %length, i1 false)168 ret void169}170 171declare void @f_with_void_ret();172 173define void @call_f_with_void_ret() {174 ; MIPS32-LABEL: name: call_f_with_void_ret175 ; MIPS32: bb.1.entry:176 ; MIPS32: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp177 ; MIPS32: JAL @f_with_void_ret, csr_o32, implicit-def $ra, implicit-def $sp178 ; MIPS32: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp179 ; MIPS32: RetRA180 ; MIPS32_PIC-LABEL: name: call_f_with_void_ret181 ; MIPS32_PIC: bb.1.entry:182 ; MIPS32_PIC: liveins: $t9, $v0183 ; MIPS32_PIC: [[ADDu:%[0-9]+]]:gpr32 = ADDu $v0, $t9184 ; MIPS32_PIC: ADJCALLSTACKDOWN 16, 0, implicit-def $sp, implicit $sp185 ; MIPS32_PIC: [[GV:%[0-9]+]]:gpr32(p0) = G_GLOBAL_VALUE target-flags(mips-got-call) @f_with_void_ret186 ; MIPS32_PIC: $gp = COPY [[ADDu]]187 ; MIPS32_PIC: JALRPseudo [[GV]](p0), csr_o32, implicit-def $ra, implicit-def $sp, implicit-def $gp188 ; MIPS32_PIC: ADJCALLSTACKUP 16, 0, implicit-def $sp, implicit $sp189 ; MIPS32_PIC: RetRA190entry:191 call void @f_with_void_ret()192 ret void193}194