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