llvm.org GIT mirror llvm / 2e49864
Merging r325525: ------------------------------------------------------------------------ r325525 | steven_wu | 2018-02-19 20:22:28 +0100 (Mon, 19 Feb 2018) | 13 lines bitcode support change for fast flags compatibility Summary: The discussion and as per need, each vendor needs a way to keep the old fast flags and the new fast flags in the auto upgrade path of the IR upgrader. This revision addresses that issue. Patched by Michael Berg Reviewers: qcolombet, hans, steven_wu Reviewed By: qcolombet, steven_wu Subscribers: dexonsmith, vsk, mehdi_amini, andrewrk, MatzeB, wristow, spatel Differential Revision: https://reviews.llvm.org/D43253 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@325592 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 2 years ago
9 changed file(s) with 41 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
394394 OBO_NO_SIGNED_WRAP = 1
395395 };
396396
397 /// FastMath Flags
398 /// This is a fixed layout derived from the bitcode emitted by LLVM 5.0
399 /// intended to decouple the in-memory representation from the serialization.
400 enum FastMathMap {
401 UnsafeAlgebra = (1 << 0), // Legacy
402 NoNaNs = (1 << 1),
403 NoInfs = (1 << 2),
404 NoSignedZeros = (1 << 3),
405 AllowReciprocal = (1 << 4),
406 AllowContract = (1 << 5),
407 ApproxFunc = (1 << 6),
408 AllowReassoc = (1 << 7)
409 };
410
397411 /// PossiblyExactOperatorOptionalFlags - Flags for serializing
398412 /// PossiblyExactOperator's SubclassOptionalData contents.
399413 enum PossiblyExactOperatorOptionalFlags { PEO_EXACT = 0 };
10451045
10461046 static FastMathFlags getDecodedFastMathFlags(unsigned Val) {
10471047 FastMathFlags FMF;
1048 if (0 != (Val & FastMathFlags::AllowReassoc))
1048 if (0 != (Val & bitc::UnsafeAlgebra))
1049 FMF.setFast();
1050 if (0 != (Val & bitc::AllowReassoc))
10491051 FMF.setAllowReassoc();
1050 if (0 != (Val & FastMathFlags::NoNaNs))
1052 if (0 != (Val & bitc::NoNaNs))
10511053 FMF.setNoNaNs();
1052 if (0 != (Val & FastMathFlags::NoInfs))
1054 if (0 != (Val & bitc::NoInfs))
10531055 FMF.setNoInfs();
1054 if (0 != (Val & FastMathFlags::NoSignedZeros))
1056 if (0 != (Val & bitc::NoSignedZeros))
10551057 FMF.setNoSignedZeros();
1056 if (0 != (Val & FastMathFlags::AllowReciprocal))
1058 if (0 != (Val & bitc::AllowReciprocal))
10571059 FMF.setAllowReciprocal();
1058 if (0 != (Val & FastMathFlags::AllowContract))
1060 if (0 != (Val & bitc::AllowContract))
10591061 FMF.setAllowContract(true);
1060 if (0 != (Val & FastMathFlags::ApproxFunc))
1062 if (0 != (Val & bitc::ApproxFunc))
10611063 FMF.setApproxFunc();
10621064 return FMF;
10631065 }
13291329 Flags |= 1 << bitc::PEO_EXACT;
13301330 } else if (const auto *FPMO = dyn_cast(V)) {
13311331 if (FPMO->hasAllowReassoc())
1332 Flags |= FastMathFlags::AllowReassoc;
1332 Flags |= bitc::AllowReassoc;
13331333 if (FPMO->hasNoNaNs())
1334 Flags |= FastMathFlags::NoNaNs;
1334 Flags |= bitc::NoNaNs;
13351335 if (FPMO->hasNoInfs())
1336 Flags |= FastMathFlags::NoInfs;
1336 Flags |= bitc::NoInfs;
13371337 if (FPMO->hasNoSignedZeros())
1338 Flags |= FastMathFlags::NoSignedZeros;
1338 Flags |= bitc::NoSignedZeros;
13391339 if (FPMO->hasAllowReciprocal())
1340 Flags |= FastMathFlags::AllowReciprocal;
1340 Flags |= bitc::AllowReciprocal;
13411341 if (FPMO->hasAllowContract())
1342 Flags |= FastMathFlags::AllowContract;
1342 Flags |= bitc::AllowContract;
13431343 if (FPMO->hasApproxFunc())
1344 Flags |= FastMathFlags::ApproxFunc;
1344 Flags |= bitc::ApproxFunc;
13451345 }
13461346
13471347 return Flags;
31823182 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
31833183 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
31843184 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
3185 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7)); // flags
3185 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); // flags
31863186 if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) !=
31873187 FUNCTION_INST_BINOP_FLAGS_ABBREV)
31883188 llvm_unreachable("Unexpected abbrev ordering!");
611611 %f.arcp = fadd arcp float %op1, %op2
612612 ; CHECK: %f.arcp = fadd arcp float %op1, %op2
613613 %f.fast = fadd fast float %op1, %op2
614 ; 'fast' used to be its own bit, but this changed in Oct 2017.
615 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
616 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp float %op1, %op2
614 ; CHECK: %f.fast = fadd fast float %op1, %op2
617615 ret void
618616 }
619617
655655 %f.arcp = fadd arcp float %op1, %op2
656656 ; CHECK: %f.arcp = fadd arcp float %op1, %op2
657657 %f.fast = fadd fast float %op1, %op2
658 ; 'fast' used to be its own bit, but this changed in Oct 2017.
659 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
660 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp float %op1, %op2
658 ; CHECK: %f.fast = fadd fast float %op1, %op2
661659 ret void
662660 }
663661
686686 %f.arcp = fadd arcp float %op1, %op2
687687 ; CHECK: %f.arcp = fadd arcp float %op1, %op2
688688 %f.fast = fadd fast float %op1, %op2
689 ; 'fast' used to be its own bit, but this changed in Oct 2017.
690 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
691 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp float %op1, %op2
689 ; CHECK: %f.fast = fadd fast float %op1, %op2
692690 ret void
693691 }
694692
701699 ; CHECK-LABEL: fastMathFlagsForCalls(
702700 define void @fastMathFlagsForCalls(float %f, double %d1, <4 x double> %d2) {
703701 %call.fast = call fast float @fmf1()
704 ; 'fast' used to be its own bit, but this changed in Oct 2017.
705 ; The binary test file does not have the newer 'contract' and 'aml' bits set, so this is not fully 'fast'.
706 ; CHECK: %call.fast = call reassoc nnan ninf nsz arcp float @fmf1()
702 ; CHECK: %call.fast = call fast float @fmf1()
707703
708704 ; Throw in some other attributes to make sure those stay in the right places.
709705
757757 %f.arcp = fadd arcp float %op1, %op2
758758 ; CHECK: %f.arcp = fadd arcp float %op1, %op2
759759 %f.fast = fadd fast float %op1, %op2
760 ; 'fast' used to be its own bit, but this changed in Oct 2017.
761 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
762 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp float %op1, %op2
760 ; CHECK: %f.fast = fadd fast float %op1, %op2
763761 ret void
764762 }
765763
772770 ; CHECK-LABEL: fastMathFlagsForCalls(
773771 define void @fastMathFlagsForCalls(float %f, double %d1, <4 x double> %d2) {
774772 %call.fast = call fast float @fmf1()
775 ; 'fast' used to be its own bit, but this changed in Oct 2017.
776 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
777 ; CHECK: %call.fast = call reassoc nnan ninf nsz arcp float @fmf1()
773 ; CHECK: %call.fast = call fast float @fmf1()
778774
779775 ; Throw in some other attributes to make sure those stay in the right places.
780776
756756 ; CHECK: %f.nsz = fadd nsz float %op1, %op2
757757 %f.arcp = fadd arcp float %op1, %op2
758758 ; CHECK: %f.arcp = fadd arcp float %op1, %op2
759 ; 'fast' used to be its own bit, but this changed in Oct 2017.
760 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
761759 %f.fast = fadd fast float %op1, %op2
762 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp float %op1, %op2
760 ; CHECK: %f.fast = fadd fast float %op1, %op2
763761 ret void
764762 }
765763
772770 ; CHECK-LABEL: fastMathFlagsForCalls(
773771 define void @fastMathFlagsForCalls(float %f, double %d1, <4 x double> %d2) {
774772 %call.fast = call fast float @fmf1()
775 ; 'fast' used to be its own bit, but this changed in Oct 2017.
776 ; The binary test file does not have the newer 'contract' and 'afn' bits set, so this is not fully 'fast'.
777 ; CHECK: %call.fast = call reassoc nnan ninf nsz arcp float @fmf1()
773 ; CHECK: %call.fast = call fast float @fmf1()
778774
779775 ; Throw in some other attributes to make sure those stay in the right places.
780776
764764 %f.contract = fadd contract float %op1, %op2
765765 ; CHECK: %f.contract = fadd contract float %op1, %op2
766766 %f.fast = fadd fast float %op1, %op2
767 ; 'fast' used to be its own bit, but this changed in Oct 2017.
768 ; The binary test file does not have the newer 'afn' bit set, so this is not fully 'fast'.
769 ; CHECK: %f.fast = fadd reassoc nnan ninf nsz arcp contract float %op1, %op2
767 ; CHECK: %f.fast = fadd fast float %op1, %op2
770768 ret void
771769 }
772770
779777 ; CHECK-LABEL: fastMathFlagsForCalls(
780778 define void @fastMathFlagsForCalls(float %f, double %d1, <4 x double> %d2) {
781779 %call.fast = call fast float @fmf1()
782 ; 'fast' used to be its own bit, but this changed in Oct 2017.
783 ; The binary test file does not have the newer 'afn' bit set, so this is not fully 'fast'.
784 ; CHECK: %call.fast = call reassoc nnan ninf nsz arcp contract float @fmf1()
780 ; CHECK: %call.fast = call fast float @fmf1()
785781
786782 ; Throw in some other attributes to make sure those stay in the right places.
787783