diff options
author | Karl Schimpf <kschimpf@google.com> | 2013-06-13 13:14:11 -0700 |
---|---|---|
committer | Karl Schimpf <kschimpf@google.com> | 2013-06-13 13:14:11 -0700 |
commit | ddadc78689898ac52d1e5959487e986dac67f549 (patch) | |
tree | 09859cc869410d484684c32ff8c4284f9c997b71 | |
parent | 5d2171152d8441be311af367276e7e016877c05c (diff) |
Insulate PNaCl bitcode from LLVM encodings of floating point optimization flags.
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405
R=jvoung@chromium.org
Review URL: https://codereview.chromium.org/16836017
-rw-r--r-- | include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h | 10 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp | 10 | ||||
-rw-r--r-- | lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp | 10 |
3 files changed, 20 insertions, 10 deletions
diff --git a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h index bf31c5bea3..b402ca2db8 100644 --- a/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h +++ b/include/llvm/Bitcode/NaCl/NaClLLVMBitCodes.h @@ -248,6 +248,16 @@ namespace naclbitc { PEO_EXACT = 0 }; + /// \brief Flags for serializing floating point binary operators's + /// SubclassOptionalData contents. + enum NaClFloatingPointBinaryOperatorOptionalFlags { + FPO_UNSAFE_ALGEBRA = 0, + FPO_NO_NANS = 1, + FPO_NO_INFS = 2, + FPO_NO_SIGNED_ZEROS = 3, + FPO_ALLOW_RECIPROCAL = 4 + }; + /// Encoded AtomicOrdering values. enum NaClAtomicOrderingCodes { ORDERING_NOTATOMIC = 0, diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp index 4add89f6ab..58ff9de3aa 100644 --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp @@ -2099,15 +2099,15 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) { cast<BinaryOperator>(I)->setIsExact(true); } else if (isa<FPMathOperator>(I)) { FastMathFlags FMF; - if (0 != (Record[OpNum] & FastMathFlags::UnsafeAlgebra)) + if (0 != (Record[OpNum] & (1 << naclbitc::FPO_UNSAFE_ALGEBRA))) FMF.setUnsafeAlgebra(); - if (0 != (Record[OpNum] & FastMathFlags::NoNaNs)) + if (0 != (Record[OpNum] & (1 << naclbitc::FPO_NO_NANS))) FMF.setNoNaNs(); - if (0 != (Record[OpNum] & FastMathFlags::NoInfs)) + if (0 != (Record[OpNum] & (1 << naclbitc::FPO_NO_INFS))) FMF.setNoInfs(); - if (0 != (Record[OpNum] & FastMathFlags::NoSignedZeros)) + if (0 != (Record[OpNum] & (1 << naclbitc::FPO_NO_SIGNED_ZEROS))) FMF.setNoSignedZeros(); - if (0 != (Record[OpNum] & FastMathFlags::AllowReciprocal)) + if (0 != (Record[OpNum] & (1 << naclbitc::FPO_ALLOW_RECIPROCAL))) FMF.setAllowReciprocal(); if (FMF.any()) I->setFastMathFlags(FMF); diff --git a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp index 522ef1bbba..47ca9afe59 100644 --- a/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp +++ b/lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp @@ -656,15 +656,15 @@ static uint64_t GetOptimizationFlags(const Value *V) { } else if (const FPMathOperator *FPMO = dyn_cast<const FPMathOperator>(V)) { if (FPMO->hasUnsafeAlgebra()) - Flags |= FastMathFlags::UnsafeAlgebra; + Flags |= 1 << naclbitc::FPO_UNSAFE_ALGEBRA; if (FPMO->hasNoNaNs()) - Flags |= FastMathFlags::NoNaNs; + Flags |= 1 << naclbitc::FPO_NO_NANS; if (FPMO->hasNoInfs()) - Flags |= FastMathFlags::NoInfs; + Flags |= 1 << naclbitc::FPO_NO_INFS; if (FPMO->hasNoSignedZeros()) - Flags |= FastMathFlags::NoSignedZeros; + Flags |= 1 << naclbitc::FPO_NO_SIGNED_ZEROS; if (FPMO->hasAllowReciprocal()) - Flags |= FastMathFlags::AllowReciprocal; + Flags |= 1 << naclbitc::FPO_ALLOW_RECIPROCAL; } return Flags; |