mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
protected:
- DerivedType(PrimitiveID id) : Type("", id) {}
+ DerivedType(TypeID id) : Type("", id) {}
~DerivedType() {
assert(AbstractTypeUsers.empty());
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const FunctionType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == FunctionTyID;
+ return T->getTypeID() == FunctionTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
///
class CompositeType : public DerivedType {
protected:
- inline CompositeType(PrimitiveID id) : DerivedType(id) { }
+ inline CompositeType(TypeID id) : DerivedType(id) { }
public:
/// getTypeAtIndex - Given an index value into the type, return the type of
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const CompositeType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == ArrayTyID ||
- T->getPrimitiveID() == StructTyID ||
- T->getPrimitiveID() == PointerTyID;
+ return T->getTypeID() == ArrayTyID ||
+ T->getTypeID() == StructTyID ||
+ T->getTypeID() == PointerTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const StructType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == StructTyID;
+ return T->getTypeID() == StructTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
SequentialType(const SequentialType &); // Do not implement!
const SequentialType &operator=(const SequentialType &); // Do not implement!
protected:
- SequentialType(PrimitiveID TID, const Type *ElType) : CompositeType(TID) {
+ SequentialType(TypeID TID, const Type *ElType) : CompositeType(TID) {
ContainedTys.reserve(1);
ContainedTys.push_back(PATypeHandle(ElType, this));
}
}
virtual bool indexValid(const Value *V) const {
const Type *Ty = V->getType();
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::IntTyID:
case Type::UIntTyID:
case Type::LongTyID:
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const SequentialType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == ArrayTyID ||
- T->getPrimitiveID() == PointerTyID;
+ return T->getTypeID() == ArrayTyID ||
+ T->getTypeID() == PointerTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ArrayType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == ArrayTyID;
+ return T->getTypeID() == ArrayTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
// Implement support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const PointerType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == PointerTyID;
+ return T->getTypeID() == PointerTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
// Implement support for type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const OpaqueType *T) { return true; }
static inline bool classof(const Type *T) {
- return T->getPrimitiveID() == OpaqueTyID;
+ return T->getTypeID() == OpaqueTyID;
}
static inline bool classof(const Value *V) {
return isa<Type>(V) && classof(cast<Type>(V));
/// Note: If you add an element to this, you need to add an element to the
/// Type::getPrimitiveType function, or else things will break!
///
- enum PrimitiveID {
+ enum TypeID {
VoidTyID = 0 , BoolTyID, // 0, 1: Basics...
UByteTyID , SByteTyID, // 2, 3: 8 bit types...
UShortTyID , ShortTyID, // 4, 5: 16 bit types...
//PackedTyID , // SIMD 'packed' format... TODO
//...
- NumPrimitiveIDs, // Must remain as last defined ID
+ NumTypeIDs, // Must remain as last defined ID
FirstDerivedTyID = FunctionTyID,
};
private:
- PrimitiveID ID; // The current base type of this type...
- unsigned UID; // The unique ID number for this class
- bool Abstract; // True if type contains an OpaqueType
+ TypeID ID; // The current base type of this type...
+ unsigned UID; // The unique ID number for this class
+ bool Abstract; // True if type contains an OpaqueType
/// RefCount - This counts the number of PATypeHolders that are pointing to
/// this type. When this number falls to zero, if the type is abstract and
const Type *getForwardedTypeInternal() const;
protected:
/// ctor is protected, so only subclasses can create Type objects...
- Type(const std::string &Name, PrimitiveID id);
+ Type(const std::string &Name, TypeID id);
virtual ~Type() {}
// are defined in private classes defined in Type.cpp for primitive types.
//
- /// getPrimitiveID - Return the base type of the type. This will return one
- /// of the PrimitiveID enum elements defined above.
+ /// getTypeID - Return the type id for the type. This will return one
+ /// of the TypeID enum elements defined above.
///
- inline PrimitiveID getPrimitiveID() const { return ID; }
+ inline TypeID getTypeID() const { return ID; }
/// getUniqueID - Returns the UID of the type. This can be thought of as a
/// small integer version of the pointer to the type class. Two types that
//
/// getPrimitiveType/getUniqueIDType - Return a type based on an identifier.
- static const Type *getPrimitiveType(PrimitiveID IDNumber);
+ static const Type *getPrimitiveType(TypeID IDNumber);
static const Type *getUniqueIDType(unsigned UID);
//===--------------------------------------------------------------------===//
};
template <> inline bool isa_impl<PointerType, Type>(const Type &Ty) {
- return Ty.getPrimitiveID() == Type::PointerTyID;
+ return Ty.getTypeID() == Type::PointerTyID;
}
} // End llvm namespace
while (O < Offset) {
assert(Offset-O < TD.getTypeSize(SubType) && "Offset out of range!");
- switch (SubType->getPrimitiveID()) {
+ switch (SubType->getTypeID()) {
case Type::StructTyID: {
const StructType *STy = cast<StructType>(SubType);
const StructLayout &SL = *TD.getStructLayout(STy);
const Type *NextSubType = 0;
unsigned NextSubTypeSize = 0;
unsigned NextPadSize = 0;
- switch (SubType->getPrimitiveID()) {
+ switch (SubType->getTypeID()) {
case Type::StructTyID: {
const StructType *STy = cast<StructType>(SubType);
const StructLayout &SL = *TD.getStructLayout(STy);
isa<FunctionType>(cast<PointerType>(Ty)->getElementType()))
Ty = cast<PointerType>(Ty)->getElementType();
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getDef();
default: return ((ValuePlaceHolder*)Val)->getDef();
}
isa<FunctionType>(cast<PointerType>(Ty)->getElementType()))
Ty = cast<PointerType>(Ty)->getElementType();
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::LabelTyID: return ((BBPlaceHolder*)Val)->getLineNum();
default: return ((ValuePlaceHolder*)Val)->getLineNum();
}
// forward, so just create an entry to be resolved later and get to it...
//
Value *d = 0;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::LabelTyID: d = new BBPlaceHolder(Ty, D); break;
default: d = new ValuePlaceHolder(Ty, D); break;
}
//cerr << "Looking up Type ID: " << ID << "\n";
if (ID < Type::FirstDerivedTyID)
- if (const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID))
+ if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID))
return T; // Asked for a primitive type...
// Otherwise, derived types need offset...
unsigned PrimType = read_vbr_uint();
const Type *Val = 0;
- if ((Val = Type::getPrimitiveType((Type::PrimitiveID)PrimType)))
+ if ((Val = Type::getPrimitiveType((Type::TypeID)PrimType)))
return Val;
switch (PrimType) {
// Ok, not an ConstantExpr. We now know how to read the given type...
const Type *Ty = getType(TypeID);
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: {
unsigned Val = read_vbr_uint();
if (Val != 0 && Val != 1)
/// fancy features are supported.
const Type *getGlobalTableType(unsigned Slot) {
if (Slot < Type::FirstDerivedTyID) {
- const Type *Ty = Type::getPrimitiveType((Type::PrimitiveID)Slot);
+ const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot);
assert(Ty && "Not a primitive type ID?");
return Ty;
}
unsigned getGlobalTableTypeSlot(const Type *Ty) {
if (Ty->isPrimitiveType())
- return Ty->getPrimitiveID();
+ return Ty->getTypeID();
TypeListTy::iterator I = find(ModuleTypes.begin(),
ModuleTypes.end(), Ty);
if (I == ModuleTypes.end())
unsigned PrimType = read_vbr_uint(Buf, EndBuf);
const Type *Val = 0;
- if ((Val = Type::getPrimitiveType((Type::PrimitiveID)PrimType)))
+ if ((Val = Type::getPrimitiveType((Type::TypeID)PrimType)))
return Val;
switch (PrimType) {
// Ok, not an ConstantExpr. We now know how to read the given type...
const Type *Ty = getType(TypeID);
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: {
unsigned Val = read_vbr_uint(Buf, EndBuf);
if (Val != 0 && Val != 1) throw std::string("Invalid boolean value read.");
//cerr << "Looking up Type ID: " << ID << "\n";
if (ID < Type::FirstDerivedTyID)
- if (const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID))
+ if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID))
return T; // Asked for a primitive type...
// Otherwise, derived types need offset...
unsigned PrimType = read_vbr_uint();
const Type *Val = 0;
- if ((Val = Type::getPrimitiveType((Type::PrimitiveID)PrimType)))
+ if ((Val = Type::getPrimitiveType((Type::TypeID)PrimType)))
return Val;
switch (PrimType) {
// Ok, not an ConstantExpr. We now know how to read the given type...
const Type *Ty = getType(TypeID);
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: {
unsigned Val = read_vbr_uint();
if (Val != 0 && Val != 1)
/// fancy features are supported.
const Type *getGlobalTableType(unsigned Slot) {
if (Slot < Type::FirstDerivedTyID) {
- const Type *Ty = Type::getPrimitiveType((Type::PrimitiveID)Slot);
+ const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot);
assert(Ty && "Not a primitive type ID?");
return Ty;
}
unsigned getGlobalTableTypeSlot(const Type *Ty) {
if (Ty->isPrimitiveType())
- return Ty->getPrimitiveID();
+ return Ty->getTypeID();
TypeListTy::iterator I = find(ModuleTypes.begin(),
ModuleTypes.end(), Ty);
if (I == ModuleTypes.end())
unsigned BytecodeParser::getTypeSlot(const Type *Ty) {
if (Ty->isPrimitiveType())
- return Ty->getPrimitiveID();
+ return Ty->getTypeID();
// Scan the compaction table for the type if needed.
if (CompactionTable.size() > Type::TypeTyID) {
//cerr << "Looking up Type ID: " << ID << "\n";
if (ID < Type::FirstDerivedTyID)
- if (const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID))
+ if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID))
return T; // Asked for a primitive type...
// Otherwise, derived types need offset...
/// fancy features are supported.
const Type *getGlobalTableType(unsigned Slot) {
if (Slot < Type::FirstDerivedTyID) {
- const Type *Ty = Type::getPrimitiveType((Type::PrimitiveID)Slot);
+ const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot);
assert(Ty && "Not a primitive type ID?");
return Ty;
}
unsigned getGlobalTableTypeSlot(const Type *Ty) {
if (Ty->isPrimitiveType())
- return Ty->getPrimitiveID();
+ return Ty->getTypeID();
TypeValuesListTy::iterator I = find(ModuleTypeValues.begin(),
ModuleTypeValues.end(), Ty);
if (I == ModuleTypeValues.end())
using namespace llvm;
void BytecodeWriter::outputType(const Type *T) {
- output_vbr((unsigned)T->getPrimitiveID(), Out);
+ output_vbr((unsigned)T->getTypeID(), Out);
// That's all there is to handling primitive types...
if (T->isPrimitiveType()) {
return; // We might do this if we alias a prim type: %x = type int
}
- switch (T->getPrimitiveID()) { // Handle derived types now.
+ switch (T->getTypeID()) { // Handle derived types now.
case Type::FunctionTyID: {
const FunctionType *MT = cast<FunctionType>(T);
int Slot = Table.getSlot(MT->getReturnType());
// Terminate list with VoidTy if we are a varargs function...
if (MT->isVarArg())
- output_vbr((unsigned)Type::VoidTy->getPrimitiveID(), Out);
+ output_vbr((unsigned)Type::VoidTyID, Out);
break;
}
}
// Terminate list with VoidTy
- output_vbr((unsigned)Type::VoidTy->getPrimitiveID(), Out);
+ output_vbr((unsigned)Type::VoidTyID, Out);
break;
}
output_vbr(0U, Out); // flag as not a ConstantExpr
}
- switch (CPV->getType()->getPrimitiveID()) {
+ switch (CPV->getType()->getTypeID()) {
case Type::BoolTyID: // Boolean Types
if (cast<ConstantBool>(CPV)->getValue())
output_vbr(1U, Out);
if (isa<SequentialType>(*TI)) {
unsigned IdxId;
- switch (I->getOperand(Idx)->getType()->getPrimitiveID()) {
+ switch (I->getOperand(Idx)->getType()->getTypeID()) {
default: assert(0 && "Unknown index type!");
case Type::UIntTyID: IdxId = 0; break;
case Type::IntTyID: IdxId = 1; break;
I != E; ++I, ++Idx)
if (isa<SequentialType>(*I)) {
unsigned IdxId;
- switch (GEP->getOperand(Idx)->getType()->getPrimitiveID()) {
+ switch (GEP->getOperand(Idx)->getType()->getTypeID()) {
default: assert(0 && "Unknown index type!");
case Type::UIntTyID: IdxId = 0; break;
case Type::IntTyID: IdxId = 1; break;
//
SC_DEBUG("Inserting primitive types:\n");
for (unsigned i = 0; i < Type::FirstDerivedTyID; ++i) {
- assert(Type::getPrimitiveType((Type::PrimitiveID)i));
- insertValue(Type::getPrimitiveType((Type::PrimitiveID)i), true);
+ assert(Type::getPrimitiveType((Type::TypeID)i));
+ insertValue(Type::getPrimitiveType((Type::TypeID)i), true);
}
if (M == 0) return; // Empty table...
//
SC_DEBUG("Inserting primitive types:\n");
for (unsigned i = 0; i < Type::FirstDerivedTyID; ++i) {
- assert(Type::getPrimitiveType((Type::PrimitiveID)i));
- insertValue(Type::getPrimitiveType((Type::PrimitiveID)i), true);
+ assert(Type::getPrimitiveType((Type::TypeID)i));
+ insertValue(Type::getPrimitiveType((Type::TypeID)i), true);
}
if (TheModule == 0) return; // Empty table...
// Make sure to insert the null entry if the thing we are inserting is not a
// null constant.
- if (TyPlane.empty() && hasNullValue(V->getType()->getPrimitiveID())) {
+ if (TyPlane.empty() && hasNullValue(V->getType()->getTypeID())) {
Value *ZeroInitializer = Constant::getNullValue(V->getType());
if (V != ZeroInitializer) {
TyPlane.push_back(ZeroInitializer);
// First step, insert the primitive types.
CompactionTable.resize(Type::TypeTyID+1);
for (unsigned i = 0; i != Type::FirstDerivedTyID; ++i) {
- const Type *PrimTy = Type::getPrimitiveType((Type::PrimitiveID)i);
+ const Type *PrimTy = Type::getPrimitiveType((Type::TypeID)i);
CompactionTable[Type::TypeTyID].push_back(PrimTy);
CompactionNodeMap[PrimTy] = i;
}
}
Ty = (unsigned)ValSlot;
} else {
- Ty = Typ->getPrimitiveID();
+ Ty = Typ->getTypeID();
}
if (Table.size() <= Ty) // Make sure we have the type plane allocated...
// and that their Primitive ID is equal to their slot #
void SlotTable::insertPrimitives() {
for (PlaneNum plane = 0; plane < Type::FirstDerivedTyID; ++plane) {
- const Type* Ty = Type::getPrimitiveType((Type::PrimitiveID) plane);
+ const Type* Ty = Type::getPrimitiveType((Type::TypeID) plane);
assert(Ty && "Couldn't get primitive type id");
SlotNum slot = this->insert(Ty);
assert(slot == plane && "Type slot didn't match plane number");
/// This type is used throughout the code to make it clear that an
/// unsigned value refers to a type plane number and not something else.
- /// @brief The type of a plane number (corresponds to Type::PrimitiveID).
+ /// @brief The type of a plane number (corresponds to Type::TypeID).
typedef unsigned PlaneNum;
/// @brief Some constants used as flags instead of actual slot numbers
/// @brief A single plane of Values. Intended index is slot number.
typedef std::vector<const Value*> ValuePlane;
- /// @brief A table of Values. Intended index is Type::PrimitiveID.
+ /// @brief A table of Values. Intended index is Type::TypeID.
typedef std::vector<ValuePlane> ValueTable;
/// @brief A map of values to slot numbers.
/// method works on all scalar LLVM types.
///
MVT::ValueType SelectionDAG::getValueType(const Type *Ty) const {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::VoidTyID: assert(0 && "Void type object in getValueType!");
default: assert(0 && "Unknown type in DAGBuilder!\n");
case Type::BoolTyID: return MVT::i1;
GenericValue GV = getConstantValue(Op);
// Handle cast of pointer to pointer...
- if (Op->getType()->getPrimitiveID() == C->getType()->getPrimitiveID())
+ if (Op->getType()->getTypeID() == C->getType()->getTypeID())
return GV;
// Handle a cast of pointer to any integral type...
// Handle cast of integer to a pointer...
if (isa<PointerType>(C->getType()) && Op->getType()->isIntegral())
- switch (Op->getType()->getPrimitiveID()) {
+ switch (Op->getType()->getTypeID()) {
case Type::BoolTyID: return PTOGV((void*)(uintptr_t)GV.BoolVal);
case Type::SByteTyID: return PTOGV((void*)( intptr_t)GV.SByteVal);
case Type::UByteTyID: return PTOGV((void*)(uintptr_t)GV.UByteVal);
abort();
}
- switch (C->getType()->getPrimitiveID()) {
+ switch (C->getType()->getTypeID()) {
#define GET_CONST_VAL(TY, CLASS) \
case Type::TY##TyID: Result.TY##Val = cast<CLASS>(C)->getValue(); break
GET_CONST_VAL(Bool , ConstantBool);
void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
const Type *Ty) {
if (getTargetData().isLittleEndian()) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID:
case Type::SByteTyID: Ptr->Untyped[0] = Val.UByteVal; break;
std::cout << "Cannot store value of type " << Ty << "!\n";
}
} else {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID:
case Type::SByteTyID: Ptr->Untyped[0] = Val.UByteVal; break;
const Type *Ty) {
GenericValue Result;
if (getTargetData().isLittleEndian()) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID:
case Type::SByteTyID: Result.UByteVal = Ptr->Untyped[0]; break;
abort();
}
} else {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID:
case Type::SByteTyID: Result.UByteVal = Ptr->Untyped[0]; break;
return;
}
- switch (Init->getType()->getPrimitiveID()) {
+ switch (Init->getType()->getTypeID()) {
case Type::ArrayTyID: {
const ConstantArray *CPA = cast<ConstantArray>(Init);
const std::vector<Use> &Val = CPA->getValues();
static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(+, UByte);
IMPLEMENT_BINARY_OPERATOR(+, SByte);
IMPLEMENT_BINARY_OPERATOR(+, UShort);
static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(-, UByte);
IMPLEMENT_BINARY_OPERATOR(-, SByte);
IMPLEMENT_BINARY_OPERATOR(-, UShort);
static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(*, UByte);
IMPLEMENT_BINARY_OPERATOR(*, SByte);
IMPLEMENT_BINARY_OPERATOR(*, UShort);
static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(/, UByte);
IMPLEMENT_BINARY_OPERATOR(/, SByte);
IMPLEMENT_BINARY_OPERATOR(/, UShort);
static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(%, UByte);
IMPLEMENT_BINARY_OPERATOR(%, SByte);
IMPLEMENT_BINARY_OPERATOR(%, UShort);
static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(&, Bool);
IMPLEMENT_BINARY_OPERATOR(&, UByte);
IMPLEMENT_BINARY_OPERATOR(&, SByte);
static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(|, Bool);
IMPLEMENT_BINARY_OPERATOR(|, UByte);
IMPLEMENT_BINARY_OPERATOR(|, SByte);
static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_BINARY_OPERATOR(^, Bool);
IMPLEMENT_BINARY_OPERATOR(^, UByte);
IMPLEMENT_BINARY_OPERATOR(^, SByte);
static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(==, UByte);
IMPLEMENT_SETCC(==, SByte);
IMPLEMENT_SETCC(==, UShort);
static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(!=, UByte);
IMPLEMENT_SETCC(!=, SByte);
IMPLEMENT_SETCC(!=, UShort);
static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(<=, UByte);
IMPLEMENT_SETCC(<=, SByte);
IMPLEMENT_SETCC(<=, UShort);
static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(>=, UByte);
IMPLEMENT_SETCC(>=, SByte);
IMPLEMENT_SETCC(>=, UShort);
static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(<, UByte);
IMPLEMENT_SETCC(<, SByte);
IMPLEMENT_SETCC(<, UShort);
static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SETCC(>, UByte);
IMPLEMENT_SETCC(>, SByte);
IMPLEMENT_SETCC(>, UShort);
GenericValue IdxGV = getOperandValue(I.getOperand(), SF);
uint64_t Idx;
- switch (I.getOperand()->getType()->getPrimitiveID()) {
+ switch (I.getOperand()->getType()->getTypeID()) {
default: assert(0 && "Illegal getelementptr index for sequential type!");
case Type::SByteTyID: Idx = IdxGV.SByteVal; break;
case Type::ShortTyID: Idx = IdxGV.ShortVal; break;
static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SHIFT(<<, UByte);
IMPLEMENT_SHIFT(<<, SByte);
IMPLEMENT_SHIFT(<<, UShort);
static GenericValue executeShrInst(GenericValue Src1, GenericValue Src2,
const Type *Ty) {
GenericValue Dest;
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_SHIFT(>>, UByte);
IMPLEMENT_SHIFT(>>, SByte);
IMPLEMENT_SHIFT(>>, UShort);
#define IMPLEMENT_CAST_CASE_START(DESTTY, DESTCTY) \
case Type::DESTTY##TyID: \
- switch (SrcTy->getPrimitiveID()) { \
+ switch (SrcTy->getTypeID()) { \
IMPLEMENT_CAST(DESTTY, DESTCTY, Bool); \
IMPLEMENT_CAST(DESTTY, DESTCTY, UByte); \
IMPLEMENT_CAST(DESTTY, DESTCTY, SByte); \
const Type *SrcTy = SrcVal->getType();
GenericValue Dest, Src = getOperandValue(SrcVal, SF);
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_CAST_CASE(UByte , (unsigned char));
IMPLEMENT_CAST_CASE(SByte , ( signed char));
IMPLEMENT_CAST_CASE(UShort , (unsigned short));
GenericValue Src = ECStack[VAList.UIntPairVal.first]
.VarArgs[VAList.UIntPairVal.second];
const Type *Ty = I.getType();
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
IMPLEMENT_VAARG(UByte);
IMPLEMENT_VAARG(SByte);
IMPLEMENT_VAARG(UShort);
static Interpreter *TheInterpreter;
static char getTypeID(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::VoidTyID: return 'V';
case Type::BoolTyID: return 'o';
case Type::UByteTyID: return 'B';
// Two types cannot be resolved together if they are of different primitive
// type. For example, we cannot resolve an int to a float.
- if (DestTyT->getPrimitiveID() != SrcTyT->getPrimitiveID()) return true;
+ if (DestTyT->getTypeID() != SrcTyT->getTypeID()) return true;
// Otherwise, resolve the used type used by this derived type...
- switch (DestTyT->getPrimitiveID()) {
+ switch (DestTyT->getTypeID()) {
case Type::FunctionTyID: {
if (cast<FunctionType>(DestTyT)->isVarArg() !=
cast<FunctionType>(SrcTyT)->isVarArg() ||
const std::string &NameSoFar,
bool IgnoreName) {
if (Ty->isPrimitiveType())
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::VoidTyID: return Out << "void " << NameSoFar;
case Type::BoolTyID: return Out << "bool " << NameSoFar;
case Type::UByteTyID: return Out << "unsigned char " << NameSoFar;
if (I != TypeNames.end()) return Out << I->second << " " << NameSoFar;
}
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FunctionTyID: {
const FunctionType *MTy = cast<FunctionType>(Ty);
std::stringstream FunctionInnards;
}
}
- switch (CPV->getType()->getPrimitiveID()) {
+ switch (CPV->getType()->getTypeID()) {
case Type::BoolTyID:
Out << (CPV == ConstantBool::False ? "0" : "1"); break;
case Type::SByteTyID:
const std::string &NameSoFar,
bool IgnoreName) {
if (Ty->isPrimitiveType())
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::VoidTyID: return Out << "void " << NameSoFar;
case Type::BoolTyID: return Out << "bool " << NameSoFar;
case Type::UByteTyID: return Out << "unsigned char " << NameSoFar;
if (I != TypeNames.end()) return Out << I->second << " " << NameSoFar;
}
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FunctionTyID: {
const FunctionType *MTy = cast<FunctionType>(Ty);
std::stringstream FunctionInnards;
}
}
- switch (CPV->getType()->getPrimitiveID()) {
+ switch (CPV->getType()->getTypeID()) {
case Type::BoolTyID:
Out << (CPV == ConstantBool::False ? "0" : "1"); break;
case Type::SByteTyID:
};
static TypeClass getClass (const Type *T) {
- switch (T->getPrimitiveID ()) {
+ switch (T->getTypeID()) {
case Type::UByteTyID: case Type::SByteTyID: return cByte;
case Type::UShortTyID: case Type::ShortTyID: return cShort;
case Type::PointerTyID:
// FP Constants are printed as integer constants to avoid losing
// precision...
double Val = CFP->getValue();
- switch (CFP->getType()->getPrimitiveID()) {
+ switch (CFP->getType()->getTypeID()) {
default: assert(0 && "Unknown floating point type!");
case Type::FloatTyID: {
union FU { // Abide by C TBAA rules
const Type *type = CV->getType();
O << "\t";
- switch (type->getPrimitiveID()) {
+ switch (type->getTypeID()) {
case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
O << ".byte";
break;
const TargetRegisterClass*
SparcV8RegisterInfo::getRegClassForType(const Type* Ty) const {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FloatTyID: return &FPRegsInstance;
case Type::DoubleTyID: return &DFPRegsInstance;
case Type::LongTyID:
};
static TypeClass getClass (const Type *T) {
- switch (T->getPrimitiveID ()) {
+ switch (T->getTypeID()) {
case Type::UByteTyID: case Type::SByteTyID: return cByte;
case Type::UShortTyID: case Type::ShortTyID: return cShort;
case Type::PointerTyID:
};
static TypeClass getClass (const Type *T) {
- switch (T->getPrimitiveID ()) {
+ switch (T->getTypeID()) {
case Type::UByteTyID: case Type::SByteTyID: return cByte;
case Type::UShortTyID: case Type::ShortTyID: return cShort;
case Type::PointerTyID:
// FP Constants are printed as integer constants to avoid losing
// precision...
double Val = CFP->getValue();
- switch (CFP->getType()->getPrimitiveID()) {
+ switch (CFP->getType()->getTypeID()) {
default: assert(0 && "Unknown floating point type!");
case Type::FloatTyID: {
union FU { // Abide by C TBAA rules
const Type *type = CV->getType();
O << "\t";
- switch (type->getPrimitiveID()) {
+ switch (type->getTypeID()) {
case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
O << ".byte";
break;
};
static TypeClass getClass (const Type *T) {
- switch (T->getPrimitiveID ()) {
+ switch (T->getTypeID()) {
case Type::UByteTyID: case Type::SByteTyID: return cByte;
case Type::UShortTyID: case Type::ShortTyID: return cShort;
case Type::PointerTyID:
const TargetRegisterClass*
SparcV8RegisterInfo::getRegClassForType(const Type* Ty) const {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FloatTyID: return &FPRegsInstance;
case Type::DoubleTyID: return &DFPRegsInstance;
case Type::LongTyID:
opLabel = opLabel + 100; // bitwise operator
} else if (opLabel == Instruction::Cast) {
const Type *ITy = I->getType();
- switch(ITy->getPrimitiveID())
+ switch(ITy->getTypeID())
{
case Type::BoolTyID: opLabel = ToBoolTy; break;
case Type::UByteTyID: opLabel = ToUByteTy; break;
inline const std::string
TypeToDataDirective(const Type* type) {
- switch(type->getPrimitiveID())
- {
+ switch(type->getTypeID()) {
case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
return ".byte";
case Type::UShortTyID: case Type::ShortTyID:
if (resultType->isInteger() || isa<PointerType>(resultType)) {
opCode = V9::SUBr;
} else {
- switch(resultType->getPrimitiveID())
+ switch(resultType->getTypeID())
{
case Type::FloatTyID: opCode = V9::FSUBS; break;
case Type::DoubleTyID: opCode = V9::FSUBD; break;
MachineOpCode opCode = V9::INVALID_OPCODE;
Value* operand = ((InstrTreeNode*) instrNode->leftChild())->getValue();
- switch(operand->getType()->getPrimitiveID()) {
+ switch(operand->getType()->getTypeID()) {
case Type::FloatTyID: opCode = V9::FCMPS; break;
case Type::DoubleTyID: opCode = V9::FCMPD; break;
default: assert(0 && "Invalid type for FCMP instruction"); break;
if (resultType->isInteger())
opCode = V9::MULXr;
else
- switch(resultType->getPrimitiveID())
+ switch(resultType->getTypeID())
{
case Type::FloatTyID: opCode = V9::FMULS; break;
case Type::DoubleTyID: opCode = V9::FMULD; break;
if (resultType->isInteger())
opCode = resultType->isSigned()? V9::SDIVXr : V9::UDIVXr;
else
- switch(resultType->getPrimitiveID())
+ switch(resultType->getTypeID())
{
case Type::FloatTyID: opCode = V9::FDIVS; break;
case Type::DoubleTyID: opCode = V9::FDIVD; break;
inline MachineOpCode
ChooseLoadInstruction(const Type *DestTy)
{
- switch (DestTy->getPrimitiveID()) {
+ switch (DestTy->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID: return V9::LDUBr;
case Type::SByteTyID: return V9::LDSBr;
inline MachineOpCode
ChooseStoreInstruction(const Type *DestTy)
{
- switch (DestTy->getPrimitiveID()) {
+ switch (DestTy->getTypeID()) {
case Type::BoolTyID:
case Type::UByteTyID:
case Type::SByteTyID: return V9::STBr;
opCode = V9::ADDr;
}
else
- switch(resultType->getPrimitiveID())
+ switch(resultType->getTypeID())
{
case Type::FloatTyID: opCode = V9::FADDS; break;
case Type::DoubleTyID: opCode = V9::FADDD; break;
//
unsigned SparcV9RegInfo::getRegClassIDOfType(const Type *type,
bool isCCReg) const {
- Type::PrimitiveID ty = type->getPrimitiveID();
+ Type::TypeID ty = type->getTypeID();
unsigned res;
// FIXME: Comparing types like this isn't very safe...
static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
uint64_t &Size, unsigned char &Alignment) {
assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!");
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::VoidTyID:
case Type::BoolTyID:
case Type::UByteTyID:
/// size of the type, and whether or not it is floating point.
///
static inline TypeClass getClass(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::SByteTyID:
case Type::UByteTyID: return cByte; // Byte operands are class #0
case Type::ShortTyID:
const Type *PromoteType = 0;
unsigned PromoteOpcode = 0;
unsigned RealDestReg = DestReg;
- switch (SrcTy->getPrimitiveID()) {
+ switch (SrcTy->getTypeID()) {
case Type::BoolTyID:
case Type::SByteTyID:
// We don't have the facilities for directly loading byte sized data from
unsigned DestReg = getReg(I);
unsigned Size;
- switch (I.getArgType()->getPrimitiveID()) {
+ switch (I.getArgType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
unsigned VAList = getReg(I.getOperand(0));
unsigned DestReg = getReg(I);
- switch (I.getType()->getPrimitiveID()) {
+ switch (I.getType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
// FP Constants are printed as integer constants to avoid losing
// precision...
double Val = CFP->getValue();
- switch (CFP->getType()->getPrimitiveID()) {
+ switch (CFP->getType()->getTypeID()) {
default: assert(0 && "Unknown floating point type!");
case Type::FloatTyID: {
union FU { // Abide by C TBAA rules
const Type *type = CV->getType();
O << "\t";
- switch (type->getPrimitiveID()) {
+ switch (type->getTypeID()) {
case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
O << ".byte";
break;
// FP Constants are printed as integer constants to avoid losing
// precision...
double Val = CFP->getValue();
- switch (CFP->getType()->getPrimitiveID()) {
+ switch (CFP->getType()->getTypeID()) {
default: assert(0 && "Unknown floating point type!");
case Type::FloatTyID: {
union FU { // Abide by C TBAA rules
const Type *type = CV->getType();
O << "\t";
- switch (type->getPrimitiveID()) {
+ switch (type->getTypeID()) {
case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
O << ".byte";
break;
/// size of the type, and whether or not it is floating point.
///
static inline TypeClass getClass(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::SByteTyID:
case Type::UByteTyID: return cByte; // Byte operands are class #0
case Type::ShortTyID:
const Type *PromoteType = 0;
unsigned PromoteOpcode = 0;
unsigned RealDestReg = DestReg;
- switch (SrcTy->getPrimitiveID()) {
+ switch (SrcTy->getTypeID()) {
case Type::BoolTyID:
case Type::SByteTyID:
// We don't have the facilities for directly loading byte sized data from
unsigned DestReg = getReg(I);
unsigned Size;
- switch (I.getArgType()->getPrimitiveID()) {
+ switch (I.getArgType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
unsigned VAList = getReg(I.getOperand(0));
unsigned DestReg = getReg(I);
- switch (I.getType()->getPrimitiveID()) {
+ switch (I.getType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
const TargetRegisterClass*
X86RegisterInfo::getRegClassForType(const Type* Ty) const {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::LongTyID:
case Type::ULongTyID: assert(0 && "Long values can't fit in registers!");
default: assert(0 && "Invalid type to getClass!");
/// size of the type, and whether or not it is floating point.
///
static inline TypeClass getClass(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::SByteTyID:
case Type::UByteTyID: return cByte; // Byte operands are class #0
case Type::ShortTyID:
const Type *PromoteType = 0;
unsigned PromoteOpcode;
unsigned RealDestReg = DestReg;
- switch (SrcTy->getPrimitiveID()) {
+ switch (SrcTy->getTypeID()) {
case Type::BoolTyID:
case Type::SByteTyID:
// We don't have the facilities for directly loading byte sized data from
unsigned DestReg = getReg(I);
unsigned Size;
- switch (I.getArgType()->getPrimitiveID()) {
+ switch (I.getArgType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
unsigned VAList = getReg(I.getOperand(0));
unsigned DestReg = getReg(I);
- switch (I.getType()->getPrimitiveID()) {
+ switch (I.getType()->getTypeID()) {
default:
std::cerr << I;
assert(0 && "Error: bad type for va_next instruction!");
if (!Old->use_empty() && !Concrete->use_empty())
for (unsigned i = 0; i < NumArguments; ++i)
if (OldMT->getParamType(i) != ConcreteMT->getParamType(i))
- if (OldMT->getParamType(i)->getPrimitiveID() !=
- ConcreteMT->getParamType(i)->getPrimitiveID()) {
+ if (OldMT->getParamType(i)->getTypeID() !=
+ ConcreteMT->getParamType(i)->getTypeID()) {
std::cerr << "WARNING: Function [" << Old->getName()
<< "]: Parameter types conflict for: '";
WriteTypeSymbolic(std::cerr, OldMT, &M);
PATypeHolder PlaceHolder = OpaqueType::get();
TypeMap.insert(std::make_pair(Ty, PlaceHolder.get()));
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FunctionTyID: {
const FunctionType *FT = cast<FunctionType>(Ty);
const Type *RetTy = ConvertType(FT->getReturnType());
// Two types cannot be resolved together if they are of different primitive
// type. For example, we cannot resolve an int to a float.
- if (DestTyT->getPrimitiveID() != SrcTyT->getPrimitiveID()) return true;
+ if (DestTyT->getTypeID() != SrcTyT->getTypeID()) return true;
// Otherwise, resolve the used type used by this derived type...
- switch (DestTyT->getPrimitiveID()) {
+ switch (DestTyT->getTypeID()) {
case Type::FunctionTyID: {
if (cast<FunctionType>(DestTyT)->isVarArg() !=
cast<FunctionType>(SrcTyT)->isVarArg() ||
TypeStack.push_back(Ty); // Recursive case: Add us to the stack..
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FunctionTyID: {
const FunctionType *FTy = cast<FunctionType>(Ty);
calcTypeName(FTy->getReturnType(), TypeStack, TypeNames, Result);
isa<ConstantPointerRef>(V1) || isa<ConstantPointerRef>(V2))
return EmptyR;
- switch (V1->getType()->getPrimitiveID()) {
+ switch (V1->getType()->getTypeID()) {
default: assert(0 && "Unknown value type for constant folding!");
case Type::BoolTyID: return BoolR;
case Type::PointerTyID: return NullPointerR;
ConstRules &Rules = ConstRules::get(V, V);
- switch (DestTy->getPrimitiveID()) {
+ switch (DestTy->getTypeID()) {
case Type::BoolTyID: return Rules.castToBool(V);
case Type::UByteTyID: return Rules.castToUByte(V);
case Type::SByteTyID: return Rules.castToSByte(V);
// Static constructor to create a '0' constant of arbitrary type...
Constant *Constant::getNullValue(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: {
static Constant *NullBool = ConstantBool::get(false);
return NullBool;
// Static constructor to create the maximum constant of an integral type...
ConstantIntegral *ConstantIntegral::getMaxValue(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: return ConstantBool::True;
case Type::SByteTyID:
case Type::ShortTyID:
// Static constructor to create the minimum constant for an integral type...
ConstantIntegral *ConstantIntegral::getMinValue(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: return ConstantBool::False;
case Type::SByteTyID:
case Type::ShortTyID:
// Static constructor to create an integral constant with all bits set
ConstantIntegral *ConstantIntegral::getAllOnesValue(const Type *Ty) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::BoolTyID: return ConstantBool::True;
case Type::SByteTyID:
case Type::ShortTyID:
for (unsigned i = 0, e = V.size(); i != e; ++i) {
assert(V[i]->getType() == T->getElementType() ||
(T->isAbstract() &&
- V[i]->getType()->getPrimitiveID() ==
- T->getElementType()->getPrimitiveID()));
+ V[i]->getType()->getTypeID() == T->getElementType()->getTypeID()));
Operands.push_back(Use(V[i], this));
}
}
assert((V[i]->getType() == T->getElementType(i) ||
((T->getElementType(i)->isAbstract() ||
V[i]->getType()->isAbstract()) &&
- T->getElementType(i)->getPrimitiveID() ==
- V[i]->getType()->getPrimitiveID())) &&
+ T->getElementType(i)->getTypeID() == V[i]->getType()->getTypeID())) &&
"Initializer for struct element doesn't match struct element type!");
Operands.push_back(Use(V[i], this));
}
// isValueValidForType implementations
bool ConstantSInt::isValueValidForType(const Type *Ty, int64_t Val) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
default:
return false; // These can't be represented as integers!!!
// Signed types...
}
bool ConstantUInt::isValueValidForType(const Type *Ty, uint64_t Val) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
default:
return false; // These can't be represented as integers!!!
}
bool ConstantFP::isValueValidForType(const Type *Ty, double Val) {
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
default:
return false; // These can't be represented as floating point!
// Two types cannot be resolved together if they are of different primitive
// type. For example, we cannot resolve an int to a float.
- if (DestTyT->getPrimitiveID() != SrcTyT->getPrimitiveID()) return true;
+ if (DestTyT->getTypeID() != SrcTyT->getTypeID()) return true;
// Otherwise, resolve the used type used by this derived type...
- switch (DestTyT->getPrimitiveID()) {
+ switch (DestTyT->getTypeID()) {
case Type::FunctionTyID: {
if (cast<FunctionType>(DestTyT)->isVarArg() !=
cast<FunctionType>(SrcTyT)->isVarArg() ||
static std::map<const Type*, std::string> ConcreteTypeDescriptions;
static std::map<const Type*, std::string> AbstractTypeDescriptions;
-Type::Type(const std::string &name, PrimitiveID id)
+Type::Type(const std::string &name, TypeID id)
: Value(Type::TypeTy, Value::TypeVal), RefCount(0), ForwardType(0) {
if (!name.empty())
ConcreteTypeDescriptions[this] = name;
return UIDMappings[UID];
}
-const Type *Type::getPrimitiveType(PrimitiveID IDNumber) {
+const Type *Type::getPrimitiveType(TypeID IDNumber) {
switch (IDNumber) {
case VoidTyID : return VoidTy;
case BoolTyID : return BoolTy;
if ((!isPrimitiveType() && !isa<PointerType>(this)) ||
(!isa<PointerType>(Ty) && !Ty->isPrimitiveType())) return false;
- if (getPrimitiveID() == Ty->getPrimitiveID())
+ if (getTypeID() == Ty->getTypeID())
return true; // Handles identity cast, and cast of differing pointer types
// Now we know that they are two differing primitive or pointer types
- switch (getPrimitiveID()) {
+ switch (getTypeID()) {
case Type::UByteTyID: return Ty == Type::SByteTy;
case Type::SByteTyID: return Ty == Type::UByteTy;
case Type::UShortTyID: return Ty == Type::ShortTy;
/// getUnsignedVersion - If this is an integer type, return the unsigned
/// variant of this type. For example int -> uint.
const Type *Type::getUnsignedVersion() const {
- switch (getPrimitiveID()) {
+ switch (getTypeID()) {
default:
assert(isInteger()&&"Type::getUnsignedVersion is only valid for integers!");
case Type::UByteTyID:
/// getSignedVersion - If this is an integer type, return the signed variant
/// of this type. For example uint -> int.
const Type *Type::getSignedVersion() const {
- switch (getPrimitiveID()) {
+ switch (getTypeID()) {
default:
assert(isInteger() && "Type::getSignedVersion is only valid for integers!");
case Type::UByteTyID:
// return zero if the type does not have a size or is not a primitive type.
//
unsigned Type::getPrimitiveSize() const {
- switch (getPrimitiveID()) {
+ switch (getTypeID()) {
#define HANDLE_PRIM_TYPE(TY,SIZE) case TY##TyID: return SIZE;
#include "llvm/Type.def"
default: return 0;
std::string Result;
TypeStack.push_back(Ty); // Add us to the stack..
- switch (Ty->getPrimitiveID()) {
+ switch (Ty->getTypeID()) {
case Type::FunctionTyID: {
const FunctionType *FTy = cast<FunctionType>(Ty);
Result = getTypeDescription(FTy->getReturnType(), TypeStack) + " (";
// type.
//
struct SignedIntType : public Type {
- SignedIntType(const std::string &Name, PrimitiveID id) : Type(Name, id) {}
+ SignedIntType(const std::string &Name, TypeID id) : Type(Name, id) {}
// isSigned - Return whether a numeric type is signed.
virtual bool isSigned() const { return 1; }
};
struct UnsignedIntType : public Type {
- UnsignedIntType(const std::string &N, PrimitiveID id) : Type(N, id) {}
+ UnsignedIntType(const std::string &N, TypeID id) : Type(N, id) {}
// isUnsigned - Return whether a numeric type is signed.
virtual bool isUnsigned() const { return 1; }
};
struct OtherType : public Type {
- OtherType(const std::string &N, PrimitiveID id) : Type(N, id) {}
+ OtherType(const std::string &N, TypeID id) : Type(N, id) {}
};
static struct TypeType : public Type {
static bool TypesEqual(const Type *Ty, const Type *Ty2,
std::map<const Type *, const Type *> &EqTypes) {
if (Ty == Ty2) return true;
- if (Ty->getPrimitiveID() != Ty2->getPrimitiveID()) return false;
+ if (Ty->getTypeID() != Ty2->getTypeID()) return false;
if (isa<OpaqueType>(Ty))
return false; // Two unequal opaque types are never equal