diff options
author | Chris Lattner <sabre@nondot.org> | 2001-11-26 17:00:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-11-26 17:00:13 +0000 |
commit | 491b29f2471410cf7890698c3ad94118a32a0656 (patch) | |
tree | 27d0ef64eb3a10ef205138792622e81aa40ccce3 /lib/Transforms/TransformInternals.h | |
parent | 89a1c806ea632f0f3cc054e0fe01b98e711c9e6c (diff) | |
download | external_llvm-491b29f2471410cf7890698c3ad94118a32a0656.zip external_llvm-491b29f2471410cf7890698c3ad94118a32a0656.tar.gz external_llvm-491b29f2471410cf7890698c3ad94118a32a0656.tar.bz2 |
Support Composite's, not just structs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1344 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/TransformInternals.h')
-rw-r--r-- | lib/Transforms/TransformInternals.h | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h index 7797ed1..8edeffc 100644 --- a/lib/Transforms/TransformInternals.h +++ b/lib/Transforms/TransformInternals.h @@ -12,6 +12,7 @@ #include "llvm/Instruction.h" #include "llvm/Target/TargetData.h" #include "llvm/DerivedTypes.h" +#include "llvm/ConstPoolVals.h" #include <map> #include <set> @@ -23,11 +24,11 @@ // extern const TargetData TD; -// losslessCastableTypes - Return true if the types are bitwise equivalent. -// This predicate returns true if it is possible to cast from one type to -// another without gaining or losing precision, or altering the bits in any way. -// -bool losslessCastableTypes(const Type *T1, const Type *T2); +static int getConstantValue(const ConstPoolInt *CPI) { + if (const ConstPoolSInt *CSI = dyn_cast<ConstPoolSInt>(CPI)) + return CSI->getValue(); + return cast<ConstPoolUInt>(CPI)->getValue(); +} // isFirstClassType - Return true if a value of the specified type can be held @@ -37,12 +38,12 @@ static inline bool isFirstClassType(const Type *Ty) { 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. +// getPointedToComposite - If the argument is a pointer type, and the pointed to +// value is a composite type, return the composite type, else return null. // -static inline const StructType *getPointedToStruct(const Type *Ty) { +static inline const CompositeType *getPointedToComposite(const Type *Ty) { const PointerType *PT = dyn_cast<PointerType>(Ty); - return PT ? dyn_cast<StructType>(PT->getValueType()) : 0; + return PT ? dyn_cast<CompositeType>(PT->getValueType()) : 0; } @@ -60,6 +61,19 @@ void ReplaceInstWithInst(BasicBlock::InstListType &BIL, BasicBlock::iterator &BI, Instruction *I); +// ConvertableToGEP - This function returns true if the specified value V is +// a valid index into a pointer of type Ty. If it is valid, Idx is filled in +// with the values that would be appropriate to make this a getelementptr +// instruction. The type returned is the root type that the GEP would point +// to if it were synthesized with this operands. +// +// If BI is nonnull, cast instructions are inserted as appropriate for the +// arguments of the getelementptr. +// +const Type *ConvertableToGEP(const Type *Ty, Value *V, vector<Value*> &Indices, + BasicBlock::iterator *BI = 0); + + // ------------- Expression Conversion --------------------- typedef map<const Value*, const Type*> ValueTypeCache; @@ -81,11 +95,11 @@ struct ValueMapCache { 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); +// ValueConvertableToType - Return true if it is possible +bool ValueConvertableToType(Value *V, const Type *Ty, + ValueTypeCache &ConvertedTypes); -void ConvertUsersType(Value *V, Value *NewVal, ValueMapCache &VMC); +void ConvertValueToNewType(Value *V, Value *NewVal, ValueMapCache &VMC); //===----------------------------------------------------------------------===// @@ -128,7 +142,7 @@ public: // false if you want a leaf // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, - vector<ConstPoolVal*> &Offsets, + vector<Value*> &Offsets, bool StopEarly = true); #endif |