llvm.org GIT mirror llvm / 8dffc81
Model the carry bit on ppc32. Without this we could move a SUBFC (etc.) below the SUBFE (etc.) that consumed the carry bit. Add missing ADDIC8, noticed along the way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82266 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 10 years ago
4 changed file(s) with 122 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
6767 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
6868 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
6969 LR8,CTR8,
70 CR0,CR1,CR5,CR6,CR7] in {
70 CR0,CR1,CR5,CR6,CR7,CARRY] in {
7171 // Convenient aliases for call instructions
7272 let Uses = [RM] in {
7373 def BL8_Darwin : IForm<18, 0, 1,
9393 F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F11,F12,F13,
9494 V0,V1,V2,V3,V4,V5,V6,V7,V8,V9,V10,V11,V12,V13,V14,V15,V16,V17,V18,V19,
9595 LR8,CTR8,
96 CR0,CR1,CR5,CR6,CR7] in {
96 CR0,CR1,CR5,CR6,CR7,CARRY] in {
9797 // Convenient aliases for call instructions
9898 let Uses = [RM] in {
9999 def BL8_ELF : IForm<18, 0, 1,
328328 "add $rT, $rA, $rB", IntGeneral,
329329 [(set G8RC:$rT, (add G8RC:$rA, G8RC:$rB))]>;
330330
331 let Defs = [CARRY] in {
331332 def ADDC8 : XOForm_1<31, 10, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
332333 "addc $rT, $rA, $rB", IntGeneral,
333334 [(set G8RC:$rT, (addc G8RC:$rA, G8RC:$rB))]>,
334335 PPC970_DGroup_Cracked;
335 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
336 "adde $rT, $rA, $rB", IntGeneral,
337 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
338
336 def ADDIC8 : DForm_2<12, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
337 "addic $rD, $rA, $imm", IntGeneral,
338 [(set G8RC:$rD, (addc G8RC:$rA, immSExt16:$imm))]>;
339 }
339340 def ADDI8 : DForm_2<14, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
340341 "addi $rD, $rA, $imm", IntGeneral,
341342 [(set G8RC:$rD, (add G8RC:$rA, immSExt16:$imm))]>;
343344 "addis $rD, $rA, $imm", IntGeneral,
344345 [(set G8RC:$rD, (add G8RC:$rA, imm16ShiftedSExt:$imm))]>;
345346
347 let Defs = [CARRY] in {
346348 def SUBFIC8: DForm_2< 8, (outs G8RC:$rD), (ins G8RC:$rA, s16imm64:$imm),
347349 "subfic $rD, $rA, $imm", IntGeneral,
348350 [(set G8RC:$rD, (subc immSExt16:$imm, G8RC:$rA))]>;
349 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
350 "subf $rT, $rA, $rB", IntGeneral,
351 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
352351 def SUBFC8 : XOForm_1<31, 8, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
353352 "subfc $rT, $rA, $rB", IntGeneral,
354353 [(set G8RC:$rT, (subc G8RC:$rB, G8RC:$rA))]>,
355354 PPC970_DGroup_Cracked;
356
357 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
358 "subfe $rT, $rA, $rB", IntGeneral,
359 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
355 }
356 def SUBF8 : XOForm_1<31, 40, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
357 "subf $rT, $rA, $rB", IntGeneral,
358 [(set G8RC:$rT, (sub G8RC:$rB, G8RC:$rA))]>;
359 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
360 "neg $rT, $rA", IntGeneral,
361 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
362 let Uses = [CARRY], Defs = [CARRY] in {
363 def ADDE8 : XOForm_1<31, 138, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
364 "adde $rT, $rA, $rB", IntGeneral,
365 [(set G8RC:$rT, (adde G8RC:$rA, G8RC:$rB))]>;
360366 def ADDME8 : XOForm_3<31, 234, 0, (outs G8RC:$rT), (ins G8RC:$rA),
361367 "addme $rT, $rA", IntGeneral,
362368 [(set G8RC:$rT, (adde G8RC:$rA, immAllOnes))]>;
363369 def ADDZE8 : XOForm_3<31, 202, 0, (outs G8RC:$rT), (ins G8RC:$rA),
364370 "addze $rT, $rA", IntGeneral,
365371 [(set G8RC:$rT, (adde G8RC:$rA, 0))]>;
366 def NEG8 : XOForm_3<31, 104, 0, (outs G8RC:$rT), (ins G8RC:$rA),
367 "neg $rT, $rA", IntGeneral,
368 [(set G8RC:$rT, (ineg G8RC:$rA))]>;
372 def SUBFE8 : XOForm_1<31, 136, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
373 "subfe $rT, $rA, $rB", IntGeneral,
374 [(set G8RC:$rT, (sube G8RC:$rB, G8RC:$rA))]>;
369375 def SUBFME8 : XOForm_3<31, 232, 0, (outs G8RC:$rT), (ins G8RC:$rA),
370376 "subfme $rT, $rA", IntGeneral,
371377 [(set G8RC:$rT, (sube immAllOnes, G8RC:$rA))]>;
372378 def SUBFZE8 : XOForm_3<31, 200, 0, (outs G8RC:$rT), (ins G8RC:$rA),
373379 "subfze $rT, $rA", IntGeneral,
374380 [(set G8RC:$rT, (sube 0, G8RC:$rA))]>;
375
381 }
376382
377383
378384 def MULHD : XOForm_1<31, 73, 0, (outs G8RC:$rT), (ins G8RC:$rA, G8RC:$rB),
397403 def SRD : XForm_6<31, 539, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
398404 "srd $rA, $rS, $rB", IntRotateD,
399405 [(set G8RC:$rA, (PPCsrl G8RC:$rS, GPRC:$rB))]>, isPPC64;
406 let Defs = [CARRY] in {
400407 def SRAD : XForm_6<31, 794, (outs G8RC:$rA), (ins G8RC:$rS, GPRC:$rB),
401408 "srad $rA, $rS, $rB", IntRotateD,
402409 [(set G8RC:$rA, (PPCsra G8RC:$rS, GPRC:$rB))]>, isPPC64;
410 }
403411
404412 def EXTSB8 : XForm_11<31, 954, (outs G8RC:$rA), (ins G8RC:$rS),
405413 "extsb $rA, $rS", IntGeneral,
419427 "extsw $rA, $rS", IntGeneral,
420428 [(set G8RC:$rA, (sext GPRC:$rS))]>, isPPC64;
421429
430 let Defs = [CARRY] in {
422431 def SRADI : XSForm_1<31, 413, (outs G8RC:$rA), (ins G8RC:$rS, u6imm:$SH),
423432 "sradi $rA, $rS, $SH", IntRotateD,
424433 [(set G8RC:$rA, (sra G8RC:$rS, (i32 imm:$SH)))]>, isPPC64;
434 }
425435 def CNTLZD : XForm_11<31, 58, (outs G8RC:$rA), (ins G8RC:$rS),
426436 "cntlzd $rA, $rS", IntGeneral,
427437 [(set G8RC:$rA, (ctlz G8RC:$rS))]>;
425425 LR,CTR,
426426 CR0,CR1,CR5,CR6,CR7,
427427 CR0LT,CR0GT,CR0EQ,CR0UN,CR1LT,CR1GT,CR1EQ,CR1UN,CR5LT,CR5GT,CR5EQ,
428 CR5UN,CR6LT,CR6GT,CR6EQ,CR6UN,CR7LT,CR7GT,CR7EQ,CR7UN] in {
428 CR5UN,CR6LT,CR6GT,CR6EQ,CR6UN,CR7LT,CR7GT,CR7EQ,CR7UN,CARRY] in {
429429 // Convenient aliases for call instructions
430430 let Uses = [RM] in {
431431 def BL_Darwin : IForm<18, 0, 1,
452452 LR,CTR,
453453 CR0,CR1,CR5,CR6,CR7,
454454 CR0LT,CR0GT,CR0EQ,CR0UN,CR1LT,CR1GT,CR1EQ,CR1UN,CR5LT,CR5GT,CR5EQ,
455 CR5UN,CR6LT,CR6GT,CR6EQ,CR6UN,CR7LT,CR7GT,CR7EQ,CR7UN] in {
455 CR5UN,CR6LT,CR6GT,CR6EQ,CR6UN,CR7LT,CR7GT,CR7EQ,CR7UN,CARRY] in {
456456 // Convenient aliases for call instructions
457457 let Uses = [RM] in {
458458 def BL_SVR4 : IForm<18, 0, 1,
868868 def ADDI : DForm_2<14, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
869869 "addi $rD, $rA, $imm", IntGeneral,
870870 [(set GPRC:$rD, (add GPRC:$rA, immSExt16:$imm))]>;
871 let Defs = [CARRY] in {
871872 def ADDIC : DForm_2<12, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
872873 "addic $rD, $rA, $imm", IntGeneral,
873874 [(set GPRC:$rD, (addc GPRC:$rA, immSExt16:$imm))]>,
875876 def ADDICo : DForm_2<13, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
876877 "addic. $rD, $rA, $imm", IntGeneral,
877878 []>;
879 }
878880 def ADDIS : DForm_2<15, (outs GPRC:$rD), (ins GPRC:$rA, symbolHi:$imm),
879881 "addis $rD, $rA, $imm", IntGeneral,
880882 [(set GPRC:$rD, (add GPRC:$rA, imm16ShiftedSExt:$imm))]>;
885887 def MULLI : DForm_2< 7, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
886888 "mulli $rD, $rA, $imm", IntMulLI,
887889 [(set GPRC:$rD, (mul GPRC:$rA, immSExt16:$imm))]>;
890 let Defs = [CARRY] in {
888891 def SUBFIC : DForm_2< 8, (outs GPRC:$rD), (ins GPRC:$rA, s16imm:$imm),
889892 "subfic $rD, $rA, $imm", IntGeneral,
890893 [(set GPRC:$rD, (subc immSExt16:$imm, GPRC:$rA))]>;
894 }
891895
892896 let isReMaterializable = 1 in {
893897 def LI : DForm_2_r0<14, (outs GPRC:$rD), (ins symbolLo:$imm),
960964 def SRW : XForm_6<31, 536, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
961965 "srw $rA, $rS, $rB", IntGeneral,
962966 [(set GPRC:$rA, (PPCsrl GPRC:$rS, GPRC:$rB))]>;
967 let Defs = [CARRY] in {
963968 def SRAW : XForm_6<31, 792, (outs GPRC:$rA), (ins GPRC:$rS, GPRC:$rB),
964969 "sraw $rA, $rS, $rB", IntShift,
965970 [(set GPRC:$rA, (PPCsra GPRC:$rS, GPRC:$rB))]>;
966971 }
972 }
967973
968974 let PPC970_Unit = 1 in { // FXU Operations.
975 let Defs = [CARRY] in {
969976 def SRAWI : XForm_10<31, 824, (outs GPRC:$rA), (ins GPRC:$rS, u5imm:$SH),
970977 "srawi $rA, $rS, $SH", IntShift,
971978 [(set GPRC:$rA, (sra GPRC:$rS, (i32 imm:$SH)))]>;
979 }
972980 def CNTLZW : XForm_11<31, 26, (outs GPRC:$rA), (ins GPRC:$rS),
973981 "cntlzw $rA, $rS", IntGeneral,
974982 [(set GPRC:$rA, (ctlz GPRC:$rS))]>;
11631171 def ADD4 : XOForm_1<31, 266, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
11641172 "add $rT, $rA, $rB", IntGeneral,
11651173 [(set GPRC:$rT, (add GPRC:$rA, GPRC:$rB))]>;
1174 let Defs = [CARRY] in {
11661175 def ADDC : XOForm_1<31, 10, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
11671176 "addc $rT, $rA, $rB", IntGeneral,
11681177 [(set GPRC:$rT, (addc GPRC:$rA, GPRC:$rB))]>,
11691178 PPC970_DGroup_Cracked;
1170 def ADDE : XOForm_1<31, 138, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1171 "adde $rT, $rA, $rB", IntGeneral,
1172 [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
1179 }
11731180 def DIVW : XOForm_1<31, 491, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
11741181 "divw $rT, $rA, $rB", IntDivW,
11751182 [(set GPRC:$rT, (sdiv GPRC:$rA, GPRC:$rB))]>,
11901197 def SUBF : XOForm_1<31, 40, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
11911198 "subf $rT, $rA, $rB", IntGeneral,
11921199 [(set GPRC:$rT, (sub GPRC:$rB, GPRC:$rA))]>;
1200 let Defs = [CARRY] in {
11931201 def SUBFC : XOForm_1<31, 8, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
11941202 "subfc $rT, $rA, $rB", IntGeneral,
11951203 [(set GPRC:$rT, (subc GPRC:$rB, GPRC:$rA))]>,
11961204 PPC970_DGroup_Cracked;
1197 def SUBFE : XOForm_1<31, 136, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1198 "subfe $rT, $rA, $rB", IntGeneral,
1199 [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
1205 }
1206 def NEG : XOForm_3<31, 104, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1207 "neg $rT, $rA", IntGeneral,
1208 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
1209 let Uses = [CARRY], Defs = [CARRY] in {
1210 def ADDE : XOForm_1<31, 138, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1211 "adde $rT, $rA, $rB", IntGeneral,
1212 [(set GPRC:$rT, (adde GPRC:$rA, GPRC:$rB))]>;
12001213 def ADDME : XOForm_3<31, 234, 0, (outs GPRC:$rT), (ins GPRC:$rA),
12011214 "addme $rT, $rA", IntGeneral,
12021215 [(set GPRC:$rT, (adde GPRC:$rA, immAllOnes))]>;
12031216 def ADDZE : XOForm_3<31, 202, 0, (outs GPRC:$rT), (ins GPRC:$rA),
12041217 "addze $rT, $rA", IntGeneral,
12051218 [(set GPRC:$rT, (adde GPRC:$rA, 0))]>;
1206 def NEG : XOForm_3<31, 104, 0, (outs GPRC:$rT), (ins GPRC:$rA),
1207 "neg $rT, $rA", IntGeneral,
1208 [(set GPRC:$rT, (ineg GPRC:$rA))]>;
1219 def SUBFE : XOForm_1<31, 136, 0, (outs GPRC:$rT), (ins GPRC:$rA, GPRC:$rB),
1220 "subfe $rT, $rA, $rB", IntGeneral,
1221 [(set GPRC:$rT, (sube GPRC:$rB, GPRC:$rA))]>;
12091222 def SUBFME : XOForm_3<31, 232, 0, (outs GPRC:$rT), (ins GPRC:$rA),
12101223 "subfme $rT, $rA", IntGeneral,
12111224 [(set GPRC:$rT, (sube immAllOnes, GPRC:$rA))]>;
12121225 def SUBFZE : XOForm_3<31, 200, 0, (outs GPRC:$rT), (ins GPRC:$rA),
12131226 "subfze $rT, $rA", IntGeneral,
12141227 [(set GPRC:$rT, (sube 0, GPRC:$rA))]>;
1228 }
12151229 }
12161230
12171231 // A-Form instructions. Most of the instructions executed in the FPU are of
254254 // VRsave register
255255 def VRSAVE: SPR<256, "VRsave">, DwarfRegNum<[107]>;
256256
257 // Carry bit. In the architecture this is really bit 0 of the XER register
258 // (which really is SPR register 1); this is the only bit interesting to a
259 // compiler.
260 def CARRY: SPR<1, "ca">, DwarfRegNum<[0]>;
261
257262 // FP rounding mode: bits 30 and 31 of the FP status and control register
258263 // This is not allocated as a normal register; it appears only in
259264 // Uses and Defs. The ABI says it needs to be preserved by a function,
376381 def CTRRC : RegisterClass<"PPC", [i32], 32, [CTR]>;
377382 def CTRRC8 : RegisterClass<"PPC", [i64], 64, [CTR8]>;
378383 def VRSAVERC : RegisterClass<"PPC", [i32], 32, [VRSAVE]>;
384 def CARRYRC : RegisterClass<"PPC", [i32], 32, [CARRY]> {
385 let CopyCost = -1;
386 }
0 ; RUN: llc -march=ppc32 < %s | FileCheck %s
1 ; ModuleID = ''
2 target datalayout = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f128:64:128"
3 target triple = "powerpc-apple-darwin9.6"
4
5 define i64 @foo(i64 %r.0.ph, i64 %q.0.ph, i32 %sr1.1.ph) nounwind {
6 entry:
7 ; CHECK: foo:
8 ; CHECK: subfc
9 ; CHECK: subfe
10 ; CHECK: subfc
11 ; CHECK: subfe
12 %tmp0 = add i64 %r.0.ph, -1 ; [#uses=1]
13 br label %bb40
14
15 bb40: ; preds = %bb40, %entry
16 %indvar = phi i32 [ 0, %entry ], [ %indvar.next, %bb40 ] ; [#uses=1]
17 %carry.0274 = phi i32 [ 0, %entry ], [%tmp122, %bb40 ] ; [#uses=1]
18 %r.0273 = phi i64 [ %r.0.ph, %entry ], [ %tmp124, %bb40 ] ; [#uses=2]
19 %q.0272 = phi i64 [ %q.0.ph, %entry ], [ %ins169, %bb40 ] ; [#uses=3]
20 %tmp1 = lshr i64 %r.0273, 31 ; [#uses=1]
21 %tmp2 = trunc i64 %tmp1 to i32 ; [#uses=1]
22 %tmp3 = and i32 %tmp2, -2 ; [#uses=1]
23 %tmp213 = trunc i64 %r.0273 to i32 ; [#uses=2]
24 %tmp106 = lshr i32 %tmp213, 31 ; [#uses=1]
25 %tmp107 = or i32 %tmp3, %tmp106 ; [#uses=1]
26 %tmp215 = zext i32 %tmp107 to i64 ; [#uses=1]
27 %tmp216 = shl i64 %tmp215, 32 ; [#uses=1]
28 %tmp108 = shl i32 %tmp213, 1 ; [#uses=1]
29 %tmp109 = lshr i64 %q.0272, 63 ; [#uses=1]
30 %tmp110 = trunc i64 %tmp109 to i32 ; [#uses=1]
31 %tmp111 = or i32 %tmp108, %tmp110 ; [#uses=1]
32 %tmp222 = zext i32 %tmp111 to i64 ; [#uses=1]
33 %ins224 = or i64 %tmp216, %tmp222 ; [#uses=2]
34 %tmp112 = lshr i64 %q.0272, 31 ; [#uses=1]
35 %tmp113 = trunc i64 %tmp112 to i32 ; [#uses=1]
36 %tmp114 = and i32 %tmp113, -2 ; [#uses=1]
37 %tmp158 = trunc i64 %q.0272 to i32 ; [#uses=2]
38 %tmp115 = lshr i32 %tmp158, 31 ; [#uses=1]
39 %tmp116 = or i32 %tmp114, %tmp115 ; [#uses=1]
40 %tmp160 = zext i32 %tmp116 to i64 ; [#uses=1]
41 %tmp161 = shl i64 %tmp160, 32 ; [#uses=1]
42 %tmp117 = shl i32 %tmp158, 1 ; [#uses=1]
43 %tmp118 = or i32 %tmp117, %carry.0274 ; [#uses=1]
44 %tmp167 = zext i32 %tmp118 to i64 ; [#uses=1]
45 %ins169 = or i64 %tmp161, %tmp167 ; [#uses=2]
46 %tmp119 = sub i64 %tmp0, %ins224 ; [#uses=1]
47 %tmp120 = ashr i64 %tmp119, 63 ; [#uses=2]
48 %tmp121 = trunc i64 %tmp120 to i32 ; [#uses=1]
49 %tmp122 = and i32 %tmp121, 1 ; [#uses=2]
50 %tmp123 = and i64 %tmp120, %q.0.ph ; [#uses=1]
51 %tmp124 = sub i64 %ins224, %tmp123 ; [#uses=2]
52 %indvar.next = add i32 %indvar, 1 ; [#uses=2]
53 %exitcond = icmp eq i32 %indvar.next, %sr1.1.ph ; [#uses=1]
54 br i1 %exitcond, label %bb41.bb42_crit_edge, label %bb40
55
56 bb41.bb42_crit_edge: ; preds = %bb40
57 %phitmp278 = zext i32 %tmp122 to i64 ; [#uses=1]
58 %tmp125 = shl i64 %ins169, 1 ; [#uses=1]
59 %tmp126 = or i64 %phitmp278, %tmp125 ; [#uses=2]
60 ret i64 %tmp126
61 }