1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32 3; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -relocation-model=pic -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32_PIC 4 5declare i32 @f(i32 %a, i32 %b); 6 7define i32 @call_global(i32 %a0, i32 %a1, i32 %x, i32 %y) { 8; MIPS32-LABEL: call_global: 9; MIPS32: # %bb.0: # %entry 10; MIPS32-NEXT: addiu $sp, $sp, -24 11; MIPS32-NEXT: .cfi_def_cfa_offset 24 12; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 13; MIPS32-NEXT: .cfi_offset 31, -4 14; MIPS32-NEXT: move $4, $6 15; MIPS32-NEXT: move $5, $7 16; MIPS32-NEXT: jal f 17; MIPS32-NEXT: nop 18; MIPS32-NEXT: addu $2, $2, $2 19; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 20; MIPS32-NEXT: addiu $sp, $sp, 24 21; MIPS32-NEXT: jr $ra 22; MIPS32-NEXT: nop 23; 24; MIPS32_PIC-LABEL: call_global: 25; MIPS32_PIC: # %bb.0: # %entry 26; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp) 27; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp) 28; MIPS32_PIC-NEXT: addiu $sp, $sp, -24 29; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24 30; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 31; MIPS32_PIC-NEXT: .cfi_offset 31, -4 32; MIPS32_PIC-NEXT: addu $gp, $2, $25 33; MIPS32_PIC-NEXT: move $4, $6 34; MIPS32_PIC-NEXT: move $5, $7 35; MIPS32_PIC-NEXT: lw $25, %call16(f)($gp) 36; MIPS32_PIC-NEXT: jalr $25 37; MIPS32_PIC-NEXT: nop 38; MIPS32_PIC-NEXT: addu $2, $2, $2 39; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 40; MIPS32_PIC-NEXT: addiu $sp, $sp, 24 41; MIPS32_PIC-NEXT: jr $ra 42; MIPS32_PIC-NEXT: nop 43entry: 44 %z = call i32 @f(i32 %x, i32 %y) 45 %doublez = add i32 %z, %z 46 ret i32 %doublez 47} 48 49define internal i32 @f_with_local_linkage(i32 %x, i32 %y) { 50; MIPS32-LABEL: f_with_local_linkage: 51; MIPS32: # %bb.0: # %entry 52; MIPS32-NEXT: addu $2, $5, $4 53; MIPS32-NEXT: jr $ra 54; MIPS32-NEXT: nop 55; 56; MIPS32_PIC-LABEL: f_with_local_linkage: 57; MIPS32_PIC: # %bb.0: # %entry 58; MIPS32_PIC-NEXT: addu $2, $5, $4 59; MIPS32_PIC-NEXT: jr $ra 60; MIPS32_PIC-NEXT: nop 61entry: 62 %add = add i32 %y, %x 63 ret i32 %add 64} 65 66define i32 @call_global_with_local_linkage(i32 %a0, i32 %a1, i32 %x, i32 %y) { 67; MIPS32-LABEL: call_global_with_local_linkage: 68; MIPS32: # %bb.0: # %entry 69; MIPS32-NEXT: addiu $sp, $sp, -24 70; MIPS32-NEXT: .cfi_def_cfa_offset 24 71; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 72; MIPS32-NEXT: .cfi_offset 31, -4 73; MIPS32-NEXT: move $4, $6 74; MIPS32-NEXT: move $5, $7 75; MIPS32-NEXT: jal f_with_local_linkage 76; MIPS32-NEXT: nop 77; MIPS32-NEXT: addu $2, $2, $2 78; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 79; MIPS32-NEXT: addiu $sp, $sp, 24 80; MIPS32-NEXT: jr $ra 81; MIPS32-NEXT: nop 82; 83; MIPS32_PIC-LABEL: call_global_with_local_linkage: 84; MIPS32_PIC: # %bb.0: # %entry 85; MIPS32_PIC-NEXT: lui $2, %hi(_gp_disp) 86; MIPS32_PIC-NEXT: addiu $2, $2, %lo(_gp_disp) 87; MIPS32_PIC-NEXT: addiu $sp, $sp, -24 88; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24 89; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 90; MIPS32_PIC-NEXT: .cfi_offset 31, -4 91; MIPS32_PIC-NEXT: addu $gp, $2, $25 92; MIPS32_PIC-NEXT: move $4, $6 93; MIPS32_PIC-NEXT: move $5, $7 94; MIPS32_PIC-NEXT: lw $1, %got(f_with_local_linkage)($gp) 95; MIPS32_PIC-NEXT: addiu $25, $1, %lo(f_with_local_linkage) 96; MIPS32_PIC-NEXT: jalr $25 97; MIPS32_PIC-NEXT: nop 98; MIPS32_PIC-NEXT: addu $2, $2, $2 99; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 100; MIPS32_PIC-NEXT: addiu $sp, $sp, 24 101; MIPS32_PIC-NEXT: jr $ra 102; MIPS32_PIC-NEXT: nop 103entry: 104 %z = call i32 @f_with_local_linkage(i32 %x, i32 %y) 105 %doublez = add i32 %z, %z 106 ret i32 %doublez 107} 108 109define i32 @call_reg(i32 (i32, i32)* %f_ptr, i32 %x, i32 %y) { 110; MIPS32-LABEL: call_reg: 111; MIPS32: # %bb.0: # %entry 112; MIPS32-NEXT: addiu $sp, $sp, -24 113; MIPS32-NEXT: .cfi_def_cfa_offset 24 114; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 115; MIPS32-NEXT: .cfi_offset 31, -4 116; MIPS32-NEXT: move $25, $4 117; MIPS32-NEXT: move $4, $5 118; MIPS32-NEXT: move $5, $6 119; MIPS32-NEXT: jalr $25 120; MIPS32-NEXT: nop 121; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 122; MIPS32-NEXT: addiu $sp, $sp, 24 123; MIPS32-NEXT: jr $ra 124; MIPS32-NEXT: nop 125; 126; MIPS32_PIC-LABEL: call_reg: 127; MIPS32_PIC: # %bb.0: # %entry 128; MIPS32_PIC-NEXT: addiu $sp, $sp, -24 129; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24 130; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 131; MIPS32_PIC-NEXT: .cfi_offset 31, -4 132; MIPS32_PIC-NEXT: move $25, $4 133; MIPS32_PIC-NEXT: move $4, $5 134; MIPS32_PIC-NEXT: move $5, $6 135; MIPS32_PIC-NEXT: jalr $25 136; MIPS32_PIC-NEXT: nop 137; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 138; MIPS32_PIC-NEXT: addiu $sp, $sp, 24 139; MIPS32_PIC-NEXT: jr $ra 140; MIPS32_PIC-NEXT: nop 141entry: 142 %call = call i32 %f_ptr(i32 %x, i32 %y) 143 ret i32 %call 144} 145 146declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i1 immarg) 147 148define void @call_symbol(i8* nocapture readonly %src, i8* nocapture %dest, i32 signext %length) { 149; MIPS32-LABEL: call_symbol: 150; MIPS32: # %bb.0: # %entry 151; MIPS32-NEXT: addiu $sp, $sp, -24 152; MIPS32-NEXT: .cfi_def_cfa_offset 24 153; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 154; MIPS32-NEXT: .cfi_offset 31, -4 155; MIPS32-NEXT: sw $4, 16($sp) # 4-byte Folded Spill 156; MIPS32-NEXT: move $4, $5 157; MIPS32-NEXT: lw $5, 16($sp) # 4-byte Folded Reload 158; MIPS32-NEXT: jal memcpy 159; MIPS32-NEXT: nop 160; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 161; MIPS32-NEXT: addiu $sp, $sp, 24 162; MIPS32-NEXT: jr $ra 163; MIPS32-NEXT: nop 164; 165; MIPS32_PIC-LABEL: call_symbol: 166; MIPS32_PIC: # %bb.0: # %entry 167; MIPS32_PIC-NEXT: addiu $sp, $sp, -24 168; MIPS32_PIC-NEXT: .cfi_def_cfa_offset 24 169; MIPS32_PIC-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill 170; MIPS32_PIC-NEXT: .cfi_offset 31, -4 171; MIPS32_PIC-NEXT: sw $4, 16($sp) # 4-byte Folded Spill 172; MIPS32_PIC-NEXT: move $4, $5 173; MIPS32_PIC-NEXT: lw $5, 16($sp) # 4-byte Folded Reload 174; MIPS32_PIC-NEXT: jal memcpy 175; MIPS32_PIC-NEXT: nop 176; MIPS32_PIC-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload 177; MIPS32_PIC-NEXT: addiu $sp, $sp, 24 178; MIPS32_PIC-NEXT: jr $ra 179; MIPS32_PIC-NEXT: nop 180entry: 181 call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 1 %dest, i8* align 1 %src, i32 %length, i1 false) 182 ret void 183} 184