Tidy up formatting of some elses on a separate line from preceding bracing. No functi...
[oota-llvm.git] / include / llvm / Operator.h
index d253c8fe09c83f6d8ffc1b7020855b886ddf9210..1e86980cf303fa5b59956aa60e2acb4ceded5cf8 100644 (file)
@@ -17,6 +17,7 @@
 
 #include "llvm/Constants.h"
 #include "llvm/Instruction.h"
+#include "llvm/Type.h"
 
 namespace llvm {
 
@@ -129,14 +130,15 @@ public:
     IsExact = (1 << 0)
   };
   
+private:
+  ~PossiblyExactOperator(); // do not implement
+
   friend class BinaryOperator;
   friend class ConstantExpr;
   void setIsExact(bool B) {
     SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact);
   }
   
-private:
-  ~PossiblyExactOperator(); // do not implement
 public:
   /// isExact - Test whether this division is known to be exact, with
   /// zero remainder.
@@ -161,7 +163,28 @@ 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.
+  float getFPAccuracy() 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
@@ -185,106 +208,6 @@ public:
   }
 };
 
-class FAddOperator : public ConcreteOperator<Operator, Instruction::FAdd> {
-  ~FAddOperator(); // DO NOT IMPLEMENT
-};
-class FSubOperator : public ConcreteOperator<Operator, Instruction::FSub> {
-  ~FSubOperator(); // DO NOT IMPLEMENT
-};
-class FMulOperator : public ConcreteOperator<Operator, Instruction::FMul> {
-  ~FMulOperator(); // DO NOT IMPLEMENT
-};
-class FDivOperator : public ConcreteOperator<Operator, Instruction::FDiv> {
-  ~FDivOperator(); // DO NOT IMPLEMENT
-};
-class URemOperator : public ConcreteOperator<Operator, Instruction::URem> {
-  ~URemOperator(); // DO NOT IMPLEMENT
-};
-class SRemOperator : public ConcreteOperator<Operator, Instruction::SRem> {
-  ~SRemOperator(); // DO NOT IMPLEMENT
-};
-class FRemOperator : public ConcreteOperator<Operator, Instruction::FRem> {
-  ~FRemOperator(); // DO NOT IMPLEMENT
-};
-class AndOperator : public ConcreteOperator<Operator, Instruction::And> {
-  ~AndOperator(); // DO NOT IMPLEMENT
-};
-class OrOperator : public ConcreteOperator<Operator, Instruction::Or> {
-  ~OrOperator(); // DO NOT IMPLEMENT
-};
-class XorOperator : public ConcreteOperator<Operator, Instruction::Xor> {
-  ~XorOperator(); // DO NOT IMPLEMENT
-};
-class TruncOperator : public ConcreteOperator<Operator, Instruction::Trunc> {
-  ~TruncOperator(); // DO NOT IMPLEMENT
-};
-class ZExtOperator : public ConcreteOperator<Operator, Instruction::ZExt> {
-  ~ZExtOperator(); // DO NOT IMPLEMENT
-};
-class SExtOperator : public ConcreteOperator<Operator, Instruction::SExt> {
-  ~SExtOperator(); // DO NOT IMPLEMENT
-};
-class FPToUIOperator : public ConcreteOperator<Operator, Instruction::FPToUI> {
-  ~FPToUIOperator(); // DO NOT IMPLEMENT
-};
-class FPToSIOperator : public ConcreteOperator<Operator, Instruction::FPToSI> {
-  ~FPToSIOperator(); // DO NOT IMPLEMENT
-};
-class UIToFPOperator : public ConcreteOperator<Operator, Instruction::UIToFP> {
-  ~UIToFPOperator(); // DO NOT IMPLEMENT
-};
-class SIToFPOperator : public ConcreteOperator<Operator, Instruction::SIToFP> {
-  ~SIToFPOperator(); // DO NOT IMPLEMENT
-};
-class FPTruncOperator
-  : public ConcreteOperator<Operator, Instruction::FPTrunc> {
-  ~FPTruncOperator(); // DO NOT IMPLEMENT
-};
-class FPExtOperator : public ConcreteOperator<Operator, Instruction::FPExt> {
-  ~FPExtOperator(); // DO NOT IMPLEMENT
-};
-class PtrToIntOperator
-  : public ConcreteOperator<Operator, Instruction::PtrToInt> {
-  ~PtrToIntOperator(); // DO NOT IMPLEMENT
-};
-class IntToPtrOperator
-  : public ConcreteOperator<Operator, Instruction::IntToPtr> {
-  ~IntToPtrOperator(); // DO NOT IMPLEMENT
-};
-class BitCastOperator
-  : public ConcreteOperator<Operator, Instruction::BitCast> {
-  ~BitCastOperator(); // DO NOT IMPLEMENT
-};
-class ICmpOperator : public ConcreteOperator<Operator, Instruction::ICmp> {
-  ~ICmpOperator(); // DO NOT IMPLEMENT
-};
-class FCmpOperator : public ConcreteOperator<Operator, Instruction::FCmp> {
-  ~FCmpOperator(); // DO NOT IMPLEMENT
-};
-class SelectOperator : public ConcreteOperator<Operator, Instruction::Select> {
-  ~SelectOperator(); // DO NOT IMPLEMENT
-};
-class ExtractElementOperator
-  : public ConcreteOperator<Operator, Instruction::ExtractElement> {
-  ~ExtractElementOperator(); // DO NOT IMPLEMENT
-};
-class InsertElementOperator
-  : public ConcreteOperator<Operator, Instruction::InsertElement> {
-  ~InsertElementOperator(); // DO NOT IMPLEMENT
-};
-class ShuffleVectorOperator
-  : public ConcreteOperator<Operator, Instruction::ShuffleVector> {
-  ~ShuffleVectorOperator(); // DO NOT IMPLEMENT
-};
-class ExtractValueOperator
-  : public ConcreteOperator<Operator, Instruction::ExtractValue> {
-  ~ExtractValueOperator(); // DO NOT IMPLEMENT
-};
-class InsertValueOperator
-  : public ConcreteOperator<Operator, Instruction::InsertValue> {
-  ~InsertValueOperator(); // DO NOT IMPLEMENT
-};
-
 class AddOperator
   : public ConcreteOperator<OverflowingBinaryOperator, Instruction::Add> {
   ~AddOperator(); // DO NOT IMPLEMENT
@@ -361,8 +284,8 @@ public:
 
   /// getPointerOperandType - Method to return the pointer operand as a
   /// PointerType.
-  const PointerType *getPointerOperandType() const {
-    return reinterpret_cast<const PointerType*>(getPointerOperand()->getType());
+  Type *getPointerOperandType() const {
+    return getPointerOperand()->getType();
   }
 
   unsigned getNumIndices() const {  // Note: always non-negative