Improve raising significantly


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1214 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h
index 94af200..ea42732 100644
--- a/lib/Transforms/TransformInternals.h
+++ b/lib/Transforms/TransformInternals.h
@@ -11,6 +11,7 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Instruction.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/DerivedTypes.h"
 #include <map>
 #include <set>
 
@@ -36,6 +37,14 @@
   return Ty->isPrimitiveType() || Ty->isPointerType();
 }
 
+// getPointedToStruct - If the argument is a pointer type, and the pointed to
+// value is a struct type, return the struct type, else return null.
+//
+static inline const StructType *getPointedToStruct(const Type *Ty) {
+  const PointerType *PT = dyn_cast<PointerType>(Ty);
+  return PT ? dyn_cast<StructType>(PT->getValueType()) : 0;
+}
+
 
 // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI)
 // with a value, then remove and delete the original instruction.
@@ -68,6 +77,10 @@
   typedef map<const Value *, Value *> ExprMapTy;
 };
 
+
+bool ExpressionConvertableToType(Value *V, const Type *Ty, ValueTypeCache &Map);
+Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC);
+
 // RetValConvertableToType - Return true if it is possible
 bool RetValConvertableToType(Value *V, const Type *Ty,
                              ValueTypeCache &ConvertedTypes);
@@ -102,4 +115,19 @@
   }
 };
 
+// getStructOffsetType - Return a vector of offsets that are to be used to index
+// into the specified struct type to get as close as possible to index as we
+// can.  Note that it is possible that we cannot get exactly to Offset, in which
+// case we update offset to be the offset we actually obtained.  The resultant
+// leaf type is returned.
+//
+// If StopEarly is set to true (the default), the first object with the
+// specified type is returned, even if it is a struct type itself.  In this
+// case, this routine will not drill down to the leaf type.  Set StopEarly to
+// false if you want a leaf
+//
+const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
+                                vector<ConstPoolVal*> &Offsets,
+                                bool StopEarly = true);
+
 #endif