mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 22:50:47 +00:00
Support Composite's, not just structs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1344 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
89a1c806ea
commit
491b29f247
@ -12,6 +12,7 @@
|
|||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/ConstPoolVals.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@ -23,11 +24,11 @@
|
|||||||
//
|
//
|
||||||
extern const TargetData TD;
|
extern const TargetData TD;
|
||||||
|
|
||||||
// losslessCastableTypes - Return true if the types are bitwise equivalent.
|
static int getConstantValue(const ConstPoolInt *CPI) {
|
||||||
// This predicate returns true if it is possible to cast from one type to
|
if (const ConstPoolSInt *CSI = dyn_cast<ConstPoolSInt>(CPI))
|
||||||
// another without gaining or losing precision, or altering the bits in any way.
|
return CSI->getValue();
|
||||||
//
|
return cast<ConstPoolUInt>(CPI)->getValue();
|
||||||
bool losslessCastableTypes(const Type *T1, const Type *T2);
|
}
|
||||||
|
|
||||||
|
|
||||||
// isFirstClassType - Return true if a value of the specified type can be held
|
// 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();
|
return Ty->isPrimitiveType() || Ty->isPointerType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPointedToStruct - If the argument is a pointer type, and the pointed to
|
// getPointedToComposite - If the argument is a pointer type, and the pointed to
|
||||||
// value is a struct type, return the struct type, else return null.
|
// 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);
|
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);
|
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 ---------------------
|
// ------------- Expression Conversion ---------------------
|
||||||
|
|
||||||
typedef map<const Value*, const Type*> ValueTypeCache;
|
typedef map<const Value*, const Type*> ValueTypeCache;
|
||||||
@ -81,11 +95,11 @@ struct ValueMapCache {
|
|||||||
bool ExpressionConvertableToType(Value *V, const Type *Ty, ValueTypeCache &Map);
|
bool ExpressionConvertableToType(Value *V, const Type *Ty, ValueTypeCache &Map);
|
||||||
Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC);
|
Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC);
|
||||||
|
|
||||||
// RetValConvertableToType - Return true if it is possible
|
// ValueConvertableToType - Return true if it is possible
|
||||||
bool RetValConvertableToType(Value *V, const Type *Ty,
|
bool ValueConvertableToType(Value *V, const Type *Ty,
|
||||||
ValueTypeCache &ConvertedTypes);
|
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
|
// false if you want a leaf
|
||||||
//
|
//
|
||||||
const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
|
const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
|
||||||
vector<ConstPoolVal*> &Offsets,
|
vector<Value*> &Offsets,
|
||||||
bool StopEarly = true);
|
bool StopEarly = true);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user