Typo: exists -> exits
[oota-llvm.git] / lib / IR / ConstantsContext.h
index b4f0a53210f5c609fe66a43a1465a591eabc566b..f06509fb73a504f8cc0292d4a1047c9a7c527717 100644 (file)
@@ -24,6 +24,9 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include <map>
+#include <tuple>
+
+#define DEBUG_TYPE "ir"
 
 namespace llvm {
 template<class ValType>
@@ -31,8 +34,8 @@ struct ConstantTraits;
 
 /// UnaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement unary constant exprs.
-class LLVM_LIBRARY_VISIBILITY UnaryConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class UnaryConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly one operand
@@ -48,8 +51,8 @@ public:
 
 /// BinaryConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement binary constant exprs.
-class LLVM_LIBRARY_VISIBILITY BinaryConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class BinaryConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly two operands
@@ -69,8 +72,8 @@ public:
 
 /// SelectConstantExpr - This class is private to Constants.cpp, and is used
 /// behind the scenes to implement select constant exprs.
-class LLVM_LIBRARY_VISIBILITY SelectConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class SelectConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly three operands
@@ -90,8 +93,8 @@ public:
 /// ExtractElementConstantExpr - This class is private to
 /// Constants.cpp, and is used behind the scenes to implement
 /// extractelement constant exprs.
-class LLVM_LIBRARY_VISIBILITY ExtractElementConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class ExtractElementConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly two operands
@@ -111,8 +114,8 @@ public:
 /// InsertElementConstantExpr - This class is private to
 /// Constants.cpp, and is used behind the scenes to implement
 /// insertelement constant exprs.
-class LLVM_LIBRARY_VISIBILITY InsertElementConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class InsertElementConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly three operands
@@ -133,8 +136,8 @@ public:
 /// ShuffleVectorConstantExpr - This class is private to
 /// Constants.cpp, and is used behind the scenes to implement
 /// shufflevector constant exprs.
-class LLVM_LIBRARY_VISIBILITY ShuffleVectorConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class ShuffleVectorConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly three operands
@@ -158,8 +161,8 @@ public:
 /// ExtractValueConstantExpr - This class is private to
 /// Constants.cpp, and is used behind the scenes to implement
 /// extractvalue constant exprs.
-class LLVM_LIBRARY_VISIBILITY ExtractValueConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class ExtractValueConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly one operand
@@ -184,8 +187,8 @@ public:
 /// InsertValueConstantExpr - This class is private to
 /// Constants.cpp, and is used behind the scenes to implement
 /// insertvalue constant exprs.
-class LLVM_LIBRARY_VISIBILITY InsertValueConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class InsertValueConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly one operand
@@ -211,8 +214,8 @@ public:
 
 /// GetElementPtrConstantExpr - This class is private to Constants.cpp, and is
 /// used behind the scenes to implement getelementpr constant exprs.
-class LLVM_LIBRARY_VISIBILITY GetElementPtrConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class GetElementPtrConstantExpr : public ConstantExpr {
+  void anchor() override;
   GetElementPtrConstantExpr(Constant *C, ArrayRef<Constant*> IdxList,
                             Type *DestTy);
 public:
@@ -232,8 +235,8 @@ public:
 // CompareConstantExpr - This class is private to Constants.cpp, and is used
 // behind the scenes to implement ICmp and FCmp constant expressions. This is
 // needed in order to store the predicate value for these instructions.
-class LLVM_LIBRARY_VISIBILITY CompareConstantExpr : public ConstantExpr {
-  virtual void anchor();
+class CompareConstantExpr : public ConstantExpr {
+  void anchor() override;
   void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION;
 public:
   // allocate space for exactly two operands
@@ -313,7 +316,7 @@ struct OperandTraits<CompareConstantExpr> :
 };
 DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CompareConstantExpr, Value)
 
-struct LLVM_LIBRARY_VISIBILITY ExprMapKeyType {
+struct ExprMapKeyType {
   ExprMapKeyType(unsigned opc,
       ArrayRef<Constant*> ops,
       unsigned short flags = 0,
@@ -334,14 +337,10 @@ struct LLVM_LIBRARY_VISIBILITY ExprMapKeyType {
            this->indices == that.indices;
   }
   bool operator<(const ExprMapKeyType & that) const {
-    if (this->opcode != that.opcode) return this->opcode < that.opcode;
-    if (this->operands != that.operands) return this->operands < that.operands;
-    if (this->subclassdata != that.subclassdata)
-      return this->subclassdata < that.subclassdata;
-    if (this->subclassoptionaldata != that.subclassoptionaldata)
-      return this->subclassoptionaldata < that.subclassoptionaldata;
-    if (this->indices != that.indices) return this->indices < that.indices;
-    return false;
+    return std::tie(opcode, operands, subclassdata, subclassoptionaldata,
+                    indices) <
+           std::tie(that.opcode, that.operands, that.subclassdata,
+                    that.subclassoptionaldata, that.indices);
   }
 
   bool operator!=(const ExprMapKeyType& that) const {
@@ -349,7 +348,7 @@ struct LLVM_LIBRARY_VISIBILITY ExprMapKeyType {
   }
 };
 
-struct LLVM_LIBRARY_VISIBILITY InlineAsmKeyType {
+struct InlineAsmKeyType {
   InlineAsmKeyType(StringRef AsmString,
                    StringRef Constraints, bool hasSideEffects,
                    bool isAlignStack, InlineAsm::AsmDialect asmDialect)
@@ -369,17 +368,10 @@ struct LLVM_LIBRARY_VISIBILITY InlineAsmKeyType {
            this->asm_dialect == that.asm_dialect;
   }
   bool operator<(const InlineAsmKeyType& that) const {
-    if (this->asm_string != that.asm_string)
-      return this->asm_string < that.asm_string;
-    if (this->constraints != that.constraints)
-      return this->constraints < that.constraints;
-    if (this->has_side_effects != that.has_side_effects)
-      return this->has_side_effects < that.has_side_effects;
-    if (this->is_align_stack != that.is_align_stack)
-      return this->is_align_stack < that.is_align_stack;
-    if (this->asm_dialect != that.asm_dialect)
-      return this->asm_dialect < that.asm_dialect;
-    return false;
+    return std::tie(asm_string, constraints, has_side_effects, is_align_stack,
+                    asm_dialect) <
+           std::tie(that.asm_string, that.constraints, that.has_side_effects,
+                    that.is_align_stack, that.asm_dialect);
   }
 
   bool operator!=(const InlineAsmKeyType& that) const {
@@ -512,7 +504,7 @@ struct ConstantKeyData<InlineAsm> {
 
 template<class ValType, class ValRefType, class TypeClass, class ConstantClass,
          bool HasLargeKey = false /*true for arrays and structs*/ >
-class LLVM_LIBRARY_VISIBILITY ConstantUniqueMap {
+class ConstantUniqueMap {
 public:
   typedef std::pair<TypeClass*, ValType> MapKey;
   typedef std::map<MapKey, ConstantClass *> MapTy;
@@ -595,7 +587,7 @@ public:
   /// necessary.
   ConstantClass *getOrCreate(TypeClass *Ty, ValRefType V) {
     MapKey Lookup(Ty, V);
-    ConstantClass* Result = 0;
+    ConstantClass* Result = nullptr;
     
     typename MapTy::iterator I = Map.find(Lookup);
     // Is it in the map?  
@@ -648,7 +640,7 @@ public:
 
 // Unique map for aggregate constants
 template<class TypeClass, class ConstantClass>
-class LLVM_LIBRARY_VISIBILITY ConstantAggrUniqueMap {
+class ConstantAggrUniqueMap {
 public:
   typedef ArrayRef<Constant*> Operands;
   typedef std::pair<TypeClass*, Operands> LookupKey;
@@ -731,7 +723,7 @@ public:
   /// necessary.
   ConstantClass *getOrCreate(TypeClass *Ty, Operands V) {
     LookupKey Lookup(Ty, V);
-    ConstantClass* Result = 0;
+    ConstantClass* Result = nullptr;
 
     typename MapTy::iterator I = Map.find_as(Lookup);
     // Is it in the map?