320 lines · plain
1; RUN: llc < %s -mtriple=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \2; RUN: --check-prefixes=ALL,GP32,GP32-M3; RUN: llc < %s -mtriple=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \4; RUN: --check-prefixes=ALL,GP32,GP32-M5; RUN: llc < %s -mtriple=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \6; RUN: --check-prefixes=ALL,GP32,GP32-M7; RUN: llc < %s -mtriple=mips -mcpu=mips32r2 -mattr=+micromips -relocation-model=pic | FileCheck %s \8; RUN: --check-prefixes=ALL,GP32,GP32-MM,GP32-MMR29; RUN: llc < %s -mtriple=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \10; RUN: --check-prefixes=ALL,GP32,GP32-MM,GP32-MMR611; RUN: llc < %s -mtriple=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \12; RUN: --check-prefixes=ALL,GP64,N6413; RUN: llc < %s -mtriple=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \14; RUN: --check-prefixes=ALL,GP64,N6415; RUN: llc < %s -mtriple=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \16; RUN: --check-prefixes=ALL,GP64,N6417; RUN: llc < %s -mtriple=mips64 -mcpu=mips3 -target-abi n32 -relocation-model=pic | FileCheck %s \18; RUN: --check-prefixes=ALL,GP64,N3219; RUN: llc < %s -mtriple=mips64 -mcpu=mips64 -target-abi n32 -relocation-model=pic | FileCheck %s \20; RUN: --check-prefixes=ALL,GP64,N3221; RUN: llc < %s -mtriple=mips64 -mcpu=mips64r6 -target-abi n32 -relocation-model=pic | FileCheck %s \22; RUN: --check-prefixes=ALL,GP64,N3223 24; Check dynamic stack realignment in functions without variable-sized objects.25 26declare void @helper_01(i32, i32, i32, i32, ptr)27 28; O32 ABI29define void @func_01() {30entry:31; GP32-LABEL: func_01:32 33 ; prologue34 ; FIXME: We are currently over-allocating stack space. This particular case35 ; needs a frame of up to between 16 and 512-bytes but currently36 ; allocates between 1024 and 1536 bytes37 ; GP32-M: addiu $sp, $sp, -102438 ; GP32-MMR2: addiusp -102439 ; GP32-MMR6: addiu $sp, $sp, -102440 ; GP32: sw $ra, 1020($sp)41 ; GP32: sw $fp, 1016($sp)42 ;43 ; GP32: move $fp, $sp44 ; GP32: addiu $[[T0:[0-9]+|ra|gp]], $zero, -51245 ; GP32-NEXT: and $sp, $sp, $[[T0]]46 47 ; body48 ; GP32: addiu $[[T1:[0-9]+]], $sp, 51249 ; GP32-M: sw $[[T1]], 16($sp)50 ; GP32-MM: sw16 $[[T1]], 16(${{[0-9]+}})51 52 ; epilogue53 ; GP32: move $sp, $fp54 ; GP32: lw $fp, 1016($sp)55 ; GP32: lw $ra, 1020($sp)56 ; GP32-M: addiu $sp, $sp, 102457 ; GP32-MMR2: addiusp 102458 ; GP32-MMR6: addiu $sp, $sp, 102459 60 %a = alloca i32, align 51261 call void @helper_01(i32 0, i32 0, i32 0, i32 0, ptr %a)62 ret void63}64 65declare void @helper_02(i32, i32, i32, i32,66 i32, i32, i32, i32, ptr)67 68; N32/N64 ABIs69define void @func_02() {70entry:71; GP64-LABEL: func_02:72 73 ; prologue74 ; FIXME: We are currently over-allocating stack space. This particular case75 ; needs a frame of up to between 16 and 512-bytes but currently76 ; allocates between 1024 and 1536 bytes77 ; N32: addiu $sp, $sp, -102478 ; N64: daddiu $sp, $sp, -102479 ; GP64: sd $ra, 1016($sp)80 ; GP64: sd $fp, 1008($sp)81 ; N32: sd $gp, 1000($sp)82 ;83 ; GP64: move $fp, $sp84 ; N32: addiu $[[T0:[0-9]+|ra]], $zero, -51285 ; N64: daddiu $[[T0:[0-9]+|ra]], $zero, -51286 ; GP64-NEXT: and $sp, $sp, $[[T0]]87 88 ; body89 ; N32: addiu $[[T1:[0-9]+]], $sp, 51290 ; N64: daddiu $[[T1:[0-9]+]], $sp, 51291 ; GP64: sd $[[T1]], 0($sp)92 93 ; epilogue94 ; GP64: move $sp, $fp95 ; N32: ld $gp, 1000($sp)96 ; GP64: ld $fp, 1008($sp)97 ; GP64: ld $ra, 1016($sp)98 ; N32: addiu $sp, $sp, 102499 ; N64: daddiu $sp, $sp, 1024100 101 %a = alloca i32, align 512102 call void @helper_02(i32 0, i32 0, i32 0, i32 0,103 i32 0, i32 0, i32 0, i32 0, ptr %a)104 ret void105}106 107; Verify that we use $fp for referencing incoming arguments.108 109declare void @helper_03(i32, i32, i32, i32, ptr, ptr)110 111; O32 ABI112define void @func_03(i32 %p0, i32 %p1, i32 %p2, i32 %p3, ptr %b) {113entry:114; GP32-LABEL: func_03:115 116 ; body117 ; FIXME: We are currently over-allocating stack space.118 ; GP32-DAG: addiu $[[T0:[0-9]+]], $sp, 512119 ; GP32-M-DAG: sw $[[T0]], 16($sp)120 ; GP32-MM-DAG: sw16 $[[T0]], 16(${{[0-9]+}})121 ; GP32-DAG: lw $[[T1:[0-9]+]], 1040($fp)122 ; GP32-M-DAG: sw $[[T1]], 20($sp)123 ; GP32-MM-DAG: sw16 $[[T1]], 20(${{[0-9]+}})124 125 %a = alloca i32, align 512126 call void @helper_03(i32 0, i32 0, i32 0, i32 0, ptr %a, ptr %b)127 ret void128}129 130declare void @helper_04(i32, i32, i32, i32,131 i32, i32, i32, i32, ptr, ptr)132 133; N32/N64 ABIs134define void @func_04(i32 %p0, i32 %p1, i32 %p2, i32 %p3,135 i32 %p4, i32 %p5, i32 %p6, i32 %p7,136 ptr %b) {137entry:138; GP64-LABEL: func_04:139 140 ; body141 ; FIXME: We are currently over-allocating stack space.142 ; N32-DAG: addiu $[[T0:[0-9]+]], $sp, 512143 ; N64-DAG: daddiu $[[T0:[0-9]+]], $sp, 512144 ; GP64-DAG: sd $[[T0]], 0($sp)145 ; GP64-DAG: ld $[[T1:[0-9]+]], 1024($fp)146 ; GP64-DAG: sd $[[T1]], 8($sp)147 148 %a = alloca i32, align 512149 call void @helper_04(i32 0, i32 0, i32 0, i32 0,150 i32 0, i32 0, i32 0, i32 0, ptr %a, ptr %b)151 ret void152}153 154; Check dynamic stack realignment in functions with variable-sized objects.155 156; O32 ABI157define void @func_05(i32 %sz) {158entry:159; GP32-LABEL: func_05:160 161 ; prologue162 ; FIXME: We are currently over-allocating stack space.163 ; GP32-M: addiu $sp, $sp, -1024164 ; GP32-MMR2: addiusp -1024165 ; GP32-MMR6: addiu $sp, $sp, -1024166 ; GP32: sw $ra, 1020($sp)167 ; GP32: sw $fp, 1016($sp)168 ; GP32: sw $23, 1012($sp)169 ;170 ; GP32: move $fp, $sp171 ; GP32: addiu $[[T0:[0-9]+|gp]], $zero, -512172 ; GP32-NEXT: and $sp, $sp, $[[T0]]173 ; GP32-NEXT: move $23, $sp174 175 ; body176 ; GP32: addiu $[[T1:[0-9]+]], $zero, 222177 ; GP32: sw $[[T1]], 508($23)178 179 ; epilogue180 ; GP32: move $sp, $fp181 ; GP32: lw $23, 1012($sp)182 ; GP32: lw $fp, 1016($sp)183 ; GP32: lw $ra, 1020($sp)184 ; GP32-M: addiu $sp, $sp, 1024185 ; GP32-MMR2: addiusp 1024186 ; GP32-MMR6: addiu $sp, $sp, 1024187 188 %a0 = alloca i32, i32 %sz, align 512189 %a1 = alloca i32, align 4190 191 store volatile i32 111, ptr %a0, align 512192 store volatile i32 222, ptr %a1, align 4193 194 ret void195}196 197; N32/N64 ABIs198define void @func_06(i32 %sz) {199entry:200; GP64-LABEL: func_06:201 202 ; prologue203 ; FIXME: We are currently over-allocating stack space.204 ; N32: addiu $sp, $sp, -1024205 ; N64: daddiu $sp, $sp, -1024206 ; GP64: sd $ra, 1016($sp)207 ; GP64: sd $fp, 1008($sp)208 ; GP64: sd $23, 1000($sp)209 ;210 ; GP64: move $fp, $sp211 ; GP64: addiu $[[T0:[0-9]+|gp]], $zero, -512212 ; GP64-NEXT: and $sp, $sp, $[[T0]]213 ; GP64-NEXT: move $23, $sp214 215 ; body216 ; GP64: addiu $[[T1:[0-9]+]], $zero, 222217 ; GP64: sw $[[T1]], 508($23)218 219 ; epilogue220 ; GP64: move $sp, $fp221 ; GP64: ld $23, 1000($sp)222 ; GP64: ld $fp, 1008($sp)223 ; GP64: ld $ra, 1016($sp)224 ; N32: addiu $sp, $sp, 1024225 ; N64: daddiu $sp, $sp, 1024226 227 %a0 = alloca i32, i32 %sz, align 512228 %a1 = alloca i32, align 4229 230 store volatile i32 111, ptr %a0, align 512231 store volatile i32 222, ptr %a1, align 4232 233 ret void234}235 236; Verify that we use $fp for referencing incoming arguments and $sp for237; building outbound arguments for nested function calls.238 239; O32 ABI240define void @func_07(i32 %p0, i32 %p1, i32 %p2, i32 %p3, i32 %sz) {241entry:242; GP32-LABEL: func_07:243 244 ; body245 ; FIXME: We are currently over-allocating stack space.246 ; GP32-DAG: lw $[[T0:[0-9]+]], 1040($fp)247 ;248 ; GP32-DAG: addiu $[[T1:[0-9]+]], $zero, 222249 ; GP32-DAG: sw $[[T1]], 508($23)250 ;251 ; GP32-M-DAG: sw $[[T2:[0-9]+]], 16($sp)252 ; GP32-MM-DAG: sw16 $[[T2:[0-9]+]], 16($[[T3:[0-9]+]])253 254 %a0 = alloca i32, i32 %sz, align 512255 %a1 = alloca i32, align 4256 257 store volatile i32 111, ptr %a0, align 512258 store volatile i32 222, ptr %a1, align 4259 260 call void @helper_01(i32 0, i32 0, i32 0, i32 0, ptr %a1)261 262 ret void263}264 265; N32/N64 ABIs266define void @func_08(i32 %p0, i32 %p1, i32 %p2, i32 %p3,267 i32 %p4, i32 %p5, i32 %p6, i32 %p7,268 i32 %sz) {269entry:270; GP64-LABEL: func_08:271 272 ; body273 ; FIXME: We are currently over-allocating stack space.274 ; N32-DAG: lw $[[T0:[0-9]+]], 1028($fp)275 ; N64-DAG: lwu $[[T0:[0-9]+]], 1028($fp)276 ;277 ; GP64-DAG: addiu $[[T1:[0-9]+]], $zero, 222278 ; GP64-DAG: sw $[[T1]], 508($23)279 ;280 ; GP64-DAG: sd $[[T2:[0-9]+]], 0($sp)281 282 %a0 = alloca i32, i32 %sz, align 512283 %a1 = alloca i32, align 4284 285 store volatile i32 111, ptr %a0, align 512286 store volatile i32 222, ptr %a1, align 4287 288 call void @helper_02(i32 0, i32 0, i32 0, i32 0,289 i32 0, i32 0, i32 0, i32 0, ptr %a1)290 ret void291}292 293; Check that we do not perform dynamic stack realignment in the presence of294; the "no-realign-stack" function attribute.295define void @func_09() "no-realign-stack" {296entry:297; ALL-LABEL: func_09:298 299 ; ALL-NOT: and $sp, $sp, $[[T0:[0-9]+|ra|gp]]300 301 %a = alloca i32, align 512302 call void @helper_01(i32 0, i32 0, i32 0, i32 0, ptr %a)303 ret void304}305 306define void @func_10(i32 %sz) "no-realign-stack" {307entry:308; ALL-LABEL: func_10:309 310 ; ALL-NOT: and $sp, $sp, $[[T0:[0-9]+|ra|gp]]311 312 %a0 = alloca i32, i32 %sz, align 512313 %a1 = alloca i32, align 4314 315 store volatile i32 111, ptr %a0, align 512316 store volatile i32 222, ptr %a1, align 4317 318 ret void319}320