2003-09-30 18:37:50 +00:00
|
|
|
//===-- llvm/DerivedTypes.h - Classes for handling data types ---*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-06-06 20:29:01 +00:00
|
|
|
//
|
2005-04-21 20:19:05 +00:00
|
|
|
// This file contains the declarations of classes that represent "derived
|
2001-06-06 20:29:01 +00:00
|
|
|
// types". These are things like "arrays of x" or "structure of x, y, z" or
|
|
|
|
// "method returning x taking (y,z) as parameters", etc...
|
|
|
|
//
|
|
|
|
// The implementations of these classes live in the Type.cpp file.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DERIVED_TYPES_H
|
|
|
|
#define LLVM_DERIVED_TYPES_H
|
|
|
|
|
|
|
|
#include "llvm/Type.h"
|
2005-01-08 22:44:06 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2004-07-08 15:54:29 +00:00
|
|
|
class Value;
|
2003-09-05 02:30:18 +00:00
|
|
|
template<class ValType, class TypeClass> class TypeMap;
|
|
|
|
class FunctionValType;
|
|
|
|
class ArrayValType;
|
|
|
|
class StructValType;
|
|
|
|
class PointerValType;
|
2004-08-20 06:00:58 +00:00
|
|
|
class PackedValType;
|
2003-09-05 02:30:18 +00:00
|
|
|
|
2005-11-13 03:26:12 +00:00
|
|
|
class DerivedType : public Type {
|
2004-10-07 19:21:43 +00:00
|
|
|
friend class Type;
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
protected:
|
2005-11-13 03:13:26 +00:00
|
|
|
DerivedType(TypeID id) : Type(id) {}
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
/// notifyUsesThatTypeBecameConcrete - Notify AbstractTypeUsers of this type
|
|
|
|
/// that the current type has transitioned from being abstract to being
|
|
|
|
/// concrete.
|
|
|
|
///
|
|
|
|
void notifyUsesThatTypeBecameConcrete();
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// dropAllTypeUses - When this (abstract) type is resolved to be equal to
|
|
|
|
/// another (more concrete) type, we must eliminate all references to other
|
|
|
|
/// types, to avoid some circular reference problems.
|
|
|
|
///
|
2004-02-09 05:40:24 +00:00
|
|
|
void dropAllTypeUses();
|
2004-02-17 02:58:36 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2001-09-07 16:19:29 +00:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Abstract Type handling methods - These types have special lifetimes, which
|
|
|
|
// are managed by (add|remove)AbstractTypeUser. See comments in
|
|
|
|
// AbstractTypeUser.h for more information.
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// refineAbstractTypeTo - This function is used to when it is discovered that
|
|
|
|
/// the 'this' abstract type is actually equivalent to the NewType specified.
|
|
|
|
/// This causes all users of 'this' to switch to reference the more concrete
|
|
|
|
/// type NewType and for 'this' to be deleted.
|
|
|
|
///
|
2003-10-03 18:57:54 +00:00
|
|
|
void refineAbstractTypeTo(const Type *NewType);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
2004-05-25 08:45:42 +00:00
|
|
|
void dump() const { Type::dump(); }
|
2003-10-02 19:44:23 +00:00
|
|
|
|
2001-10-01 18:26:53 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const DerivedType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2001-10-01 18:26:53 +00:00
|
|
|
return T->isDerivedType();
|
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// FunctionType - Class to represent function types
|
|
|
|
///
|
2004-02-09 04:12:57 +00:00
|
|
|
class FunctionType : public DerivedType {
|
2003-09-05 02:30:18 +00:00
|
|
|
friend class TypeMap<FunctionValType, FunctionType>;
|
2001-07-25 22:47:55 +00:00
|
|
|
bool isVarArgs;
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-03-29 03:15:32 +00:00
|
|
|
FunctionType(const FunctionType &); // Do not implement
|
|
|
|
const FunctionType &operator=(const FunctionType &); // Do not implement
|
2001-06-06 20:29:01 +00:00
|
|
|
protected:
|
2004-02-10 21:49:59 +00:00
|
|
|
/// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
/// from GCC to make them protected: warning: `class FunctionType' only
|
2004-02-10 21:49:59 +00:00
|
|
|
/// defines private constructors and has no friends
|
|
|
|
///
|
|
|
|
/// Private ctor - Only can be created by a static member...
|
|
|
|
///
|
2005-04-21 20:19:05 +00:00
|
|
|
FunctionType(const Type *Result, const std::vector<const Type*> &Params,
|
2002-03-29 03:15:32 +00:00
|
|
|
bool IsVarArgs);
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2003-10-03 18:46:24 +00:00
|
|
|
/// FunctionType::get - This static method is the primary way of constructing
|
|
|
|
/// a FunctionType
|
2004-02-10 21:49:59 +00:00
|
|
|
///
|
2003-10-03 18:46:24 +00:00
|
|
|
static FunctionType *get(const Type *Result,
|
|
|
|
const std::vector<const Type*> &Params,
|
|
|
|
bool isVarArg);
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2001-07-25 22:47:55 +00:00
|
|
|
inline bool isVarArg() const { return isVarArgs; }
|
2004-02-09 05:40:24 +00:00
|
|
|
inline const Type *getReturnType() const { return ContainedTys[0]; }
|
2004-02-09 04:12:57 +00:00
|
|
|
|
2004-02-09 04:36:50 +00:00
|
|
|
typedef std::vector<PATypeHandle>::const_iterator param_iterator;
|
2004-02-09 05:40:24 +00:00
|
|
|
param_iterator param_begin() const { return ContainedTys.begin()+1; }
|
|
|
|
param_iterator param_end() const { return ContainedTys.end(); }
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2002-03-29 19:04:19 +00:00
|
|
|
// Parameter type accessors...
|
2004-02-09 05:40:24 +00:00
|
|
|
const Type *getParamType(unsigned i) const { return ContainedTys[i+1]; }
|
2002-03-29 19:04:19 +00:00
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// getNumParams - Return the number of fixed parameters this function type
|
|
|
|
/// requires. This does not consider varargs.
|
|
|
|
///
|
2005-05-15 16:13:11 +00:00
|
|
|
unsigned getNumParams() const { return unsigned(ContainedTys.size()-1); }
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement the AbstractTypeUser interface.
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
2003-10-03 18:46:24 +00:00
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
2005-04-21 20:19:05 +00:00
|
|
|
|
2001-10-01 16:18:37 +00:00
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2002-03-29 03:15:32 +00:00
|
|
|
static inline bool classof(const FunctionType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == FunctionTyID;
|
2001-10-01 16:18:37 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-08-20 06:00:58 +00:00
|
|
|
/// CompositeType - Common super class of ArrayType, StructType, PointerType
|
|
|
|
/// and PackedType
|
2001-11-26 16:46:45 +00:00
|
|
|
class CompositeType : public DerivedType {
|
|
|
|
protected:
|
2004-06-17 18:19:28 +00:00
|
|
|
inline CompositeType(TypeID id) : DerivedType(id) { }
|
2001-11-26 16:46:45 +00:00
|
|
|
public:
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// getTypeAtIndex - Given an index value into the type, return the type of
|
|
|
|
/// the element.
|
|
|
|
///
|
2001-11-26 16:46:45 +00:00
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const = 0;
|
|
|
|
virtual bool indexValid(const Value *V) const = 0;
|
|
|
|
|
|
|
|
// 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) {
|
2005-04-21 20:19:05 +00:00
|
|
|
return T->getTypeID() == ArrayTyID ||
|
2004-06-17 18:19:28 +00:00
|
|
|
T->getTypeID() == StructTyID ||
|
2004-08-20 06:00:58 +00:00
|
|
|
T->getTypeID() == PointerTyID ||
|
|
|
|
T->getTypeID() == PackedTyID;
|
2001-11-26 16:46:45 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// StructType - Class to represent struct types
|
|
|
|
///
|
2004-02-09 04:36:50 +00:00
|
|
|
class StructType : public CompositeType {
|
2003-09-05 02:30:18 +00:00
|
|
|
friend class TypeMap<StructValType, StructType>;
|
2001-12-14 16:20:21 +00:00
|
|
|
StructType(const StructType &); // Do not implement
|
|
|
|
const StructType &operator=(const StructType &); // Do not implement
|
2001-06-06 20:29:01 +00:00
|
|
|
|
|
|
|
protected:
|
2004-02-10 21:49:59 +00:00
|
|
|
/// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
/// from GCC to make them protected: warning: `class StructType' only
|
2004-02-10 21:49:59 +00:00
|
|
|
/// defines private constructors and has no friends
|
|
|
|
///
|
|
|
|
/// Private ctor - Only can be created by a static member...
|
|
|
|
///
|
2002-01-20 22:54:45 +00:00
|
|
|
StructType(const std::vector<const Type*> &Types);
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2003-10-03 18:46:24 +00:00
|
|
|
/// StructType::get - This static method is the primary way to create a
|
|
|
|
/// StructType.
|
2004-02-10 21:49:59 +00:00
|
|
|
///
|
2003-10-03 18:46:24 +00:00
|
|
|
static StructType *get(const std::vector<const Type*> &Params);
|
|
|
|
|
2004-02-09 04:36:50 +00:00
|
|
|
// Iterator access to the elements
|
|
|
|
typedef std::vector<PATypeHandle>::const_iterator element_iterator;
|
2004-02-09 05:40:24 +00:00
|
|
|
element_iterator element_begin() const { return ContainedTys.begin(); }
|
|
|
|
element_iterator element_end() const { return ContainedTys.end(); }
|
2004-02-09 04:36:50 +00:00
|
|
|
|
|
|
|
// Random access to the elements
|
2005-05-15 16:13:11 +00:00
|
|
|
unsigned getNumElements() const { return unsigned(ContainedTys.size()); }
|
2004-02-09 04:36:50 +00:00
|
|
|
const Type *getElementType(unsigned N) const {
|
2004-02-09 05:40:24 +00:00
|
|
|
assert(N < ContainedTys.size() && "Element number out of range!");
|
|
|
|
return ContainedTys[N];
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// getTypeAtIndex - Given an index value into the type, return the type of
|
|
|
|
/// the element. For a structure type, this must be a constant value...
|
|
|
|
///
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const ;
|
|
|
|
virtual bool indexValid(const Value *V) const;
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement the AbstractTypeUser interface.
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
2003-10-03 18:46:24 +00:00
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-14 16:20:21 +00:00
|
|
|
static inline bool classof(const StructType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == StructTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2001-07-23 05:03:15 +00:00
|
|
|
|
2005-04-21 20:19:05 +00:00
|
|
|
/// SequentialType - This is the superclass of the array, pointer and packed
|
2004-08-20 06:00:58 +00:00
|
|
|
/// type classes. All of these represent "arrays" in memory. The array type
|
2004-02-10 21:49:59 +00:00
|
|
|
/// represents a specifically sized array, pointer types are unsized/unknown
|
2005-04-21 20:19:05 +00:00
|
|
|
/// size arrays, packed types represent specifically sized arrays that
|
|
|
|
/// allow for use of SIMD instructions. SequentialType holds the common
|
|
|
|
/// features of all, which stem from the fact that all three lay their
|
2004-08-20 06:00:58 +00:00
|
|
|
/// components out in memory identically.
|
2004-02-10 21:49:59 +00:00
|
|
|
///
|
2001-12-14 16:20:21 +00:00
|
|
|
class SequentialType : public CompositeType {
|
|
|
|
SequentialType(const SequentialType &); // Do not implement!
|
|
|
|
const SequentialType &operator=(const SequentialType &); // Do not implement!
|
2001-06-06 20:29:01 +00:00
|
|
|
protected:
|
2004-06-17 18:19:28 +00:00
|
|
|
SequentialType(TypeID TID, const Type *ElType) : CompositeType(TID) {
|
2004-02-09 05:40:24 +00:00
|
|
|
ContainedTys.reserve(1);
|
|
|
|
ContainedTys.push_back(PATypeHandle(ElType, this));
|
2001-12-14 16:20:21 +00:00
|
|
|
}
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2004-02-09 05:40:24 +00:00
|
|
|
inline const Type *getElementType() const { return ContainedTys[0]; }
|
2001-09-07 16:19:29 +00:00
|
|
|
|
2004-07-04 10:48:27 +00:00
|
|
|
virtual bool indexValid(const Value *V) const;
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// getTypeAtIndex - Given an index value into the type, return the type of
|
|
|
|
/// the element. For sequential types, there is only one subtype...
|
|
|
|
///
|
2001-12-14 16:20:21 +00:00
|
|
|
virtual const Type *getTypeAtIndex(const Value *V) const {
|
2004-02-09 05:40:24 +00:00
|
|
|
return ContainedTys[0];
|
2001-12-14 16:20:21 +00:00
|
|
|
}
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
// 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) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == ArrayTyID ||
|
2004-08-20 06:00:58 +00:00
|
|
|
T->getTypeID() == PointerTyID ||
|
|
|
|
T->getTypeID() == PackedTyID;
|
2001-12-14 16:20:21 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// ArrayType - Class to represent array types
|
|
|
|
///
|
2001-12-14 16:20:21 +00:00
|
|
|
class ArrayType : public SequentialType {
|
2003-09-05 02:30:18 +00:00
|
|
|
friend class TypeMap<ArrayValType, ArrayType>;
|
2005-01-08 20:19:27 +00:00
|
|
|
uint64_t NumElements;
|
2001-12-14 16:20:21 +00:00
|
|
|
|
|
|
|
ArrayType(const ArrayType &); // Do not implement
|
|
|
|
const ArrayType &operator=(const ArrayType &); // Do not implement
|
|
|
|
protected:
|
2004-02-10 21:49:59 +00:00
|
|
|
/// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
/// from GCC to make them protected: warning: `class ArrayType' only
|
2004-02-10 21:49:59 +00:00
|
|
|
/// defines private constructors and has no friends
|
|
|
|
///
|
|
|
|
/// Private ctor - Only can be created by a static member...
|
|
|
|
///
|
2005-01-08 20:19:27 +00:00
|
|
|
ArrayType(const Type *ElType, uint64_t NumEl);
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2001-12-14 16:20:21 +00:00
|
|
|
public:
|
2003-10-03 18:46:24 +00:00
|
|
|
/// ArrayType::get - This static method is the primary way to construct an
|
|
|
|
/// ArrayType
|
2004-02-10 21:49:59 +00:00
|
|
|
///
|
2005-01-08 20:19:27 +00:00
|
|
|
static ArrayType *get(const Type *ElementType, uint64_t NumElements);
|
2003-10-03 18:46:24 +00:00
|
|
|
|
2005-01-08 20:19:27 +00:00
|
|
|
inline uint64_t getNumElements() const { return NumElements; }
|
2001-11-26 16:46:45 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement the AbstractTypeUser interface.
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
2003-10-03 18:46:24 +00:00
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
2001-12-14 16:20:21 +00:00
|
|
|
static inline bool classof(const ArrayType *T) { return true; }
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const Type *T) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == ArrayTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-07-23 05:03:15 +00:00
|
|
|
};
|
2001-07-20 21:09:17 +00:00
|
|
|
|
2004-08-20 06:00:58 +00:00
|
|
|
/// PackedType - Class to represent packed types
|
|
|
|
///
|
|
|
|
class PackedType : public SequentialType {
|
|
|
|
friend class TypeMap<PackedValType, PackedType>;
|
|
|
|
unsigned NumElements;
|
|
|
|
|
|
|
|
PackedType(const PackedType &); // Do not implement
|
|
|
|
const PackedType &operator=(const PackedType &); // Do not implement
|
|
|
|
protected:
|
|
|
|
/// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
/// from GCC to make them protected: warning: `class PackedType' only
|
2004-08-20 06:00:58 +00:00
|
|
|
/// defines private constructors and has no friends
|
|
|
|
///
|
|
|
|
/// Private ctor - Only can be created by a static member...
|
|
|
|
///
|
|
|
|
PackedType(const Type *ElType, unsigned NumEl);
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// PackedType::get - This static method is the primary way to construct an
|
|
|
|
/// PackedType
|
|
|
|
///
|
|
|
|
static PackedType *get(const Type *ElementType, unsigned NumElements);
|
|
|
|
|
2004-10-19 05:49:46 +00:00
|
|
|
inline unsigned getNumElements() const { return NumElements; }
|
2004-08-20 06:00:58 +00:00
|
|
|
|
|
|
|
// Implement the AbstractTypeUser interface.
|
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
|
|
|
|
|
|
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
|
|
|
static inline bool classof(const PackedType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
|
|
|
return T->getTypeID() == PackedTyID;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2001-07-20 21:09:17 +00:00
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// PointerType - Class to represent pointers
|
|
|
|
///
|
2001-12-14 16:20:21 +00:00
|
|
|
class PointerType : public SequentialType {
|
2003-09-05 02:30:18 +00:00
|
|
|
friend class TypeMap<PointerValType, PointerType>;
|
2001-06-06 20:29:01 +00:00
|
|
|
PointerType(const PointerType &); // Do not implement
|
|
|
|
const PointerType &operator=(const PointerType &); // Do not implement
|
|
|
|
protected:
|
|
|
|
// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
// from GCC to make them protected: warning: `class PointerType' only
|
2001-06-06 20:29:01 +00:00
|
|
|
// defines private constructors and has no friends
|
|
|
|
|
|
|
|
// Private ctor - Only can be created by a static member...
|
|
|
|
PointerType(const Type *ElType);
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
public:
|
2003-10-03 18:46:24 +00:00
|
|
|
/// PointerType::get - This is the only way to construct a new pointer type.
|
2001-09-07 16:19:29 +00:00
|
|
|
static PointerType *get(const Type *ElementType);
|
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement the AbstractTypeUser interface.
|
2001-09-07 16:19:29 +00:00
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
2003-10-03 18:46:24 +00:00
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
2001-10-01 18:26:53 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement support type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const PointerType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == PointerTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-09-07 16:19:29 +00:00
|
|
|
};
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
|
2004-02-10 21:49:59 +00:00
|
|
|
/// OpaqueType - Class to represent abstract types
|
|
|
|
///
|
2001-09-07 16:19:29 +00:00
|
|
|
class OpaqueType : public DerivedType {
|
2003-09-01 16:38:43 +00:00
|
|
|
OpaqueType(const OpaqueType &); // DO NOT IMPLEMENT
|
|
|
|
const OpaqueType &operator=(const OpaqueType &); // DO NOT IMPLEMENT
|
2001-09-07 16:19:29 +00:00
|
|
|
protected:
|
2004-02-10 21:49:59 +00:00
|
|
|
/// This should really be private, but it squelches a bogus warning
|
2005-04-21 20:19:05 +00:00
|
|
|
/// from GCC to make them protected: warning: `class OpaqueType' only
|
2004-02-10 21:49:59 +00:00
|
|
|
/// defines private constructors and has no friends
|
|
|
|
///
|
|
|
|
/// Private ctor - Only can be created by a static member...
|
2001-09-07 16:19:29 +00:00
|
|
|
OpaqueType();
|
2003-09-05 02:15:36 +00:00
|
|
|
|
2001-09-07 16:19:29 +00:00
|
|
|
public:
|
2004-02-10 21:49:59 +00:00
|
|
|
/// OpaqueType::get - Static factory method for the OpaqueType class...
|
|
|
|
///
|
2001-09-07 16:19:29 +00:00
|
|
|
static OpaqueType *get() {
|
|
|
|
return new OpaqueType(); // All opaque types are distinct
|
2001-07-20 19:09:11 +00:00
|
|
|
}
|
2001-10-01 18:26:53 +00:00
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement the AbstractTypeUser interface.
|
2003-10-02 19:44:23 +00:00
|
|
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
|
2003-10-03 18:46:24 +00:00
|
|
|
abort(); // FIXME: this is not really an AbstractTypeUser!
|
|
|
|
}
|
|
|
|
virtual void typeBecameConcrete(const DerivedType *AbsTy) {
|
|
|
|
abort(); // FIXME: this is not really an AbstractTypeUser!
|
2003-10-02 19:44:23 +00:00
|
|
|
}
|
|
|
|
|
2003-10-03 18:46:24 +00:00
|
|
|
// Implement support for type inquiry through isa, cast, and dyn_cast:
|
2001-10-02 03:41:24 +00:00
|
|
|
static inline bool classof(const OpaqueType *T) { return true; }
|
|
|
|
static inline bool classof(const Type *T) {
|
2004-06-17 18:19:28 +00:00
|
|
|
return T->getTypeID() == OpaqueTyID;
|
2001-10-01 18:26:53 +00:00
|
|
|
}
|
2001-06-06 20:29:01 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-06-06 20:29:01 +00:00
|
|
|
#endif
|