[AVX512] adding PRORQ , PRORD , PRORLVQ and PRORLVD Intrinsics
[oota-llvm.git] / include / llvm / IR / DerivedTypes.h
index 76f806434f44f5307d6c75161fd0579712669696..071e69b1e808c0496ed4afa6e7fd7aef96ad9143 100644 (file)
@@ -36,11 +36,12 @@ class StringRef;
 /// @brief Integer representation type
 class IntegerType : public Type {
   friend class LLVMContextImpl;
-  
+
 protected:
   explicit IntegerType(LLVMContext &C, unsigned NumBits) : Type(C, IntegerTyID){
     setSubclassData(NumBits);
   }
+
 public:
   /// This enum is just used to hold constants we need for IntegerType.
   enum {
@@ -90,6 +91,9 @@ public:
   }
 };
 
+unsigned Type::getIntegerBitWidth() const {
+  return cast<IntegerType>(this)->getBitWidth();
+}
 
 /// FunctionType - Class to represent function types
 ///
@@ -108,7 +112,7 @@ public:
   /// FunctionType::get - Create a FunctionType taking no parameters.
   ///
   static FunctionType *get(Type *Result, bool isVarArg);
-  
+
   /// isValidReturnType - Return true if the specified type is valid as a return
   /// type.
   static bool isValidReturnType(Type *RetTy);
@@ -140,20 +144,33 @@ public:
     return T->getTypeID() == FunctionTyID;
   }
 };
+static_assert(AlignOf<FunctionType>::Alignment >= AlignOf<Type *>::Alignment,
+              "Alignment sufficient for objects appended to FunctionType");
+
+bool Type::isFunctionVarArg() const {
+  return cast<FunctionType>(this)->isVarArg();
+}
 
+Type *Type::getFunctionParamType(unsigned i) const {
+  return cast<FunctionType>(this)->getParamType(i);
+}
+
+unsigned Type::getFunctionNumParams() const {
+  return cast<FunctionType>(this)->getNumParams();
+}
 
 /// CompositeType - Common super class of ArrayType, StructType, PointerType
 /// and VectorType.
 class CompositeType : public Type {
 protected:
-  explicit CompositeType(LLVMContext &C, TypeID tid) : Type(C, tid) { }
-public:
+  explicit CompositeType(LLVMContext &C, TypeID tid) : Type(C, tid) {}
 
+public:
   /// getTypeAtIndex - Given an index value into the type, return the type of
   /// the element.
   ///
-  Type *getTypeAtIndex(const Value *V);
-  Type *getTypeAtIndex(unsigned Idx);
+  Type *getTypeAtIndex(const Value *V) const;
+  Type *getTypeAtIndex(unsigned Idx) const;
   bool indexValid(const Value *V) const;
   bool indexValid(unsigned Idx) const;
 
@@ -166,14 +183,13 @@ public:
   }
 };
 
-
 /// StructType - Class to represent struct types.  There are two different kinds
 /// of struct types: Literal structs and Identified structs.
 ///
 /// Literal struct types (e.g. { i32, i32 }) are uniqued structurally, and must
 /// always have a body when created.  You can get one of these by using one of
 /// the StructType::get() forms.
-///  
+///
 /// Identified structs (e.g. %foo or %42) may optionally have a name and are not
 /// uniqued.  The names for identified structs are managed at the LLVMContext
 /// level, so there can only be a single identified struct with a given name in
@@ -204,23 +220,20 @@ class StructType : public CompositeType {
   /// pointer to the symbol table entry (maintained by LLVMContext) for the
   /// struct.  This is null if the type is an literal struct or if it is
   /// a identified type that has an empty name.
-  /// 
+  ///
   void *SymbolTableEntry;
-public:
 
+public:
   /// StructType::create - This creates an identified struct.
   static StructType *create(LLVMContext &Context, StringRef Name);
   static StructType *create(LLVMContext &Context);
-  
-  static StructType *create(ArrayRef<Type*> Elements,
-                            StringRef Name,
-                            bool isPacked = false);
-  static StructType *create(ArrayRef<Type*> Elements);
-  static StructType *create(LLVMContext &Context,
-                            ArrayRef<Type*> Elements,
-                            StringRef Name,
+
+  static StructType *create(ArrayRef<Type *> Elements, StringRef Name,
                             bool isPacked = false);
-  static StructType *create(LLVMContext &Context, ArrayRef<Type*> Elements);
+  static StructType *create(ArrayRef<Type *> Elements);
+  static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements,
+                            StringRef Name, bool isPacked = false);
+  static StructType *create(LLVMContext &Context, ArrayRef<Type *> Elements);
   static StructType *create(StringRef Name, Type *elt1, ...) LLVM_END_WITH_NULL;
 
   /// StructType::get - This static method is the primary way to create a
@@ -231,7 +244,7 @@ public:
   /// StructType::get - Create an empty structure type.
   ///
   static StructType *get(LLVMContext &Context, bool isPacked = false);
-  
+
   /// StructType::get - This static method is a convenience method for creating
   /// structure types by specifying the elements as arguments.  Note that this
   /// method always returns a non-packed struct, and requires at least one
@@ -239,26 +252,26 @@ public:
   static StructType *get(Type *elt1, ...) LLVM_END_WITH_NULL;
 
   bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; }
-  
+
   /// isLiteral - Return true if this type is uniqued by structural
   /// equivalence, false if it is a struct definition.
   bool isLiteral() const { return (getSubclassData() & SCDB_IsLiteral) != 0; }
-  
+
   /// isOpaque - Return true if this is a type with an identity that has no body
   /// specified yet.  These prints as 'opaque' in .ll files.
   bool isOpaque() const { return (getSubclassData() & SCDB_HasBody) == 0; }
 
   /// isSized - Return true if this is a sized type.
-  bool isSized(SmallPtrSetImpl<const Type*> *Visited = nullptr) const;
-  
+  bool isSized(SmallPtrSetImpl<Type *> *Visited = nullptr) const;
+
   /// hasName - Return true if this is a named struct that has a non-empty name.
   bool hasName() const { return SymbolTableEntry != nullptr; }
-  
+
   /// getName - Return the name for this struct type if it has an identity.
   /// This may return an empty string for an unnamed struct type.  Do not call
   /// this on an literal type.
   StringRef getName() const;
-  
+
   /// setName - Change the name of this type to the specified name, or to a name
   /// with a suffix if there is a collision.  Do not call this on an literal
   /// type.
@@ -267,11 +280,10 @@ public:
   /// setBody - Specify a body for an opaque identified type.
   void setBody(ArrayRef<Type*> Elements, bool isPacked = false);
   void setBody(Type *elt1, ...) LLVM_END_WITH_NULL;
-  
+
   /// isValidElementType - Return true if the specified type is valid as a
   /// element type.
   static bool isValidElementType(Type *ElemTy);
-  
 
   // Iterator access to the elements.
   typedef Type::subtype_iterator element_iterator;
@@ -283,8 +295,8 @@ public:
 
   /// isLayoutIdentical - Return true if this is layout identical to the
   /// specified struct.
-  bool isLayoutIdentical(StructType *Other) const;  
-  
+  bool isLayoutIdentical(StructType *Other) const;
+
   /// Random access to the elements
   unsigned getNumElements() const { return NumContainedTys; }
   Type *getElementType(unsigned N) const {
@@ -298,6 +310,18 @@ public:
   }
 };
 
+StringRef Type::getStructName() const {
+  return cast<StructType>(this)->getName();
+}
+
+unsigned Type::getStructNumElements() const {
+  return cast<StructType>(this)->getNumElements();
+}
+
+Type *Type::getStructElementType(unsigned N) const {
+  return cast<StructType>(this)->getElementType(N);
+}
+
 /// SequentialType - This is the superclass of the array, pointer and vector
 /// type classes.  All of these represent "arrays" in memory.  The array type
 /// represents a specifically sized array, pointer types are unsized/unknown
@@ -329,6 +353,9 @@ public:
   }
 };
 
+Type *Type::getSequentialElementType() const {
+  return cast<SequentialType>(this)->getElementType();
+}
 
 /// ArrayType - Class to represent array types.
 ///
@@ -338,6 +365,7 @@ class ArrayType : public SequentialType {
   ArrayType(const ArrayType &) = delete;
   const ArrayType &operator=(const ArrayType &) = delete;
   ArrayType(Type *ElType, uint64_t NumEl);
+
 public:
   /// ArrayType::get - This static method is the primary way to construct an
   /// ArrayType
@@ -356,6 +384,10 @@ public:
   }
 };
 
+uint64_t Type::getArrayNumElements() const {
+  return cast<ArrayType>(this)->getNumElements();
+}
+
 /// VectorType - Class to represent vector types.
 ///
 class VectorType : public SequentialType {
@@ -364,6 +396,7 @@ class VectorType : public SequentialType {
   VectorType(const VectorType &) = delete;
   const VectorType &operator=(const VectorType &) = delete;
   VectorType(Type *ElType, unsigned NumEl);
+
 public:
   /// VectorType::get - This static method is the primary way to construct an
   /// VectorType.
@@ -442,6 +475,9 @@ public:
   }
 };
 
+unsigned Type::getVectorNumElements() const {
+  return cast<VectorType>(this)->getNumElements();
+}
 
 /// PointerType - Class to represent pointers.
 ///
@@ -449,6 +485,7 @@ class PointerType : public SequentialType {
   PointerType(const PointerType &) = delete;
   const PointerType &operator=(const PointerType &) = delete;
   explicit PointerType(Type *ElType, unsigned AddrSpace);
+
 public:
   /// PointerType::get - This constructs a pointer to an object of the specified
   /// type in a numbered address space.
@@ -464,6 +501,9 @@ public:
   /// element type.
   static bool isValidElementType(Type *ElemTy);
 
+  /// Return true if we can load or store from a pointer to this type.
+  static bool isLoadableOrStorableType(Type *ElemTy);
+
   /// @brief Return the address space of the Pointer type.
   inline unsigned getAddressSpace() const { return getSubclassData(); }
 
@@ -473,6 +513,10 @@ public:
   }
 };
 
+unsigned Type::getPointerAddressSpace() const {
+  return cast<PointerType>(getScalarType())->getAddressSpace();
+}
+
 } // End llvm namespace
 
 #endif