Don't force a ConstantPointer to be returned
authorChris Lattner <sabre@nondot.org>
Thu, 17 Apr 2003 19:22:47 +0000 (19:22 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 17 Apr 2003 19:22:47 +0000 (19:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5799 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ConstantHandling.h
lib/VMCore/ConstantFold.h
lib/VMCore/ConstantFolding.h

index 546b37e605fc1cd74550e7feb59cd6d700106f74..8175b6c8be6e8aba0724f710440e37ed751ae97c 100644 (file)
@@ -41,14 +41,12 @@ class PointerType;
 //  Implement == and != directly...
 //===----------------------------------------------------------------------===//
 
-inline ConstantBool *operator==(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator==(const Constant &V1, const Constant &V2) {
   assert(V1.getType() == V2.getType() && "Constant types must be identical!");
   return ConstantBool::get(&V1 == &V2);
 }
 
-inline ConstantBool *operator!=(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator!=(const Constant &V1, const Constant &V2) {
   return ConstantBool::get(&V1 != &V2);
 }
 
@@ -89,8 +87,8 @@ public:
   virtual ConstantUInt *castToULong (const Constant *V) const = 0;
   virtual ConstantFP   *castToFloat (const Constant *V) const = 0;
   virtual ConstantFP   *castToDouble(const Constant *V) const = 0;
-  virtual ConstantPointer *castToPointer(const Constant *V,
-                                         const PointerType *Ty) const = 0;
+  virtual Constant     *castToPointer(const Constant *V,
+                                      const PointerType *Ty) const = 0;
 
   inline Constant *castTo(const Constant *V, const Type *Ty) const {
     switch (Ty->getPrimitiveID()) {
@@ -117,7 +115,7 @@ public:
   static inline ConstRules *get(const Constant &V) {
     return (ConstRules*)V.getType()->getOrCreateAnnotation(AID);
   }
-private :
+private:
   static Annotation *find(AnnotationID AID, const Annotable *Ty, void *);
 
   ConstRules(const ConstRules &);             // Do not implement
@@ -220,5 +218,6 @@ Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
                                         const Constant *V2);
 Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1,
                                        const Constant *V2);
-
+Constant *ConstantFoldGetElementPtr(const Constant *C,
+                                    const std::vector<Constant*> &IdxList);
 #endif
index 546b37e605fc1cd74550e7feb59cd6d700106f74..8175b6c8be6e8aba0724f710440e37ed751ae97c 100644 (file)
@@ -41,14 +41,12 @@ class PointerType;
 //  Implement == and != directly...
 //===----------------------------------------------------------------------===//
 
-inline ConstantBool *operator==(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator==(const Constant &V1, const Constant &V2) {
   assert(V1.getType() == V2.getType() && "Constant types must be identical!");
   return ConstantBool::get(&V1 == &V2);
 }
 
-inline ConstantBool *operator!=(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator!=(const Constant &V1, const Constant &V2) {
   return ConstantBool::get(&V1 != &V2);
 }
 
@@ -89,8 +87,8 @@ public:
   virtual ConstantUInt *castToULong (const Constant *V) const = 0;
   virtual ConstantFP   *castToFloat (const Constant *V) const = 0;
   virtual ConstantFP   *castToDouble(const Constant *V) const = 0;
-  virtual ConstantPointer *castToPointer(const Constant *V,
-                                         const PointerType *Ty) const = 0;
+  virtual Constant     *castToPointer(const Constant *V,
+                                      const PointerType *Ty) const = 0;
 
   inline Constant *castTo(const Constant *V, const Type *Ty) const {
     switch (Ty->getPrimitiveID()) {
@@ -117,7 +115,7 @@ public:
   static inline ConstRules *get(const Constant &V) {
     return (ConstRules*)V.getType()->getOrCreateAnnotation(AID);
   }
-private :
+private:
   static Annotation *find(AnnotationID AID, const Annotable *Ty, void *);
 
   ConstRules(const ConstRules &);             // Do not implement
@@ -220,5 +218,6 @@ Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
                                         const Constant *V2);
 Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1,
                                        const Constant *V2);
-
+Constant *ConstantFoldGetElementPtr(const Constant *C,
+                                    const std::vector<Constant*> &IdxList);
 #endif
index 546b37e605fc1cd74550e7feb59cd6d700106f74..8175b6c8be6e8aba0724f710440e37ed751ae97c 100644 (file)
@@ -41,14 +41,12 @@ class PointerType;
 //  Implement == and != directly...
 //===----------------------------------------------------------------------===//
 
-inline ConstantBool *operator==(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator==(const Constant &V1, const Constant &V2) {
   assert(V1.getType() == V2.getType() && "Constant types must be identical!");
   return ConstantBool::get(&V1 == &V2);
 }
 
-inline ConstantBool *operator!=(const Constant &V1, 
-                                const Constant &V2) {
+inline ConstantBool *operator!=(const Constant &V1, const Constant &V2) {
   return ConstantBool::get(&V1 != &V2);
 }
 
@@ -89,8 +87,8 @@ public:
   virtual ConstantUInt *castToULong (const Constant *V) const = 0;
   virtual ConstantFP   *castToFloat (const Constant *V) const = 0;
   virtual ConstantFP   *castToDouble(const Constant *V) const = 0;
-  virtual ConstantPointer *castToPointer(const Constant *V,
-                                         const PointerType *Ty) const = 0;
+  virtual Constant     *castToPointer(const Constant *V,
+                                      const PointerType *Ty) const = 0;
 
   inline Constant *castTo(const Constant *V, const Type *Ty) const {
     switch (Ty->getPrimitiveID()) {
@@ -117,7 +115,7 @@ public:
   static inline ConstRules *get(const Constant &V) {
     return (ConstRules*)V.getType()->getOrCreateAnnotation(AID);
   }
-private :
+private:
   static Annotation *find(AnnotationID AID, const Annotable *Ty, void *);
 
   ConstRules(const ConstRules &);             // Do not implement
@@ -220,5 +218,6 @@ Constant *ConstantFoldBinaryInstruction(unsigned Opcode, const Constant *V1,
                                         const Constant *V2);
 Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1,
                                        const Constant *V2);
-
+Constant *ConstantFoldGetElementPtr(const Constant *C,
+                                    const std::vector<Constant*> &IdxList);
 #endif