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

Robert Bocchino bocchino at cs.uiuc.edu
Tue Oct 18 12:22:20 PDT 2005



Changes in directory llvm/include/llvm:

Constants.h updated: 1.75 -> 1.75.2.1
DerivedTypes.h updated: 1.68 -> 1.68.4.1
Instruction.def updated: 1.16 -> 1.16.2.1
Instructions.h updated: 1.27 -> 1.27.2.1
Type.h updated: 1.77 -> 1.77.4.1
---
Log message:

Initial commit of Vector LLVM.


---
Diffs of the changes:  (+673 -74)

 Constants.h     |   38 ++--
 DerivedTypes.h  |  132 ++++++++++++---
 Instruction.def |   65 ++++---
 Instructions.h  |  492 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 Type.h          |   20 +-
 5 files changed, 673 insertions(+), 74 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.75 llvm/include/llvm/Constants.h:1.75.2.1
--- llvm/include/llvm/Constants.h:1.75	Tue Oct  4 13:12:13 2005
+++ llvm/include/llvm/Constants.h	Tue Oct 18 14:21:56 2005
@@ -29,7 +29,7 @@
 class ArrayType;
 class StructType;
 class PointerType;
-class PackedType;
+class FixedVectorType;
 
 template<class ConstantClass, class TypeClass, class ValType>
 struct ConstantCreator;
@@ -163,6 +163,7 @@
   /// ConstantInt::get static method: return a ConstantInt with the specified
   /// value.  as above, we work only with very small values here.
   ///
+
   static ConstantInt *get(const Type *Ty, unsigned char V);
 
   /// isNullValue - Return true if this is the value that would be returned by
@@ -192,6 +193,7 @@
 public:
   /// get() - Static factory methods - Return objects of the specified value
   ///
+
   static ConstantSInt *get(const Type *Ty, int64_t V);
 
   /// isValueValidForType - return true if Ty is big enough to represent V.
@@ -243,6 +245,7 @@
 public:
   /// get() - Static factory methods - Return objects of the specified value
   ///
+
   static ConstantUInt *get(const Type *Ty, uint64_t V);
 
   /// isValueValidForType - return true if Ty is big enough to represent V.
@@ -280,6 +283,7 @@
   ConstantFP(const Type *Ty, double V);
 public:
   /// get() - Static factory methods - Return objects of the specified value
+
   static ConstantFP *get(const Type *Ty, double V);
 
   /// isValueValidForType - return true if Ty is big enough to represent V.
@@ -420,25 +424,26 @@
 };
 
 //===----------------------------------------------------------------------===//
-/// ConstantPacked - Constant Packed Declarations
+/// ConstantVector - Constant FixedVector Declarations
 ///
-class ConstantPacked : public Constant {
-  friend struct ConstantCreator<ConstantPacked, PackedType,
+class ConstantVector : public Constant {
+  friend struct ConstantCreator<ConstantVector, FixedVectorType,
                                     std::vector<Constant*> >;
-  ConstantPacked(const ConstantPacked &);      // DO NOT IMPLEMENT
+  ConstantVector(const ConstantVector &);      // DO NOT IMPLEMENT
 protected:
-  ConstantPacked(const PackedType *T, const std::vector<Constant*> &Val);
-  ~ConstantPacked();
+  ConstantVector(const FixedVectorType *T, const std::vector<Constant*> &Val);
+  ~ConstantVector();
 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 FixedVectorType *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.
+  
+  /// getType - Specialize the getType() method to always return a
+  /// FixedVectorType, which reduces the amount of casting needed in
+  /// parts of the compiler.
   ///
-  inline const PackedType *getType() const {
-    return reinterpret_cast<const PackedType*>(Value::getType());
+  inline const FixedVectorType *getType() const {
+    return reinterpret_cast<const FixedVectorType*>(Value::getType());
   }
 
   /// isNullValue - Return true if this is the value that would be returned by
@@ -450,9 +455,14 @@
   virtual void replaceUsesOfWithOnConstant(Value *From, Value *To, Use *U);
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
-  static inline bool classof(const ConstantPacked *) { return true; }
+  static inline bool classof(const ConstantVector *) { return true; }
   static bool classof(const Value *V) {
+    //<<<<<<< Constants.h
+    //return V->getValueType() == SimpleConstantVal &&
+    //       V->getType()->getTypeID() == Type::FixedVectorTyID;
+    //=======
     return V->getValueType() == ConstantPackedVal;
+    //>>>>>>> 1.75
   }
 };
 


Index: llvm/include/llvm/DerivedTypes.h
diff -u llvm/include/llvm/DerivedTypes.h:1.68 llvm/include/llvm/DerivedTypes.h:1.68.4.1
--- llvm/include/llvm/DerivedTypes.h:1.68	Sun May 15 11:13:11 2005
+++ llvm/include/llvm/DerivedTypes.h	Tue Oct 18 14:21:56 2005
@@ -29,7 +29,9 @@
 class ArrayValType;
 class StructValType;
 class PointerValType;
-class PackedValType;
+class StreamValType;
+class VectorValType;
+class FixedVectorValType;
 
 class DerivedType : public Type, public AbstractTypeUser {
   // AbstractTypeUsers - Implement a list of the users that need to be notified
@@ -156,7 +158,7 @@
 
 
 /// CompositeType - Common super class of ArrayType, StructType, PointerType
-/// and PackedType
+/// and FixedVectorType
 class CompositeType : public DerivedType {
 protected:
   inline CompositeType(TypeID id) : DerivedType(id) { }
@@ -174,7 +176,9 @@
     return T->getTypeID() == ArrayTyID ||
            T->getTypeID() == StructTyID ||
            T->getTypeID() == PointerTyID ||
-           T->getTypeID() == PackedTyID;
+           T->getTypeID() == StreamTyID ||
+           T->getTypeID() == VectorTyID ||
+           T->getTypeID() == FixedVectorTyID;
   }
 };
 
@@ -231,13 +235,12 @@
 };
 
 
-/// 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, 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.
+/// SequentialType - This is the superclass of the array, pointer, and
+/// vector type classes.  The array type represents a specifically
+/// sized array, pointer types are unsized/unknown size arrays, and
+/// vector types are first-class types that allow for use of SIMD
+/// instructions.  SequentialType holds the common features of all,
+/// which stem from the fact that each is a sequence of elements.
 ///
 class SequentialType : public CompositeType {
   SequentialType(const SequentialType &);                  // Do not implement!
@@ -264,8 +267,10 @@
   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() == PackedTyID;
+      T->getTypeID() == PointerTyID ||
+      T->getTypeID() == StreamTyID ||
+      T->getTypeID() == VectorTyID ||
+      T->getTypeID() == FixedVectorTyID;
   }
 };
 
@@ -306,28 +311,105 @@
   }
 };
 
-/// PackedType - Class to represent packed types
+/// StreamType - Class to represent vector types
 ///
-class PackedType : public SequentialType {
-  friend class TypeMap<PackedValType, PackedType>;
-  unsigned NumElements;
+class StreamType : public SequentialType {
+  friend class TypeMap<StreamValType, StreamType>;
+
+  StreamType(const StreamType &);                   // Do not implement
+  const StreamType &operator=(const StreamType &);  // Do not implement
+
+protected:
+  /// This should really be private, but it squelches a bogus warning
+  /// from GCC to make them protected:  warning: `class StreamType' only 
+  /// defines private constructors and has no friends
+  ///
+  /// Private ctor - Only can be created by a static member...
+  ///
+  StreamType(const Type *ElType);
+
+public:
+  /// StreamType::get - This static method is the primary way to construct a
+  /// StreamType
+  ///
+  static StreamType *get(const Type *ElementType);
+
+  // 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 StreamType *T) { return true; }
+  static inline bool classof(const Type *T) {
+    return T->getTypeID() == StreamTyID;
+  }
+};
+
+/// VectorType - Class to represent vector types
+///
+class VectorType : public SequentialType {
+  friend class TypeMap<VectorValType, VectorType>;
+
+  VectorType(const VectorType &);                   // Do not implement
+  const VectorType &operator=(const VectorType &);  // Do not implement
 
-  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
+  /// from GCC to make them protected:  warning: `class VectorType' only 
   /// defines private constructors and has no friends
   ///
   /// Private ctor - Only can be created by a static member...
   ///
-  PackedType(const Type *ElType, unsigned NumEl);
+  VectorType(const Type *ElType, bool fixed = false);
+
+public:
+  /// VectorType::get - This static method is the primary way to construct a
+  /// VectorType
+  ///
+  static VectorType *get(const Type *ElementType);
+
+  /// Functions for vector support
+  ///
+  bool isIntegerVector() const { return getElementType()->isInteger(); }
+  bool isIntegralVector() const { return getElementType()->isIntegral(); }
+  bool isFPVector() const { return getElementType()->isFloatingPoint(); }
+  bool isBooleanVector() const { return getElementType() == Type::BoolTy; }
+
+  // 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 VectorType *T) { return true; }
+  static inline bool classof(const Type *T) {
+    return T->getTypeID() == VectorTyID ||
+      T->getTypeID() == FixedVectorTyID;
+  }
+};
+
+/// FixedVectorType - Class to represent vectors with fixed lengths
+///
+class FixedVectorType : public VectorType {
+  friend class TypeMap<FixedVectorValType, FixedVectorType>;
+  unsigned NumElements;
+
+  FixedVectorType(const FixedVectorType &);                   // Do not implement
+  const FixedVectorType &operator=(const FixedVectorType &);  // Do not implement
+protected:
+  /// This should really be private, but it squelches a bogus warning
+  /// from GCC to make them protected: warning: `class
+  /// FixedVectorType' only defines private constructors and has no
+  /// friends
+  ///
+  /// Private ctor - Only can be created by a static member...
+  ///
+  FixedVectorType(const Type *ElType, unsigned NumEl);
 
 public:
-  /// PackedType::get - This static method is the primary way to construct an
-  /// PackedType
+  /// FixedVectorType::get - This static method is the primary way to construct an
+  /// FixedVectorType
   ///
-  static PackedType *get(const Type *ElementType, unsigned NumElements);
+  static FixedVectorType *get(const Type *ElementType, unsigned NumElements);
 
   inline unsigned getNumElements() const { return NumElements; }
 
@@ -336,9 +418,9 @@
   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 FixedVectorType *T) { return true; }
   static inline bool classof(const Type *T) {
-    return T->getTypeID() == PackedTyID;
+    return T->getTypeID() == FixedVectorTyID;
   }
 };
 


Index: llvm/include/llvm/Instruction.def
diff -u llvm/include/llvm/Instruction.def:1.16 llvm/include/llvm/Instruction.def:1.16.2.1
--- llvm/include/llvm/Instruction.def:1.16	Fri Jun 24 13:17:33 2005
+++ llvm/include/llvm/Instruction.def	Tue Oct 18 14:21:56 2005
@@ -102,40 +102,55 @@
 HANDLE_BINARY_INST(14, Xor   , BinaryOperator)
 
 // Binary comparison operators...
-HANDLE_BINARY_INST(15, SetEQ , SetCondInst)
+HANDLE_BINARY_INST(15, SetEQ , SetCondInst)  // Scalar operators
 HANDLE_BINARY_INST(16, SetNE , SetCondInst)
 HANDLE_BINARY_INST(17, SetLE , SetCondInst)
 HANDLE_BINARY_INST(18, SetGE , SetCondInst)
 HANDLE_BINARY_INST(19, SetLT , SetCondInst)
 HANDLE_BINARY_INST(20, SetGT , SetCondInst)
-  LAST_BINARY_INST(20)
+HANDLE_BINARY_INST(21, VSetEQ , SetCondInst) // Vector operators
+HANDLE_BINARY_INST(22, VSetNE , SetCondInst)
+HANDLE_BINARY_INST(23, VSetLE , SetCondInst)
+HANDLE_BINARY_INST(24, VSetGE , SetCondInst)
+HANDLE_BINARY_INST(25, VSetLT , SetCondInst)
+HANDLE_BINARY_INST(26, VSetGT , SetCondInst)
+  LAST_BINARY_INST(26)
 
 // Memory operators...
- FIRST_MEMORY_INST(21)
-HANDLE_MEMORY_INST(21, Malloc, MallocInst)  // Heap management instructions
-HANDLE_MEMORY_INST(22, Free  , FreeInst  )
-HANDLE_MEMORY_INST(23, Alloca, AllocaInst)  // Stack management
-HANDLE_MEMORY_INST(24, Load  , LoadInst  )  // Memory manipulation instrs
-HANDLE_MEMORY_INST(25, Store , StoreInst )
-HANDLE_MEMORY_INST(26, GetElementPtr, GetElementPtrInst)
-  LAST_MEMORY_INST(26)
+ FIRST_MEMORY_INST(27)
+HANDLE_MEMORY_INST(28, Malloc, MallocInst)   // Heap management instructions
+HANDLE_MEMORY_INST(29, Free  , FreeInst  )
+HANDLE_MEMORY_INST(30, Alloca, AllocaInst)   // Stack management
+HANDLE_MEMORY_INST(31, Load  , LoadInst  )   // Memory manipulation instrs
+HANDLE_MEMORY_INST(32, Store , StoreInst )
+HANDLE_MEMORY_INST(33, VGather, VGatherInst) // vector gather
+HANDLE_MEMORY_INST(34, VImm, VImmInst)       // vector immediate
+HANDLE_MEMORY_INST(35, VScatter, VScatterInst) // vector scatter
+HANDLE_MEMORY_INST(36, GetElementPtr, GetElementPtrInst)
+  LAST_MEMORY_INST(36)
 
 // Other operators...
- FIRST_OTHER_INST(27)
-HANDLE_OTHER_INST(27, PHI    , PHINode    )  // PHI node instruction
-HANDLE_OTHER_INST(28, Cast   , CastInst   )  // Type cast
-HANDLE_OTHER_INST(29, Call   , CallInst   )  // Call a function
-
-HANDLE_OTHER_INST(30, Shl    , ShiftInst  )  // Shift operations
-HANDLE_OTHER_INST(31, Shr    , ShiftInst  )
-// 32 -> Empty slot used to be used for vanext in llvm 1.5 and before.
-// 33 -> Empty slot used to be used for vaarg in llvm 1.5 and before.
-HANDLE_OTHER_INST(34, Select , SelectInst )  // select instruction
-
-HANDLE_OTHER_INST(35, UserOp1, Instruction)  // May be used internally in a pass
-HANDLE_OTHER_INST(36, UserOp2, Instruction)
-HANDLE_OTHER_INST(37, VAArg  , VAArgInst  )  // vaarg instruction
-  LAST_OTHER_INST(37)
+ FIRST_OTHER_INST(37)
+HANDLE_OTHER_INST(37, PHI    , PHINode    )  // PHI node instruction
+HANDLE_OTHER_INST(38, Cast   , CastInst   )  // Type cast
+HANDLE_OTHER_INST(39, Call   , CallInst   )  // Call a function
+
+HANDLE_OTHER_INST(40, Shl    , ShiftInst  )  // Shift operations
+HANDLE_OTHER_INST(41, Shr    , ShiftInst  )
+   // 42 is reserved for old VANext
+   // 43 is reserved for old VAArg
+HANDLE_OTHER_INST(44, Select , SelectInst )  // select instruction
+HANDLE_OTHER_INST(45, VSelect, VSelectInst ) // vector select instruction
+
+HANDLE_OTHER_INST(46, Extract, ExtractInst)  // vector extract
+HANDLE_OTHER_INST(47, ExtractElement, ExtractElementInst)  // vector extract element
+HANDLE_OTHER_INST(48, Combine, CombineInst)  // vector combine
+HANDLE_OTHER_INST(49, CombineElement, CombineElementInst)   // vector combine element
+
+HANDLE_OTHER_INST(50, UserOp1, Instruction)  // May be used internally in a pass
+HANDLE_OTHER_INST(51, UserOp2, Instruction)
+HANDLE_OTHER_INST(52, VAArg  , VAArgInst  )  // vaarg  instruction
+  LAST_OTHER_INST(52)
 
 #undef  FIRST_TERM_INST
 #undef HANDLE_TERM_INST


Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.27 llvm/include/llvm/Instructions.h:1.27.2.1
--- llvm/include/llvm/Instructions.h:1.27	Thu Aug  4 19:49:06 2005
+++ llvm/include/llvm/Instructions.h	Tue Oct 18 14:21:56 2005
@@ -24,6 +24,8 @@
 class BasicBlock;
 class ConstantInt;
 class PointerType;
+class VectorType;
+
 
 //===----------------------------------------------------------------------===//
 //                             AllocationInst Class
@@ -380,8 +382,8 @@
 //                            SetCondInst Class
 //===----------------------------------------------------------------------===//
 
-/// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt,
-/// le, or ge.
+/// SetCondInst class - Represent a SetCC or VSetCC operator, where CC
+/// is eq, ne, lt, gt, le, or ge.
 ///
 class SetCondInst : public BinaryOperator {
 public:
@@ -415,13 +417,35 @@
   ///
   static BinaryOps getSwappedCondition(BinaryOps Opcode);
 
+  // getScalarOpcode - Return the scalar version of this opcode.
+  // For example seteq -> seteq, vseteq -> seteq, etc.
+  //
+  BinaryOps getScalarOpcode() const {
+    return getScalarOpcode(getOpcode());
+  }
+
+  /// getScalarOpcode - Static version that you can use without an
+  /// instruction available.
+  ///
+  static BinaryOps getScalarOpcode(BinaryOps Opcode);
+
+  // getVectorOpcode - Return the scalar version of this opcode.
+  // For example seteq -> seteq, vseteq -> seteq, etc.
+  //
+  BinaryOps getVectorOpcode() const {
+    return getVectorOpcode(getOpcode());
+  }
+
+  /// getVectorOpcode - Static version that you can use without an
+  /// instruction available.
+  ///
+  static BinaryOps getVectorOpcode(BinaryOps Opcode);
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const SetCondInst *) { return true; }
   static inline bool classof(const Instruction *I) {
-    return I->getOpcode() == SetEQ || I->getOpcode() == SetNE ||
-           I->getOpcode() == SetLE || I->getOpcode() == SetGE ||
-           I->getOpcode() == SetLT || I->getOpcode() == SetGT;
+    return I->getOpcode() >= SetEQ &&
+      I->getOpcode() <= VSetGT;
   }
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(V));
@@ -661,6 +685,72 @@
 };
 
 //===----------------------------------------------------------------------===//
+//                               VSelectInst Class
+//===----------------------------------------------------------------------===//
+
+/// VSelectInst - This class represents the vector version of the LLVM
+/// 'select' instruction.
+///
+class VSelectInst : public Instruction {
+  Use Ops[3];
+
+  void init(Value *C, Value *S1, Value *S2) {
+    Ops[0].init(C, this);
+    Ops[1].init(S1, this);
+    Ops[2].init(S2, this);
+  }
+
+  VSelectInst(const VSelectInst &SI)
+    : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
+    init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
+  }
+public:
+  VSelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
+             Instruction *InsertBefore = 0)
+    : Instruction(S1->getType(), Instruction::VSelect, Ops, 3,
+                  Name, InsertBefore) {
+    init(C, S1, S2);
+  }
+  VSelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
+             BasicBlock *InsertAtEnd)
+    : Instruction(S1->getType(), Instruction::VSelect, Ops, 3,
+                  Name, InsertAtEnd) {
+    init(C, S1, S2);
+  }
+
+  Value *getCondition() const { return Ops[0]; }
+  Value *getTrueValue() const { return Ops[1]; }
+  Value *getFalseValue() const { return Ops[2]; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 3 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 3 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 3; }
+
+  OtherOps getOpcode() const {
+    return static_cast<OtherOps>(Instruction::getOpcode());
+  }
+
+  virtual VSelectInst *clone() const;
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VSelectInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::VSelect;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+
+//===----------------------------------------------------------------------===//
 //                                VAArgInst Class
 //===----------------------------------------------------------------------===//
 
@@ -1289,6 +1379,398 @@
   virtual void setSuccessorV(unsigned idx, BasicBlock *B);
 };
 
+//===----------------------------------------------------------------------===//
+//                             VMemoryInst Class
+//===----------------------------------------------------------------------===//
+
+/// VMemoryInst - This class is the common base class of VGatherInst and
+/// VScatterInst.
+///
+class VMemoryInst : public Instruction {
+protected:
+  VMemoryInst(const Type *Ty, unsigned iType,
+	      Use *Ops, unsigned NumOps,
+	      const std::string &Name = "", Instruction *InsertBef = 0);
+  VMemoryInst(const Type* Ty, unsigned iType,
+	      Use *Ops, unsigned NumOps,
+	      const std::string &Name, BasicBlock *InsertAE);
+  ~VMemoryInst();
+
+public:
+
+  // Check for correct number of indices
+  //
+  static bool VMemoryInst::checkNumIndices(const std::vector<Value*> &Idx) {
+    return (Idx.size() >= 4 && Idx.size() % 4 == 0);
+  }
+
+  // Check for correct types of indices
+  //
+  static bool VMemoryInst::checkIndexType(const std::vector<Value*> &);
+
+  virtual Instruction *clone() const = 0;
+
+  const Type *getElementType() const;
+  virtual Value *getPointerOperand() = 0;
+  virtual const Value *getPointerOperand() const = 0;
+
+  virtual unsigned getNumIndices() const = 0;
+  virtual Value *getIndex(unsigned) = 0;
+  virtual const Value *getIndex(unsigned) const = 0;
+
+  Value *getLowerBound(unsigned level) { return getIndex(4*level); }
+  const Value *getLowerBound(unsigned level) const { return getIndex(4*level); }
+
+  Value *getUpperBound(unsigned level) { return getIndex(4*level+1); }
+  const Value *getUpperBound(unsigned level) const { return getIndex(4*level+1); }
+
+  Value *getStride(unsigned level) { return getIndex(4*level+2); }
+  const Value *getStride(unsigned level) const { return getIndex(4*level+2); }
+  
+  Value *getMultiplier(unsigned level) {return getIndex(4*level+3); }
+  const Value *getMultiplier(unsigned level) const {return getIndex(4*level+3); }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VMemoryInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::VGather ||
+           I->getOpcode() == Instruction::VScatter;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+
+//===----------------------------------------------------------------------===//
+//                                VGatherInst Class
+//===----------------------------------------------------------------------===//
+
+/// VGatherInst - an instruction for reading a vector into a register
+/// from memory
+///
+class VGatherInst : public VMemoryInst {
+  VGatherInst(const VGatherInst &LI) : VMemoryInst(LI.getType(), VGather, 0, 0) {
+    NumOperands = LI.getNumOperands();
+    Use *OL = OperandList = new Use[NumOperands];
+    for (unsigned i = 0; i < NumOperands; ++i)
+      OL[i].init(LI.getOperand(i), this);
+  }
+  void init(Value *Ptr, const std::vector<Value*> &Idx);
+
+public:
+  VGatherInst(Value *Ptr, const std::vector<Value*> &Idx,
+	    const std::string &Name = "", Instruction *InsertBefore = 0);
+  VGatherInst(Value *Ptr, const std::vector<Value*> &Idx,
+	    const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual VGatherInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  Value *getPointerOperand() { return getOperand(0); }
+  const Value *getPointerOperand() const { return getOperand(0); }
+  static unsigned getPointerOperandIndex() { return 0U; }
+
+  unsigned getNumIndices() const {  // Note: always non-negative
+    return getNumOperands() - 1;
+  }
+
+  Value *getIndex(unsigned i) { return getOperand(i + 1); }
+  const Value *getIndex(unsigned i) const { return getOperand(i + 1); }
+  
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VGatherInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::VGather;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+
+
+//===----------------------------------------------------------------------===//
+//                                VScatterInst Class
+//===----------------------------------------------------------------------===//
+
+/// VScatterInst - an instruction for storing a vector register to
+/// memory
+///
+class VScatterInst : public VMemoryInst {
+  VScatterInst(const VScatterInst &SI) : VMemoryInst(SI.getType(), VScatter, 0, 0) {
+    NumOperands = SI.getNumOperands();
+    Use *OL = OperandList = new Use[NumOperands];
+    for (unsigned i = 0; i < NumOperands; ++i)
+      OL[i].init(SI.getOperand(i), this);
+  }
+  void init(Value *Val, Value *Ptr, const std::vector<Value*> &Idx);
+
+public:
+  VScatterInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
+	       Instruction *InsertBefore = 0);
+  VScatterInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
+	       BasicBlock *InsertAtEnd);
+
+  virtual VScatterInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return true; }
+
+  Value *getPointerOperand() { return getOperand(1); }
+  const Value *getPointerOperand() const { return getOperand(1); }
+  static unsigned getPointerOperandIndex() { return 1U; }
+
+  unsigned getNumIndices() const {  // Note: always non-negative
+    return getNumOperands() - 2;
+  }
+
+  Value *getIndex(unsigned i) { return getOperand(i + 2); }
+  const Value *getIndex(unsigned i) const { return getOperand(i + 2); }
+  
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VScatterInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::VScatter;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+
+//===----------------------------------------------------------------------===//
+//                                VImmInst Class
+//===----------------------------------------------------------------------===//
+
+/// VImmInst - an instruction for creating a vector from a replicated
+/// scalar value
+///
+class VImmInst : public Instruction {
+  Use Ops[2];
+  VImmInst(const VImmInst &VI) : Instruction(VI.getType(), VImm, Ops, 2) {
+    Ops[0].init(VI.Ops[0], this);
+    Ops[1].init(VI.Ops[1], this);
+  }
+
+public:
+  VImmInst(Value *Ptr, Value *Len, bool isFixed,
+	   const std::string &Name = "", Instruction *InsertBefore = 0);
+  VImmInst(Value *Ptr, Value *Len, bool isFixed,
+	   const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual VImmInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 2 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 2 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 2; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const VImmInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::VImm;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+//===----------------------------------------------------------------------===//
+//                                ExtractInst Class
+//===----------------------------------------------------------------------===//
+
+/// ExtractInst - an instruction for extracting a subvector from a
+/// vector
+///
+class ExtractInst : public Instruction {
+  Use Ops[4];
+  ExtractInst(const ExtractInst &EI) : Instruction(EI.getType(), Extract, Ops, 4) {
+    Ops[0].init(EI.Ops[0], this);
+    Ops[1].init(EI.Ops[1], this);
+    Ops[2].init(EI.Ops[2], this);
+    Ops[3].init(EI.Ops[3], this);
+  }
+
+public:
+  ExtractInst(Value *Val, Value *Start, Value *Stride, Value *Len,
+	       const std::string &Name = "", Instruction *InsertBefore = 0);
+  ExtractInst(Value *Val, Value *Start, Value *Stride, Value *Len,
+	       const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual ExtractInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 4 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 4 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 4; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const ExtractInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::Extract;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+//===----------------------------------------------------------------------===//
+//                                ExtractElementInst Class
+//===----------------------------------------------------------------------===//
+
+/// ExtractElementInst - an instruction for extracting a single
+/// element from a vector
+///
+class ExtractElementInst : public Instruction {
+  Use Ops[2];
+  ExtractElementInst(const ExtractElementInst &EI) : 
+    Instruction(EI.getType(), ExtractElement, Ops, 2) {
+    Ops[0].init(EI.Ops[0], this);
+    Ops[1].init(EI.Ops[1], this);
+  }
+
+public:
+  ExtractElementInst(Value *Val, Value *Index,
+	       const std::string &Name = "", Instruction *InsertBefore = 0);
+  ExtractElementInst(Value *Val, Value *Index,
+	       const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual ExtractElementInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 2 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 2 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 2; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const ExtractElementInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::ExtractElement;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+//===----------------------------------------------------------------------===//
+//                                CombineInst Class
+//===----------------------------------------------------------------------===//
+
+/// CombineInst - an instruction for combining two vectors by
+/// overlaying the second on the first
+///
+class CombineInst : public Instruction {
+  Use Ops[4];
+  CombineInst(const CombineInst &EI) : Instruction(EI.getType(), Combine, Ops, 4) {
+    Ops[0].init(EI.Ops[0], this);
+    Ops[1].init(EI.Ops[1], this);
+    Ops[2].init(EI.Ops[2], this);
+    Ops[3].init(EI.Ops[3], this);
+  }
+
+public:
+  CombineInst(Value *V1, Value *V2, Value *Start, Value *Stride,
+	      const std::string &Name = "", Instruction *InsertBefore = 0);
+  CombineInst(Value *V1, Value *V2, Value *Start, Value *Stride,
+	      const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual CombineInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 4 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 4 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 4; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const CombineInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::Combine;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+//===----------------------------------------------------------------------===//
+//                                CombineElementInst Class
+//===----------------------------------------------------------------------===//
+
+/// CombineElementInst - an instruction for combining two vectors by
+/// overlaying the second on the first
+///
+class CombineElementInst : public Instruction {
+  Use Ops[3];
+  CombineElementInst(const CombineElementInst &EI) : 
+    Instruction(EI.getType(), CombineElement, Ops, 3) {
+    Ops[0].init(EI.Ops[0], this);
+    Ops[1].init(EI.Ops[1], this);
+    Ops[2].init(EI.Ops[2], this);
+  }
+
+public:
+  CombineElementInst(Value *Vector, Value *Element, Value *Index, 
+	      const std::string &Name = "", Instruction *InsertBefore = 0);
+  CombineElementInst(Value *Vector, Value *Element, Value *Index,
+	      const std::string &Name, BasicBlock *InsertAtEnd);
+
+  virtual CombineElementInst *clone() const;
+
+  virtual bool mayWriteToMemory() const { return false; }
+
+  /// Transparently provide more efficient getOperand methods.
+  Value *getOperand(unsigned i) const {
+    assert(i < 3 && "getOperand() out of range!");
+    return Ops[i];
+  }
+  void setOperand(unsigned i, Value *Val) {
+    assert(i < 3 && "setOperand() out of range!");
+    Ops[i] = Val;
+  }
+  unsigned getNumOperands() const { return 3; }
+
+  // Methods for support type inquiry through isa, cast, and dyn_cast:
+  static inline bool classof(const CombineElementInst *) { return true; }
+  static inline bool classof(const Instruction *I) {
+    return I->getOpcode() == Instruction::CombineElement;
+  }
+  static inline bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
 } // End llvm namespace
 
 #endif


Index: llvm/include/llvm/Type.h
diff -u llvm/include/llvm/Type.h:1.77 llvm/include/llvm/Type.h:1.77.4.1
--- llvm/include/llvm/Type.h:1.77	Sat Apr 23 16:59:42 2005
+++ llvm/include/llvm/Type.h	Tue Oct 18 14:21:56 2005
@@ -48,7 +48,7 @@
 class OpaqueType;
 class PointerType;
 class StructType;
-class PackedType;
+class FixedVectorType;
 
 class Type {
 public:
@@ -73,7 +73,9 @@
     FunctionTyID  , StructTyID,         // Functions... Structs...
     ArrayTyID     , PointerTyID,        // Array... pointer...
     OpaqueTyID,                         // Opaque type instances...
-    PackedTyID,                         // SIMD 'packed' format...
+    StreamTyID,                         // Stream...
+    VectorTyID,                         // Vector...
+    FixedVectorTyID,                    // Vector with fixed length...
     //...
 
     NumTypeIDs,                         // Must remain as last defined ID
@@ -172,6 +174,13 @@
   /// types
   bool isFloatingPoint() const { return ID == FloatTyID || ID == DoubleTyID; }
 
+  /// Functions for vector support
+  ///
+  virtual bool isIntegerVector() const { return false; }
+  virtual bool isIntegralVector() const { return false; }
+  virtual bool isFPVector() const { return false; }
+  virtual bool isBooleanVector() const { return false; }
+
   /// isAbstract - True if the type is either an Opaque type, or is a derived
   /// type that includes an opaque type somewhere in it.
   ///
@@ -192,8 +201,9 @@
   /// isFirstClassType - Return true if the value is holdable in a register.
   ///
   inline bool isFirstClassType() const {
-    return (ID != VoidTyID && ID <= LastPrimitiveTyID) ||
-            ID == PointerTyID || ID == PackedTyID;
+    return (ID != VoidTyID && ID <= LastPrimitiveTyID) || 
+            ID == PointerTyID || ID == VectorTyID || ID == FixedVectorTyID ||
+            ID == StreamTyID;
   }
 
   /// isSized - Return true if it makes sense to take the size of this type.  To
@@ -206,7 +216,7 @@
       return true;
     // If it is not something that can have a size (e.g. a function or label),
     // it doesn't have a size.
-    if (ID != StructTyID && ID != ArrayTyID && ID != PackedTyID)
+    if (ID != StructTyID && ID != ArrayTyID && ID != FixedVectorTyID)
       return false;
     // If it is something that can have a size and it's concrete, it definitely
     // has a size, otherwise we have to try harder to decide.






More information about the llvm-commits mailing list