summaryrefslogtreecommitdiff
path: root/include/llvm/Operator.h
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 /include/llvm/Operator.h
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 'include/llvm/Operator.h')
-rw-r--r--include/llvm/Operator.h30
1 files changed, 28 insertions, 2 deletions
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<ConstantExpr>(V) && classof(cast<ConstantExpr>(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<Instruction>(V) && classof(cast<Instruction>(V));
+ }
+};
/// ConcreteOperator - A helper template for defining operators for individual