From 8883c43ddc13e5f92ba8dfe00f2116a153a570d5 Mon Sep 17 00:00:00 2001 From: Duncan Sands Date: Mon, 16 Apr 2012 16:28:59 +0000 Subject: 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 --- lib/VMCore/Verifier.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/VMCore/Verifier.cpp') 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(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(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(Op0)) { + Assert1(S0->getString() == "fast", "wrong fpmath accuracy keyword!", &I); + } else { + Assert1(false, "invalid fpmath accuracy!", &I); + } } MDNode *MD = I.getMetadata(LLVMContext::MD_range); -- cgit v1.2.3