1; RUN: llc -O2 -mtriple powerpc64-ibm-aix-xcoff -mcpu=ppc -stop-after=machine-cp -verify-machineinstrs < %s | \ 2; RUN: FileCheck --check-prefix=64BIT %s 3 4; RUN: llc -O2 -verify-machineinstrs -mcpu=pwr4 -mattr=-altivec \ 5; RUN: -mtriple powerpc64-ibm-aix-xcoff < %s | \ 6; RUN: FileCheck --check-prefix=ASM64 %s 7 8 define i32 @int_va_arg(i32 %a, ...) local_unnamed_addr { 9 entry: 10 %arg1 = alloca ptr, align 8 11 %arg2 = alloca ptr, align 8 12 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg1) 13 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg2) 14 call void @llvm.va_start(ptr nonnull %arg1) 15 call void @llvm.va_copy(ptr nonnull %arg2, ptr nonnull %arg1) 16 %0 = va_arg ptr %arg1, i32 17 %add = add nsw i32 %0, %a 18 %1 = va_arg ptr %arg2, i32 19 %mul = shl i32 %1, 1 20 %add3 = add nsw i32 %add, %mul 21 call void @llvm.va_end(ptr nonnull %arg1) 22 call void @llvm.va_end(ptr nonnull %arg2) 23 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg2) 24 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg1) 25 ret i32 %add3 26 } 27 28 declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) 29 declare void @llvm.va_start(ptr) 30 declare void @llvm.va_copy(ptr, ptr) 31 declare void @llvm.va_end(ptr) 32 declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) 33 34; 64BIT-LABEL: name: int_va_arg 35; 64BIT-LABEL: liveins: 36; 64BIT-DAG: - { reg: '$x3', virtual-reg: '' } 37; 64BIT-DAG: - { reg: '$x4', virtual-reg: '' } 38; 64BIT-DAG: - { reg: '$x5', virtual-reg: '' } 39; 64BIT-DAG: - { reg: '$x6', virtual-reg: '' } 40; 64BIT-DAG: - { reg: '$x7', virtual-reg: '' } 41; 64BIT-DAG: - { reg: '$x8', virtual-reg: '' } 42; 64BIT-DAG: - { reg: '$x9', virtual-reg: '' } 43; 64BIT-DAG: - { reg: '$x10', virtual-reg: '' } 44 45; 64BIT-LABEL: fixedStack: 46; 64BIT-DAG: - { id: 0, type: default, offset: 56, size: 8 47 48; 64BIT-LABEL: stack: 49; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8 50; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8 51 52; 64BIT-LABEL: body: | 53; 64BIT-DAG: bb.0.entry: 54; 64BIT-DAG: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10 55; 64BIT-DAG: STD killed renamable $x4, 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0) 56; 64BIT-DAG: STD killed renamable $x5, 8, %fixed-stack.0 :: (store (s64) into %fixed-stack.0 + 8) 57; 64BIT-DAG: STD killed renamable $x6, 16, %fixed-stack.0 :: (store (s64)) 58; 64BIT-DAG: STD killed renamable $x7, 24, %fixed-stack.0 :: (store (s64)) 59; 64BIT-DAG: STD killed renamable $x8, 32, %fixed-stack.0 :: (store (s64)) 60; 64BIT-DAG: STD killed renamable $x9, 40, %fixed-stack.0 :: (store (s64)) 61; 64BIT-DAG: STD killed renamable $x10, 48, %fixed-stack.0 :: (store (s64)) 62; 64BIT-DAG: renamable $x11 = ADDI8 %fixed-stack.0, 0 63; 64BIT-DAG: STD renamable $x11, 0, %stack.1.arg2 :: (store (s64) into %ir.arg2) 64; 64BIT-DAG: renamable $x6 = LD 0, %stack.1.arg2 :: (load (s64) from %ir.arg2) 65; 64BIT-DAG: renamable $x9 = ADDI8 renamable $x6, 4 66; 64BIT-DAG: renamable $x7 = disjoint ADDI8 %fixed-stack.0, 4 67; 64BIT-DAG: renamable $r8 = LWZ 0, %fixed-stack.0 :: (load (s32) from %fixed-stack.0, align 8) 68; 64BIT-DAG: STD killed renamable $x11, 0, %stack.0.arg1 :: (store (s64) into %ir.arg1) 69; 64BIT-DAG: STD killed renamable $x7, 0, %stack.0.arg1 :: (store (s64) into %ir.arg1) 70; 64BIT-DAG: STD killed renamable $x9, 0, %stack.1.arg2 :: (store (s64) into %ir.arg2) 71; 64BIT-DAG: renamable $r4 = LWZ 0, killed renamable $x6 :: (load (s32)) 72; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r8, renamable $r3, implicit killed $x3 73; 64BIT-DAG: renamable $r4 = RLWINM killed renamable $r4, 1, 0, 30 74; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, killed renamable $r4, implicit-def $x3 75; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $x3 76 77; ASM64-LABEL: .int_va_arg: 78; ASM64-DAG: std 4, 56(1) 79; ASM64-DAG: addi 4, 1, 56 80; ASM64-DAG: std 4, -16(1) 81; ASM64-DAG: std 4, -8(1) 82; ASM64-DAG: ld 4, -16(1) 83; ASM64-DAG: std 5, 64(1) 84; ASM64-DAG: addi 5, 1, 60 85; ASM64-DAG: std 5, -8(1) 86; ASM64-DAG: addi 5, 4, 4 87; ASM64-DAG: std 6, 72(1) 88; ASM64-DAG: std 7, 80(1) 89; ASM64-DAG: std 8, 88(1) 90; ASM64-DAG: std 9, 96(1) 91; ASM64-DAG: std 10, 104(1) 92; ASM64-DAG: std 5, -16(1) 93; ASM64-DAG: lwz 11, 56(1) 94; ASM64-DAG: lwz 4, 0(4) 95; ASM64-DAG: add 3, 11, 3 96; ASM64-DAG: slwi 4, 4, 1 97; ASM64-DAG: add 3, 3, 4 98; ASM64-DAG: blr 99 100 define i32 @int_stack_va_arg(i32 %one, i32 %two, i32 %three, i32 %four, i32 %five, i32 %six, i32 %seven, i32 %eight, ...) local_unnamed_addr { 101 entry: 102 %arg1 = alloca ptr, align 8 103 %arg2 = alloca ptr, align 8 104 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg1) 105 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg2) 106 call void @llvm.va_start(ptr nonnull %arg1) 107 call void @llvm.va_copy(ptr nonnull %arg2, ptr nonnull %arg1) 108 %add = add nsw i32 %two, %one 109 %add2 = add nsw i32 %add, %three 110 %add3 = add nsw i32 %add2, %four 111 %add4 = add nsw i32 %add3, %five 112 %add5 = add nsw i32 %add4, %six 113 %add6 = add nsw i32 %add5, %seven 114 %add7 = add nsw i32 %add6, %eight 115 %0 = va_arg ptr %arg1, i32 116 %add8 = add nsw i32 %add7, %0 117 %1 = va_arg ptr %arg2, i32 118 %mul = shl i32 %1, 1 119 %add10 = add nsw i32 %add8, %mul 120 call void @llvm.va_end(ptr nonnull %arg1) 121 call void @llvm.va_end(ptr nonnull %arg2) 122 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg2) 123 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg1) 124 ret i32 %add10 125 } 126 127; 64BIT-LABEL: name: int_stack_va_arg 128; 64BIT-LABEL: liveins: 129; 64BIT-DAG: - { reg: '$x3', virtual-reg: '' } 130; 64BIT-DAG: - { reg: '$x4', virtual-reg: '' } 131; 64BIT-DAG: - { reg: '$x5', virtual-reg: '' } 132; 64BIT-DAG: - { reg: '$x6', virtual-reg: '' } 133; 64BIT-DAG: - { reg: '$x7', virtual-reg: '' } 134; 64BIT-DAG: - { reg: '$x8', virtual-reg: '' } 135; 64BIT-DAG: - { reg: '$x9', virtual-reg: '' } 136; 64BIT-DAG: - { reg: '$x10', virtual-reg: '' } 137 138; 64BIT-LABEL: fixedStack: 139; 64BIT-DAG: - { id: 0, type: default, offset: 112, size: 8, alignment: 16, stack-id: default, 140 141; 64BIT-LABEL: stack: 142; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8, alignment: 8, 143; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8, alignment: 8, 144 145; 64BIT-LABEL: body: | 146; 64BIT-DAG: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10 147; 64BIT-DAG: renamable $r11 = LWZ 0, %fixed-stack.0 :: (load (s32) from %fixed-stack.0, align 16) 148; 64BIT-DAG: renamable $r3 = nsw ADD4 renamable $r4, renamable $r3, implicit killed $x3, implicit killed $x4 149; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r5, implicit killed $x5 150; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r6, implicit killed $x6 151; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r7, implicit killed $x7 152; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r8, implicit killed $x8 153; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r9, implicit killed $x9 154; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r10, implicit killed $x10 155; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, renamable $r11 156; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, killed renamable $r4, implicit-def $x3 157; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $x3 158 159; ASM64-LABEL: .int_stack_va_arg: 160; ASM64-DAG: add 3, 4, 3 161; ASM64-DAG: add 3, 3, 5 162; ASM64-DAG: add 3, 3, 6 163; ASM64-DAG: add 3, 3, 7 164; ASM64-DAG: add 3, 3, 8 165; ASM64-DAG: add 3, 3, 9 166; ASM64-DAG: add 3, 3, 10 167; ASM64-DAG: lwz 11, 112(1) 168; ASM64-DAG: slwi 4, 11, 1 169; ASM64-DAG: add 3, 3, 11 170; ASM64-DAG: add 3, 3, 4 171; ASM64-DAG: blr 172 173 define double @double_va_arg(double %a, ...) local_unnamed_addr { 174 entry: 175 %arg1 = alloca ptr, align 8 176 %arg2 = alloca ptr, align 8 177 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg1) 178 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg2) 179 call void @llvm.va_start(ptr nonnull %arg1) 180 call void @llvm.va_copy(ptr nonnull %arg2, ptr nonnull %arg1) 181 %0 = va_arg ptr %arg1, double 182 %add = fadd double %0, %a 183 %1 = va_arg ptr %arg2, double 184 %mul = fmul double %1, 2.000000e+00 185 %add3 = fadd double %add, %mul 186 call void @llvm.va_end(ptr nonnull %arg1) 187 call void @llvm.va_end(ptr nonnull %arg2) 188 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg2) 189 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg1) 190 ret double %add3 191 } 192 193; 64BIT-LABEL: name: double_va_arg 194; 64BIT-LABEL: liveins: 195; 64BIT-DAG: - { reg: '$f1', virtual-reg: '' } 196; 64BIT-DAG: - { reg: '$x4', virtual-reg: '' } 197; 64BIT-DAG: - { reg: '$x5', virtual-reg: '' } 198; 64BIT-DAG: - { reg: '$x6', virtual-reg: '' } 199; 64BIT-DAG: - { reg: '$x7', virtual-reg: '' } 200; 64BIT-DAG: - { reg: '$x8', virtual-reg: '' } 201; 64BIT-DAG: - { reg: '$x9', virtual-reg: '' } 202; 64BIT-DAG: - { reg: '$x10', virtual-reg: '' } 203 204; 64BIT-LABEL: fixedStack: 205; 64BIT-DAG: - { id: 0, type: default, offset: 56, size: 8 206 207; 64BIT-LABEL: stack: 208; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8 209; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8 210 211; 64BIT-LABEL: body: | 212; 64BIT-DAG: liveins: $f1, $x4, $x5, $x6, $x7, $x8, $x9, $x10 213; 64BIT-DAG: renamable $x3 = ADDI8 %fixed-stack.0, 0 214; 64BIT-DAG: STD killed renamable $x4, 0, %fixed-stack.0 :: (store (s64) into %fixed-stack.0) 215; 64BIT-DAG: STD killed renamable $x5, 8, %fixed-stack.0 :: (store (s64) into %fixed-stack.0 + 8) 216; 64BIT-DAG: STD killed renamable $x6, 16, %fixed-stack.0 :: (store (s64)) 217; 64BIT-DAG: STD killed renamable $x7, 24, %fixed-stack.0 :: (store (s64)) 218; 64BIT-DAG: STD killed renamable $x8, 32, %fixed-stack.0 :: (store (s64)) 219; 64BIT-DAG: STD killed renamable $x9, 40, %fixed-stack.0 :: (store (s64)) 220; 64BIT-DAG: STD killed renamable $x10, 48, %fixed-stack.0 :: (store (s64)) 221; 64BIT-DAG: STD renamable $x3, 0, %stack.1.arg2 :: (store (s64) into %ir.arg2) 222; 64BIT-DAG: renamable $x6 = LD 0, %stack.1.arg2 :: (load (s64) from %ir.arg2) 223; 64BIT-DAG: renamable $x7 = ADDI8 %fixed-stack.0, 8 224; 64BIT-DAG: STD killed renamable $x3, 0, %stack.0.arg1 :: (store (s64) into %ir.arg1) 225; 64BIT-DAG: STD killed renamable $x7, 0, %stack.0.arg1 :: (store (s64) into %ir.arg1) 226; 64BIT-DAG: renamable $f0 = LFD 0, %fixed-stack.0 :: (load (s64)) 227; 64BIT-DAG: renamable $x3 = ADDI8 renamable $x6, 8 228; 64BIT-DAG: STD killed renamable $x3, 0, %stack.1.arg2 :: (store (s64) into %ir.arg2) 229; 64BIT-DAG: renamable $f2 = LFD 0, killed renamable $x6 :: (load (s64)) 230; 64BIT-DAG: renamable $f0 = nofpexcept FADD killed renamable $f0, killed renamable $f1, implicit $rm 231; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f2, renamable $f2, implicit $rm 232; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f0, killed renamable $f1, implicit $rm 233; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $f1 234 235; ASM64-LABEL: .double_va_arg: 236; ASM64-DAG: addi 3, 1, 56 237; ASM64-DAG: std 4, 56(1) 238; ASM64-DAG: std 3, -8(1) 239; ASM64-DAG: std 3, -16(1) 240; ASM64-DAG: addi 3, 1, 64 241; ASM64-DAG: std 3, -8(1) 242; ASM64-DAG: ld 3, -16(1) 243; ASM64-DAG: lfd 0, 56(1) 244; ASM64-DAG: addi 4, 3, 8 245; ASM64-DAG: std 5, 64(1) 246; ASM64-DAG: fadd 0, 0, 1 247; ASM64-DAG: std 6, 72(1) 248; ASM64-DAG: std 7, 80(1) 249; ASM64-DAG: std 8, 88(1) 250; ASM64-DAG: std 9, 96(1) 251; ASM64-DAG: std 10, 104(1) 252; ASM64-DAG: std 4, -16(1) 253; ASM64-DAG: lfd 1, 0(3) 254; ASM64-DAG: fadd 1, 1, 1 255; ASM64-DAG: fadd 1, 0, 1 256; ASM64-DAG: blr 257 258 define double @double_stack_va_arg(double %one, double %two, double %three, double %four, double %five, double %six, double %seven, double %eight, double %nine, double %ten, double %eleven, double %twelve, double %thirteen, ...) local_unnamed_addr { 259 entry: 260 %arg1 = alloca ptr, align 8 261 %arg2 = alloca ptr, align 8 262 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg1) 263 call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %arg2) 264 call void @llvm.va_start(ptr nonnull %arg1) 265 call void @llvm.va_copy(ptr nonnull %arg2, ptr nonnull %arg1) 266 %add = fadd double %one, %two 267 %add2 = fadd double %add, %three 268 %add3 = fadd double %add2, %four 269 %add4 = fadd double %add3, %five 270 %add5 = fadd double %add4, %six 271 %add6 = fadd double %add5, %seven 272 %add7 = fadd double %add6, %eight 273 %add8 = fadd double %add7, %nine 274 %add9 = fadd double %add8, %ten 275 %add10 = fadd double %add9, %eleven 276 %add11 = fadd double %add10, %twelve 277 %add12 = fadd double %add11, %thirteen 278 %0 = va_arg ptr %arg1, double 279 %add13 = fadd double %add12, %0 280 %1 = va_arg ptr %arg2, double 281 %mul = fmul double %1, 2.000000e+00 282 %add15 = fadd double %add13, %mul 283 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg2) 284 call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %arg1) 285 ret double %add15 286 } 287 288 289; 64BIT-LABEL: name: double_stack_va_arg 290; 64BIT-LABEL: liveins: 291; 64BIT-DAG: - { reg: '$f1', virtual-reg: '' } 292; 64BIT-DAG: - { reg: '$f2', virtual-reg: '' } 293; 64BIT-DAG: - { reg: '$f3', virtual-reg: '' } 294; 64BIT-DAG: - { reg: '$f4', virtual-reg: '' } 295; 64BIT-DAG: - { reg: '$f5', virtual-reg: '' } 296; 64BIT-DAG: - { reg: '$f6', virtual-reg: '' } 297; 64BIT-DAG: - { reg: '$f7', virtual-reg: '' } 298; 64BIT-DAG: - { reg: '$f8', virtual-reg: '' } 299; 64BIT-DAG: - { reg: '$f9', virtual-reg: '' } 300; 64BIT-DAG: - { reg: '$f10', virtual-reg: '' } 301; 64BIT-DAG: - { reg: '$f11', virtual-reg: '' } 302; 64BIT-DAG: - { reg: '$f12', virtual-reg: '' } 303; 64BIT-DAG: - { reg: '$f13', virtual-reg: '' } 304 305; 64BIT-LABEL: fixedStack: 306; 64BIT-DAG: - { id: 0, type: default, offset: 152, size: 8 307 308; 64BIT-LABEL: stack: 309; 64BIT-DAG: - { id: 0, name: arg1, type: default, offset: 0, size: 8 310; 64BIT-DAG: - { id: 1, name: arg2, type: default, offset: 0, size: 8 311 312; 64BIT-LABEL: body: | 313; 64BIT-DAG: liveins: $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8, $f9, $f10, $f11, $f12, $f13 314; 64BIT-DAG: renamable $f0 = LFD 0, %fixed-stack.0 :: (load (s64)) 315; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f2, implicit $rm 316; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f3, implicit $rm 317; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f4, implicit $rm 318; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f5, implicit $rm 319; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f6, implicit $rm 320; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f7, implicit $rm 321; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f8, implicit $rm 322; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f9, implicit $rm 323; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f10, implicit $rm 324; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f11, implicit $rm 325; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f12, implicit $rm 326; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f13, implicit $rm 327; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, renamable $f0, implicit $rm 328; 64BIT-DAG: renamable $f0 = nofpexcept FADD killed renamable $f0, renamable $f0, implicit $rm 329; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f1, killed renamable $f0, implicit $rm 330; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $f1 331 332; ASM64-LABEL: .double_stack_va_arg: 333; ASM64-DAG: fadd 1, 1, 2 334; ASM64-DAG: fadd 1, 1, 3 335; ASM64-DAG: fadd 1, 1, 4 336; ASM64-DAG: fadd 1, 1, 5 337; ASM64-DAG: fadd 1, 1, 6 338; ASM64-DAG: fadd 1, 1, 7 339; ASM64-DAG: fadd 1, 1, 8 340; ASM64-DAG: fadd 1, 1, 9 341; ASM64-DAG: fadd 1, 1, 10 342; ASM64-DAG: fadd 1, 1, 11 343; ASM64-DAG: fadd 1, 1, 12 344; ASM64-DAG: fadd 1, 1, 13 345; ASM64-DAG: lfd 0, 152(1) 346; ASM64-DAG: fadd 1, 1, 0 347; ASM64-DAG: fadd 0, 0, 0 348; ASM64-DAG: fadd 1, 1, 0 349; ASM64-DAG: blr 350