class StructType

Declaration

class StructType : public Type { /* 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:213

Inherits from: Type

Member Variables

private void* SymbolTableEntry = nullptr
For a named struct that actually has a name, this is a 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.

Inherited from Type:

protected NumContainedTys = 0
protected ContainedTys = nullptr

Method Overview

  • public StructType(const llvm::StructType &)
  • private StructType(llvm::LLVMContext & C)
  • public static bool classof(const llvm::Type * T)
  • public bool containsScalableVectorType() const
  • 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 std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *> 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 ArrayRef<llvm::Type *> elements() const
  • public template <class... Tys>static std::enable_if_t<are_base_of<Type, Tys...>::value, StructType *> 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 llvm::Type * getTypeAtIndex(const llvm::Value * V) const
  • public llvm::Type * getTypeAtIndex(unsigned int N) const
  • public static llvm::StructType * getTypeByName(llvm::LLVMContext & C, llvm::StringRef Name)
  • public bool hasName() const
  • public bool indexValid(const llvm::Value * V) const
  • public bool indexValid(unsigned int Idx) 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>std::enable_if_t<are_base_of<Type, Tys...>::value, void> setBody(llvm::Type * elt1, Tys *... elts)
  • public void setName(llvm::StringRef Name)

Inherited from Type:

Methods

StructType(const llvm::StructType&)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:231

Parameters

const llvm::StructType&

StructType(llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:214

Parameters

llvm::LLVMContext& C

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:339

Parameters

const llvm::Type* T

bool containsScalableVectorType() const

Description

Returns true if this struct contains a scalable vector.

Declared at: llvm/include/llvm/IR/DerivedTypes.h:287

static llvm::StructType* create(
    llvm::LLVMContext& Context,
    llvm::StringRef Name)

Description

This creates an identified struct.

Declared at: llvm/include/llvm/IR/DerivedTypes.h:235

Parameters

llvm::LLVMContext& Context
llvm::StringRef Name

static llvm::StructType* create(
    llvm::LLVMContext& Context)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:236

Parameters

llvm::LLVMContext& Context

static llvm::StructType* create(
    ArrayRef<llvm::Type*> Elements,
    llvm::StringRef Name,
    bool isPacked = false)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:238

Parameters

ArrayRef<llvm::Type*> Elements
llvm::StringRef Name
bool isPacked = false

static llvm::StructType* create(
    ArrayRef<llvm::Type*> Elements)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:240

Parameters

ArrayRef<llvm::Type*> Elements

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:241

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)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:243

Parameters

llvm::LLVMContext& Context
ArrayRef<llvm::Type*> Elements

template <class... Tys>
static std::enable_if_t<
    are_base_of<Type, Tys...>::value,
    StructType*>
create(llvm::StringRef Name,
       llvm::Type* elt1,
       Tys*... elts)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:246

Templates

Tys

Parameters

llvm::StringRef Name
llvm::Type* elt1
Tys*... elts

llvm::StructType::element_iterator element_begin()
    const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:317

llvm::StructType::element_iterator element_end()
    const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:318

ArrayRef<llvm::Type*> elements() const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:319

template <class... Tys>
static std::enable_if_t<
    are_base_of<Type, Tys...>::value,
    StructType*>
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:263

Templates

Tys

Parameters

llvm::Type* elt1
Tys*... elts

static llvm::StructType* get(
    llvm::LLVMContext& Context,
    bool isPacked = false)

Description

Create an empty structure type.

Declared at: llvm/include/llvm/IR/DerivedTypes.h:256

Parameters

llvm::LLVMContext& Context
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:252

Parameters

llvm::LLVMContext& Context
ArrayRef<llvm::Type*> Elements
bool isPacked = false

llvm::Type* getElementType(unsigned int N) const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:328

Parameters

unsigned int N

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:295

unsigned int getNumElements() const

Description

Random access to the elements

Declared at: llvm/include/llvm/IR/DerivedTypes.h:327

llvm::Type* getTypeAtIndex(
    const llvm::Value* V) const

Description

Given an index value into the type, return the type of the element.

Declared at: llvm/include/llvm/IR/DerivedTypes.h:333

Parameters

const llvm::Value* V

llvm::Type* getTypeAtIndex(unsigned int N) const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:334

Parameters

unsigned int N

static llvm::StructType* getTypeByName(
    llvm::LLVMContext& C,
    llvm::StringRef Name)

Description

Return the type with the specified name, or null if there is none by that name.

Declared at: llvm/include/llvm/IR/DerivedTypes.h:271

Parameters

llvm::LLVMContext& C
llvm::StringRef Name

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:290

bool indexValid(const llvm::Value* V) const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:335

Parameters

const llvm::Value* V

bool indexValid(unsigned int Idx) const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:336

Parameters

unsigned int Idx

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:324

Parameters

llvm::StructType* Other

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:277

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:281

bool isPacked() const

Declared at: llvm/include/llvm/IR/DerivedTypes.h:273

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:284

Parameters

SmallPtrSetImpl<llvm::Type*>* Visited = nullptr

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:312

Parameters

llvm::Type* ElemTy

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:302

Parameters

ArrayRef<llvm::Type*> Elements
bool isPacked = false

template <typename... Tys>
std::enable_if_t<are_base_of<Type, Tys...>::value,
                 void>
setBody(llvm::Type* elt1, Tys*... elts)

Declared at: llvm/include/llvm/IR/DerivedTypes.h:306

Templates

Tys

Parameters

llvm::Type* elt1
Tys*... elts

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:299

Parameters

llvm::StringRef Name