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 --- include/llvm/Operator.h | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'include/llvm/Operator.h') diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h index 9268d98d63..6bd7e56607 100644 --- a/include/llvm/Operator.h +++ b/include/llvm/Operator.h @@ -15,8 +15,9 @@ #ifndef LLVM_OPERATOR_H #define LLVM_OPERATOR_H -#include "llvm/Instruction.h" #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/Type.h" namespace llvm { @@ -162,7 +163,32 @@ public: (isa(V) && classof(cast(V))); } }; - + +/// FPMathOperator - Utility class for floating point operations which can have +/// information about relaxed accuracy requirements attached to them. +class FPMathOperator : public Operator { +private: + ~FPMathOperator(); // do not implement + +public: + + /// \brief Get the maximum error permitted by this operation in ULPs. An + /// accuracy of 0.0 means that the operation should be performed with the + /// default precision. A huge value is returned if the accuracy is 'fast'. + float getFPAccuracy() const; + + /// \brief Return true if the accuracy is 'fast'. This indicates that speed + /// is more important than accuracy. + bool isFastFPAccuracy() const; + + static inline bool classof(const FPMathOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getType()->isFPOrFPVectorTy(); + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; /// ConcreteOperator - A helper template for defining operators for individual -- cgit v1.2.3