aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2004-08-20 06:00:58 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2004-08-20 06:00:58 +0000
commit715c90ba524e736190a6380695ab337eeb5148be (patch)
tree0ab6881edc06308fc09116d695a55ccbd096cb5f /include/llvm
parent4e5b9e136f2eafcb2ab4c5b968307c2678e16a96 (diff)
downloadexternal_llvm-715c90ba524e736190a6380695ab337eeb5148be.zip
external_llvm-715c90ba524e736190a6380695ab337eeb5148be.tar.gz
external_llvm-715c90ba524e736190a6380695ab337eeb5148be.tar.bz2
Packed types, brought to you by Brad Jones
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15938 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Bytecode/BytecodeHandler.h9
-rw-r--r--include/llvm/Constants.h39
-rw-r--r--include/llvm/DerivedTypes.h57
-rw-r--r--include/llvm/Type.def1
-rw-r--r--include/llvm/Type.h8
5 files changed, 103 insertions, 11 deletions
diff --git a/include/llvm/Bytecode/BytecodeHandler.h b/include/llvm/Bytecode/BytecodeHandler.h
index 687bf80..5a022a0 100644
--- a/include/llvm/Bytecode/BytecodeHandler.h
+++ b/include/llvm/Bytecode/BytecodeHandler.h
@@ -23,6 +23,7 @@ namespace llvm {
class ArrayType;
class StructType;
class PointerType;
+class PackedType;
class ConstantArray;
class Module;
@@ -250,6 +251,14 @@ public:
Constant* Val ///< The constant value
) {}
+ /// @brief Handle a constant packed
+ virtual void handleConstantPacked(
+ const PackedType* PT, ///< Type of the array
+ std::vector<Constant*>& ElementSlots,///< Slot nums for packed values
+ unsigned TypeSlot, ///< Slot # of type
+ Constant* Val ///< The constant value
+ ) {}
+
/// @brief Handle a constant pointer
virtual void handleConstantPointer(
const PointerType* PT, ///< Type of the pointer
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 74541c9..5ef2cb0 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -24,6 +24,7 @@ namespace llvm {
class ArrayType;
class StructType;
class PointerType;
+class PackedType;
template<class ConstantClass, class TypeClass, class ValType>
struct ConstantCreator;
@@ -426,6 +427,44 @@ public:
};
//===---------------------------------------------------------------------------
+/// ConstantPacked - Constant Packed Declarations
+///
+class ConstantPacked : public Constant {
+ friend struct ConstantCreator<ConstantPacked, PackedType,
+ std::vector<Constant*> >;
+ ConstantPacked(const ConstantPacked &); // DO NOT IMPLEMENT
+protected:
+ ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val);
+public:
+ /// get() - Static factory methods - Return objects of the specified value
+ static Constant *get(const PackedType *T, const std::vector<Constant*> &);
+ static Constant *get(const std::vector<Constant*> &V);
+
+ /// getType - Specialize the getType() method to always return an PackedType,
+ /// which reduces the amount of casting needed in parts of the compiler.
+ ///
+ inline const PackedType *getType() const {
+ return reinterpret_cast<const PackedType*>(Value::getType());
+ }
+
+ /// isNullValue - Return true if this is the value that would be returned by
+ /// getNullValue. This always returns false because zero arrays are always
+ /// created as ConstantAggregateZero objects.
+ virtual bool isNullValue() const { return false; }
+
+ virtual void destroyConstant();
+ virtual void replaceUsesOfWithOnConstant(Value *From, Value *To,
+ bool DisableChecking = false);
+
+ /// Methods for support type inquiry through isa, cast, and dyn_cast:
+ static inline bool classof(const ConstantPacked *) { return true; }
+ static bool classof(const Value *V) {
+ return V->getValueType() == SimpleConstantVal &&
+ V->getType()->getTypeID() == Type::PackedTyID;
+ }
+};
+
+//===---------------------------------------------------------------------------
/// ConstantPointerNull - a constant pointer value that points to null
///
class ConstantPointerNull : public Constant {
diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h
index 8720ca6..10f74dc 100644
--- a/include/llvm/DerivedTypes.h
+++ b/include/llvm/DerivedTypes.h
@@ -28,6 +28,7 @@ class FunctionValType;
class ArrayValType;
class StructValType;
class PointerValType;
+class PackedValType;
class DerivedType : public Type, public AbstractTypeUser {
// AbstractTypeUsers - Implement a list of the users that need to be notified
@@ -152,8 +153,8 @@ public:
};
-/// CompositeType - Common super class of ArrayType, StructType, and PointerType
-///
+/// CompositeType - Common super class of ArrayType, StructType, PointerType
+/// and PackedType
class CompositeType : public DerivedType {
protected:
inline CompositeType(TypeID id) : DerivedType(id) { }
@@ -170,7 +171,8 @@ public:
static inline bool classof(const Type *T) {
return T->getTypeID() == ArrayTyID ||
T->getTypeID() == StructTyID ||
- T->getTypeID() == PointerTyID;
+ T->getTypeID() == PointerTyID ||
+ T->getTypeID() == PackedTyID;
}
};
@@ -227,11 +229,13 @@ public:
};
-/// SequentialType - This is the superclass of the array and pointer type
-/// classes. Both of these represent "arrays" in memory. The array type
+/// SequentialType - This is the superclass of the array, pointer and packed
+/// type classes. All of these represent "arrays" in memory. The array type
/// represents a specifically sized array, pointer types are unsized/unknown
-/// size arrays. SequentialType holds the common features of both, which stem
-/// from the fact that both lay their components out in memory identically.
+/// 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
+/// components out in memory identically.
///
class SequentialType : public CompositeType {
SequentialType(const SequentialType &); // Do not implement!
@@ -258,7 +262,8 @@ public:
static inline bool classof(const SequentialType *T) { return true; }
static inline bool classof(const Type *T) {
return T->getTypeID() == ArrayTyID ||
- T->getTypeID() == PointerTyID;
+ T->getTypeID() == PointerTyID ||
+ T->getTypeID() == PackedTyID;
}
};
@@ -299,6 +304,42 @@ public:
}
};
+/// 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
+ /// from GCC to make them protected: warning: `class PackedType' only
+ /// 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);
+
+ inline unsigned getNumElements() const { return NumElements; }
+
+ // 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;
+ }
+};
+
/// PointerType - Class to represent pointers
///
diff --git a/include/llvm/Type.def b/include/llvm/Type.def
index 8e59c7a..25ad5cd 100644
--- a/include/llvm/Type.def
+++ b/include/llvm/Type.def
@@ -58,6 +58,7 @@ HANDLE_DERV_TYPE(Array , ArrayType)
HANDLE_DERV_TYPE(Pointer , PointerType)
HANDLE_DERV_TYPE(Struct , StructType)
HANDLE_DERV_TYPE(Opaque , OpaqueType)
+HANDLE_DERV_TYPE(Packed , PackedType)
// Kill the macros on exit...
#undef HANDLE_PRIM_TYPE
diff --git a/include/llvm/Type.h b/include/llvm/Type.h
index 273cd43..fcaa9f5 100644
--- a/include/llvm/Type.h
+++ b/include/llvm/Type.h
@@ -48,6 +48,7 @@ class FunctionType;
class OpaqueType;
class PointerType;
class StructType;
+class PackedType;
struct Type {
///===-------------------------------------------------------------------===//
@@ -71,7 +72,7 @@ struct Type {
FunctionTyID , StructTyID, // Functions... Structs...
ArrayTyID , PointerTyID, // Array... pointer...
OpaqueTyID, // Opaque type instances...
- //PackedTyID , // SIMD 'packed' format... TODO
+ PackedTyID, // SIMD 'packed' format...
//...
NumTypeIDs, // Must remain as last defined ID
@@ -189,7 +190,8 @@ public:
/// isFirstClassType - Return true if the value is holdable in a register.
inline bool isFirstClassType() const {
- return (ID != VoidTyID && ID <= LastPrimitiveTyID) || ID == PointerTyID;
+ return (ID != VoidTyID && ID <= LastPrimitiveTyID) ||
+ ID == PointerTyID || ID == PackedTyID;
}
/// isSized - Return true if it makes sense to take the size of this type. To
@@ -197,7 +199,7 @@ public:
/// TargetData subsystem to do this.
///
bool isSized() const {
- return (ID >= BoolTyID && ID <= DoubleTyID) || ID == PointerTyID ||
+ return (ID >= BoolTyID && ID <= DoubleTyID) || ID == PointerTyID ||
isSizedDerivedType();
}