summaryrefslogtreecommitdiff
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-04-16 16:28:59 +0000
committerDuncan Sands <baldrick@free.fr>2012-04-16 16:28:59 +0000
commit8883c43ddc13e5f92ba8dfe00f2116a153a570d5 (patch)
tree40b5bad6be11275bb56cb7f227d1e4ee6544718d /lib/VMCore/Verifier.cpp
parent9e67db4af13abb967cae5858502207a43d26bf84 (diff)
downloadllvm-8883c43ddc13e5f92ba8dfe00f2116a153a570d5.tar.gz
llvm-8883c43ddc13e5f92ba8dfe00f2116a153a570d5.tar.bz2
llvm-8883c43ddc13e5f92ba8dfe00f2116a153a570d5.tar.xz
Make it possible to indicate relaxed floating point requirements at the IR level
through the use of 'fpmath' metadata. Currently this only provides a 'fpaccuracy' value, which may be a number in ULPs or the keyword 'fast', however the intent is that this will be extended with additional information about NaN's, infinities etc later. No optimizations have been hooked up to this so far. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154822 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index ab79d8ce62..2576766928 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -1657,12 +1657,16 @@ void Verifier::visitInstruction(Instruction &I) {
Assert1(I.getType()->isFPOrFPVectorTy(),
"fpmath requires a floating point result!", &I);
Assert1(MD->getNumOperands() == 1, "fpmath takes one operand!", &I);
- ConstantFP *Op = dyn_cast_or_null<ConstantFP>(MD->getOperand(0));
- Assert1(Op, "fpmath ULPs not a floating point number!", &I);
- APFloat ULPs = Op->getValueAPF();
- Assert1(ULPs.isNormal() || ULPs.isZero(),
- "fpmath ULPs not a normal number!", &I);
- Assert1(!ULPs.isNegative(), "fpmath ULPs is negative!", &I);
+ Value *Op0 = MD->getOperand(0);
+ if (ConstantFP *CFP0 = dyn_cast_or_null<ConstantFP>(Op0)) {
+ APFloat Accuracy = CFP0->getValueAPF();
+ Assert1(Accuracy.isNormal() && !Accuracy.isNegative(),
+ "fpmath accuracy not a positive number!", &I);
+ } else if (MDString *S0 = dyn_cast_or_null<MDString>(Op0)) {
+ Assert1(S0->getString() == "fast", "wrong fpmath accuracy keyword!", &I);
+ } else {
+ Assert1(false, "invalid fpmath accuracy!", &I);
+ }
}
MDNode *MD = I.getMetadata(LLVMContext::MD_range);