[llvm-commits] CVS: llvm/include/llvm/Constants.h DerivedTypes.h Type.def Type.h

Brian Gaeke gaeke at cs.uiuc.edu
Thu Aug 19 23:01:08 PDT 2004



Changes in directory llvm/include/llvm:

Constants.h updated: 1.55 -> 1.56
DerivedTypes.h updated: 1.60 -> 1.61
Type.def updated: 1.7 -> 1.8
Type.h updated: 1.56 -> 1.57
---
Log message:

Packed types, brought to you by Brad Jones


---
Diffs of the changes:  (+94 -11)

Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.55 llvm/include/llvm/Constants.h:1.56
--- llvm/include/llvm/Constants.h:1.55	Wed Aug  4 13:49:52 2004
+++ llvm/include/llvm/Constants.h	Fri Aug 20 01:00:57 2004
@@ -24,6 +24,7 @@
 class ArrayType;
 class StructType;
 class PointerType;
+class PackedType;
 
 template<class ConstantClass, class TypeClass, class ValType>
 struct ConstantCreator;
@@ -426,6 +427,44 @@
 };
 
 //===---------------------------------------------------------------------------
+/// 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 {


Index: llvm/include/llvm/DerivedTypes.h
diff -u llvm/include/llvm/DerivedTypes.h:1.60 llvm/include/llvm/DerivedTypes.h:1.61
--- llvm/include/llvm/DerivedTypes.h:1.60	Thu Jul  8 10:54:29 2004
+++ llvm/include/llvm/DerivedTypes.h	Fri Aug 20 01:00:57 2004
@@ -28,6 +28,7 @@
 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 @@
 };
 
 
-/// 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 @@
   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 @@
 };
 
 
-/// 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 @@
   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 @@
   }
 };
 
+/// 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
 ///


Index: llvm/include/llvm/Type.def
diff -u llvm/include/llvm/Type.def:1.7 llvm/include/llvm/Type.def:1.8
--- llvm/include/llvm/Type.def:1.7	Sun Jul  4 05:50:43 2004
+++ llvm/include/llvm/Type.def	Fri Aug 20 01:00:57 2004
@@ -58,6 +58,7 @@
 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


Index: llvm/include/llvm/Type.h
diff -u llvm/include/llvm/Type.h:1.56 llvm/include/llvm/Type.h:1.57
--- llvm/include/llvm/Type.h:1.56	Wed Jul 14 21:54:36 2004
+++ llvm/include/llvm/Type.h	Fri Aug 20 01:00:57 2004
@@ -48,6 +48,7 @@
 class OpaqueType;
 class PointerType;
 class StructType;
+class PackedType;
 
 struct Type {
   ///===-------------------------------------------------------------------===//
@@ -71,7 +72,7 @@
     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 @@
 
   /// 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 @@
   /// TargetData subsystem to do this.
   ///
   bool isSized() const {
-    return (ID >= BoolTyID && ID <= DoubleTyID) || ID == PointerTyID ||
+    return (ID >= BoolTyID && ID <= DoubleTyID) || ID == PointerTyID || 
            isSizedDerivedType();
   }
 






More information about the llvm-commits mailing list