class StructType
Declaration
class StructType : public CompositeType { /* full declaration omitted */ };
Description
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 a particular LLVMContext. Identified structs may also optionally be opaque (have no body specified). You get one of these by using one of the StructType::create() forms. Independent of what kind of struct you have, the body of a struct type are laid out in memory consecutively with the elements directly one after the other (if the struct is packed) or (if not packed) with padding between the elements as defined by DataLayout (which is required to match what the code generator for a target expects).
Declared at: llvm/include/llvm/IR/DerivedTypes.h:238
Inherits from: CompositeType
Member Variables
Inherited from Type:
- protected NumContainedTys = 0
- protected ContainedTys = nullptr
Method Overview
- public StructType(const llvm::StructType &)
- public static bool classof(const llvm::Type * T)
- public static llvm::StructType * create(llvm::LLVMContext & Context, llvm::StringRef Name)
- public static llvm::StructType * create(llvm::LLVMContext & Context)
- public static llvm::StructType * create(ArrayRef<llvm::Type *> Elements, llvm::StringRef Name, bool isPacked = false)
- public static llvm::StructType * create(ArrayRef<llvm::Type *> Elements)
- public static llvm::StructType * create(llvm::LLVMContext & Context, ArrayRef<llvm::Type *> Elements, llvm::StringRef Name, bool isPacked = false)
- public static llvm::StructType * create(llvm::LLVMContext & Context, ArrayRef<llvm::Type *> Elements)
- public template <class... Tys>static typename std::enable_if<are_base_of<Type, Tys...>::value, StructType *>::type create(llvm::StringRef Name, llvm::Type * elt1, Tys *... elts)
- public llvm::StructType::element_iterator element_begin() const
- public llvm::StructType::element_iterator element_end() const
- public const ArrayRef<llvm::Type *> elements() const
- public template <class... Tys>static typename std::enable_if<are_base_of<Type, Tys...>::value, StructType *>::type get(llvm::Type * elt1, Tys *... elts)
- public static llvm::StructType * get(llvm::LLVMContext & Context, bool isPacked = false)
- public static llvm::StructType * get(llvm::LLVMContext & Context, ArrayRef<llvm::Type *> Elements, bool isPacked = false)
- public llvm::Type * getElementType(unsigned int N) const
- public llvm::StringRef getName() const
- public unsigned int getNumElements() const
- public bool hasName() const
- public bool isLayoutIdentical(llvm::StructType * Other) const
- public bool isLiteral() const
- public bool isOpaque() const
- public bool isPacked() const
- public bool isSized(SmallPtrSetImpl<llvm::Type *> * Visited = nullptr) const
- public static bool isValidElementType(llvm::Type * ElemTy)
- public void setBody(ArrayRef<llvm::Type *> Elements, bool isPacked = false)
- public template <typename... Tys>typename std::enable_if<are_base_of<Type, Tys...>::value, void>::type setBody(llvm::Type * elt1, Tys *... elts)
- public void setName(llvm::StringRef Name)
Inherited from CompositeType:
Inherited from Type:
- public canLosslesslyBitCastTo
- public dump
- public getArrayElementType
- public getArrayNumElements
- public getContainedType
- public getContext
- public getDoublePtrTy
- public getDoubleTy
- public getExtendedType
- public getFP128PtrTy
- public getFP128Ty
- public getFPMantissaWidth
- public getFloatPtrTy
- public getFloatTy
- public getFltSemantics
- public getFunctionNumParams
- public getFunctionParamType
- public getHalfPtrTy
- public getHalfTy
- public getInt128Ty
- public getInt16PtrTy
- public getInt16Ty
- public getInt1PtrTy
- public getInt1Ty
- public getInt32PtrTy
- public getInt32Ty
- public getInt64PtrTy
- public getInt64Ty
- public getInt8PtrTy
- public getInt8Ty
- public getIntNPtrTy
- public getIntNTy
- public getIntegerBitWidth
- public getLabelTy
- public getMetadataTy
- public getNumContainedTypes
- public getPPC_FP128PtrTy
- public getPPC_FP128Ty
- public getPointerAddressSpace
- public getPointerElementType
- public getPointerTo
- public getPrimitiveSizeInBits
- public getPrimitiveType
- public getScalarSizeInBits
- public getScalarTy
- public getScalarType
- public getSequentialElementType
- public getStructElementType
- public getStructName
- public getStructNumElements
- protected getSubclassData
- public getTokenTy
- public getTypeID
- public getVectorElementCount
- public getVectorElementType
- public getVectorIsScalable
- public getVectorNumElements
- public getVoidTy
- public getWithNewBitWidth
- public getX86_FP80PtrTy
- public getX86_FP80Ty
- public getX86_MMXPtrTy
- public getX86_MMXTy
- public isAggregateType
- public isArrayTy
- public isDoubleTy
- public isEmptyTy
- public isFP128Ty
- public isFPOrFPVectorTy
- public isFirstClassType
- public isFloatTy
- public isFloatingPointTy
- public isFunctionTy
- public isFunctionVarArg
- public isHalfTy
- public isIntOrIntVectorTy
- public isIntOrIntVectorTy
- public isIntOrPtrTy
- public isIntegerTy
- public isIntegerTy
- public isLabelTy
- public isMetadataTy
- public isPPC_FP128Ty
- public isPointerTy
- public isPtrOrPtrVectorTy
- protected isSequentialType
- public isSingleValueType
- public isSized
- public isStructTy
- public isTokenTy
- public isVectorTy
- public isVoidTy
- public isX86_FP80Ty
- public isX86_MMXTy
- public print
- protected setSubclassData
- public subtype_begin
- public subtype_end
- public subtype_rbegin
- public subtype_rend
- public subtypes
Methods
¶StructType(const llvm::StructType&)
StructType(const llvm::StructType&)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:256
Parameters
- const llvm::StructType&
¶static bool classof(const llvm::Type* T)
static bool classof(const llvm::Type* T)
Description
Methods for support type inquiry through isa, cast, and dyn_cast.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:357
Parameters
- const llvm::Type* T
¶static llvm::StructType* create(
llvm::LLVMContext& Context,
llvm::StringRef Name)
static llvm::StructType* create(
llvm::LLVMContext& Context,
llvm::StringRef Name)
Description
This creates an identified struct.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:260
Parameters
- llvm::LLVMContext& Context
- llvm::StringRef Name
¶static llvm::StructType* create(
llvm::LLVMContext& Context)
static llvm::StructType* create(
llvm::LLVMContext& Context)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:261
Parameters
- llvm::LLVMContext& Context
¶static llvm::StructType* create(
ArrayRef<llvm::Type*> Elements,
llvm::StringRef Name,
bool isPacked = false)
static llvm::StructType* create(
ArrayRef<llvm::Type*> Elements,
llvm::StringRef Name,
bool isPacked = false)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:263
Parameters
- ArrayRef<llvm::Type*> Elements
- llvm::StringRef Name
- bool isPacked = false
¶static llvm::StructType* create(
ArrayRef<llvm::Type*> Elements)
static llvm::StructType* create(
ArrayRef<llvm::Type*> Elements)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:265
Parameters
- ArrayRef<llvm::Type*> Elements
¶static llvm::StructType* create(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements,
llvm::StringRef Name,
bool isPacked = false)
static llvm::StructType* create(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements,
llvm::StringRef Name,
bool isPacked = false)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:266
Parameters
- llvm::LLVMContext& Context
- ArrayRef<llvm::Type*> Elements
- llvm::StringRef Name
- bool isPacked = false
¶static llvm::StructType* create(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements)
static llvm::StructType* create(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:268
Parameters
- llvm::LLVMContext& Context
- ArrayRef<llvm::Type*> Elements
¶template <class... Tys>
static typename std::enable_if<
are_base_of<Type, Tys...>::value,
StructType*>::type
create(llvm::StringRef Name,
llvm::Type* elt1,
Tys*... elts)
template <class... Tys>
static typename std::enable_if<
are_base_of<Type, Tys...>::value,
StructType*>::type
create(llvm::StringRef Name,
llvm::Type* elt1,
Tys*... elts)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:272
Templates
- Tys
Parameters
- llvm::StringRef Name
- llvm::Type* elt1
- Tys*... elts
¶llvm::StructType::element_iterator element_begin()
const
llvm::StructType::element_iterator element_begin()
const
Declared at: llvm/include/llvm/IR/DerivedTypes.h:340
¶llvm::StructType::element_iterator element_end()
const
llvm::StructType::element_iterator element_end()
const
Declared at: llvm/include/llvm/IR/DerivedTypes.h:341
¶const ArrayRef<llvm::Type*> elements() const
const ArrayRef<llvm::Type*> elements() const
Declared at: llvm/include/llvm/IR/DerivedTypes.h:342
¶template <class... Tys>
static typename std::enable_if<
are_base_of<Type, Tys...>::value,
StructType*>::type
get(llvm::Type* elt1, Tys*... elts)
template <class... Tys>
static typename std::enable_if<
are_base_of<Type, Tys...>::value,
StructType*>::type
get(llvm::Type* elt1, Tys*... elts)
Description
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 element type.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:291
Templates
- Tys
Parameters
- llvm::Type* elt1
- Tys*... elts
¶static llvm::StructType* get(
llvm::LLVMContext& Context,
bool isPacked = false)
static llvm::StructType* get(
llvm::LLVMContext& Context,
bool isPacked = false)
Description
Create an empty structure type.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:283
Parameters
- llvm::LLVMContext& Context
- bool isPacked = false
¶static llvm::StructType* get(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements,
bool isPacked = false)
static llvm::StructType* get(
llvm::LLVMContext& Context,
ArrayRef<llvm::Type*> Elements,
bool isPacked = false)
Description
This static method is the primary way to create a literal StructType.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:279
Parameters
- llvm::LLVMContext& Context
- ArrayRef<llvm::Type*> Elements
- bool isPacked = false
¶llvm::Type* getElementType(unsigned int N) const
llvm::Type* getElementType(unsigned int N) const
Declared at: llvm/include/llvm/IR/DerivedTypes.h:351
Parameters
- unsigned int N
¶llvm::StringRef getName() const
llvm::StringRef getName() const
Description
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.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:317
¶unsigned int getNumElements() const
unsigned int getNumElements() const
Description
Random access to the elements
Declared at: llvm/include/llvm/IR/DerivedTypes.h:350
¶bool hasName() const
bool hasName() const
Description
Return true if this is a named struct that has a non-empty name.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:312
¶bool isLayoutIdentical(
llvm::StructType* Other) const
bool isLayoutIdentical(
llvm::StructType* Other) const
Description
Return true if this is layout identical to the specified struct.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:347
Parameters
- llvm::StructType* Other
¶bool isLiteral() const
bool isLiteral() const
Description
Return true if this type is uniqued by structural equivalence, false if it is a struct definition.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:302
¶bool isOpaque() const
bool isOpaque() const
Description
Return true if this is a type with an identity that has no body specified yet. These prints as 'opaque' in .ll files.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:306
¶bool isPacked() const
bool isPacked() const
Declared at: llvm/include/llvm/IR/DerivedTypes.h:298
¶bool isSized(SmallPtrSetImpl<llvm::Type*>*
Visited = nullptr) const
bool isSized(SmallPtrSetImpl<llvm::Type*>*
Visited = nullptr) const
Description
isSized - Return true if this is a sized type.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:309
Parameters
- SmallPtrSetImpl<llvm::Type*>* Visited = nullptr
¶static bool isValidElementType(llvm::Type* ElemTy)
static bool isValidElementType(llvm::Type* ElemTy)
Description
Return true if the specified type is valid as a element type.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:335
Parameters
- llvm::Type* ElemTy
¶void setBody(ArrayRef<llvm::Type*> Elements,
bool isPacked = false)
void setBody(ArrayRef<llvm::Type*> Elements,
bool isPacked = false)
Description
Specify a body for an opaque identified type.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:324
Parameters
- ArrayRef<llvm::Type*> Elements
- bool isPacked = false
¶template <typename... Tys>
typename std::enable_if<
are_base_of<Type, Tys...>::value,
void>::type
setBody(llvm::Type* elt1, Tys*... elts)
template <typename... Tys>
typename std::enable_if<
are_base_of<Type, Tys...>::value,
void>::type
setBody(llvm::Type* elt1, Tys*... elts)
Declared at: llvm/include/llvm/IR/DerivedTypes.h:328
Templates
- Tys
Parameters
- llvm::Type* elt1
- Tys*... elts
¶void setName(llvm::StringRef Name)
void setName(llvm::StringRef Name)
Description
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.
Declared at: llvm/include/llvm/IR/DerivedTypes.h:321
Parameters
- llvm::StringRef Name