class Type

Declaration

class Type { /* full declaration omitted */ };

Description

The instances of the Type class are immutable: once they are created, they are never changed. Also note that only one instance of a particular type is ever created. Thus seeing if two types are equal is a matter of doing a trivial pointer comparison. To enforce that no two equal instances are created, Type instances can only be created via static factory methods in class Type and in derived classes. Once allocated, Types are never free'd.

Declared at: llvm/include/llvm/IR/Type.h:45

Member Variables

private llvm::LLVMContext& Context
This refers to the LLVMContext in which this type was uniqued.
private llvm::Type::TypeID ID
private unsigned int SubclassData
protected unsigned int NumContainedTys = 0
Keeps track of how many Type*'s there are in the ContainedTys list.
protected llvm::Type* const* ContainedTys = nullptr
A pointer to the array of Types contained by this Type. For example, this includes the arguments of a function type, the elements of a structure, the pointee of a pointer, the element type of an array, etc. This pointer may be 0 for types that don't contain other types (Integer, Double, Float).

Method Overview

Methods

Type(llvm::LLVMContext& C, llvm::Type::TypeID tid)

Declared at: llvm/include/llvm/IR/Type.h:93

Parameters

llvm::LLVMContext& C
llvm::Type::TypeID tid

bool canLosslesslyBitCastTo(llvm::Type* Ty) const

Description

Return true if this type could be converted with a lossless BitCast to type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the same size only where no re-interpretation of the bits is done. Determine if this type could be losslessly bitcast to Ty

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

Parameters

llvm::Type* Ty

void dump() const

Declared at: llvm/include/llvm/IR/Type.h:125

llvm::Type* getArrayElementType() const

Declared at: llvm/include/llvm/IR/Type.h:370

inline uint64_t getArrayNumElements() const

Declared at: llvm/include/llvm/IR/Type.h:368

static llvm::PointerType* getBFloatPtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:462

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getBFloatTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:424

Parameters

llvm::LLVMContext& C

llvm::Type* getContainedType(unsigned int i) const

Description

This method is used to implement the type iterator (defined at the end of the file). For derived types, this returns the types 'contained' in the derived type.

Declared at: llvm/include/llvm/IR/Type.h:343

Parameters

unsigned int i

llvm::LLVMContext& getContext() const

Description

Return the LLVMContext in which this type was uniqued.

Declared at: llvm/include/llvm/IR/Type.h:128

static llvm::PointerType* getDoublePtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:464

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getDoubleTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:426

Parameters

llvm::LLVMContext& C

inline llvm::Type* getExtendedType() const

Description

Given scalar/vector integer type, returns a type with elements twice as wide as in the original type. For vectors, preserves element count.

Declared at: llvm/include/llvm/IR/Type.h:405

static llvm::PointerType* getFP128PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:466

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getFP128Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:429

Parameters

llvm::LLVMContext& C

int getFPMantissaWidth() const

Description

Return the width of the mantissa of this type. This is only valid on floating-point types. If the FP type does not have a stable mantissa (e.g. ppc long double), this method returns -1.

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

static llvm::PointerType* getFloatPtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:463

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getFloatTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:425

Parameters

llvm::LLVMContext& C

static llvm::Type* getFloatingPointTy(
    llvm::LLVMContext& C,
    const llvm::fltSemantics& S)

Declared at: llvm/include/llvm/IR/Type.h:455

Parameters

llvm::LLVMContext& C
const llvm::fltSemantics& S

const llvm::fltSemantics& getFltSemantics() const

Declared at: llvm/include/llvm/IR/Type.h:175

inline unsigned int getFunctionNumParams() const

Declared at: llvm/include/llvm/IR/Type.h:361

inline llvm::Type* getFunctionParamType(
    unsigned int i) const

Declared at: llvm/include/llvm/IR/Type.h:360

Parameters

unsigned int i

static llvm::PointerType* getHalfPtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:461

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getHalfTy(llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:423

Parameters

llvm::LLVMContext& C

static llvm::IntegerType* getInt128Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:440

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getInt16PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:473

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::IntegerType* getInt16Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:437

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getInt1PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:471

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::IntegerType* getInt1Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:435

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getInt32PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:474

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::IntegerType* getInt32Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:438

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getInt64PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:475

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::IntegerType* getInt64Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:439

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getInt8PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:472

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::IntegerType* getInt8Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:436

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getIntNPtrTy(
    llvm::LLVMContext& C,
    unsigned int N,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:470

Parameters

llvm::LLVMContext& C
unsigned int N
unsigned int AS = 0

static llvm::IntegerType* getIntNTy(
    llvm::LLVMContext& C,
    unsigned int N)

Declared at: llvm/include/llvm/IR/Type.h:434

Parameters

llvm::LLVMContext& C
unsigned int N

inline unsigned int getIntegerBitWidth() const

Declared at: llvm/include/llvm/IR/Type.h:358

static llvm::Type* getLabelTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:422

Parameters

llvm::LLVMContext& C

static llvm::Type* getMetadataTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:427

Parameters

llvm::LLVMContext& C

llvm::Type* getNonOpaquePointerElementType() const

Description

Only use this method in code that is not reachable with opaque pointers, or part of deprecated methods that will be removed as part of the opaque pointers transition.

Declared at: llvm/include/llvm/IR/Type.h:387

unsigned int getNumContainedTypes() const

Description

Return the number of types in the derived type.

Declared at: llvm/include/llvm/IR/Type.h:349

static llvm::PointerType* getPPC_FP128PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:467

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getPPC_FP128Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:430

Parameters

llvm::LLVMContext& C

inline unsigned int getPointerAddressSpace() const

Description

Get the address space of this pointer or pointer vector type.

Declared at: llvm/include/llvm/IR/Type.h:408

llvm::Type* getPointerElementType() const

Description

This method is deprecated without replacement. Pointer element types are not available with opaque pointers.

Declared at: llvm/include/llvm/IR/Type.h:380

llvm::PointerType* getPointerTo(
    unsigned int AddrSpace = 0) const

Description

Return a pointer to the current type. This is equivalent to PointerType::get(Foo, AddrSpace). TODO: Remove this after opaque pointer transition is complete.

Declared at: llvm/include/llvm/IR/Type.h:480

Parameters

unsigned int AddrSpace = 0

llvm::TypeSize getPrimitiveSizeInBits() const

Description

Return the basic size of this type if it is a primitive type. These are fixed by LLVM and are not target-dependent. This will return zero if the type does not have a size or is not a primitive type. If this is a scalable vector type, the scalable property will be set and the runtime size will be a positive integer multiple of the base size. Note that this may not reflect the size of memory allocated for an instance of the type or the number of bytes that are written when an instance of the type is stored to memory. The DataLayout class provides additional query functions to provide this information.

Declared at: llvm/include/llvm/IR/Type.h:296

static llvm::Type* getPrimitiveType(
    llvm::LLVMContext& C,
    llvm::Type::TypeID IDNumber)

Description

Return a type based on an identifier.

Declared at: llvm/include/llvm/IR/Type.h:416

Parameters

llvm::LLVMContext& C
llvm::Type::TypeID IDNumber

unsigned int getScalarSizeInBits() const

Description

If this is a vector type, return the getPrimitiveSizeInBits value for the element type. Otherwise return the getPrimitiveSizeInBits value for this type.

Declared at: llvm/include/llvm/IR/Type.h:301

template <typename ScalarTy>
static llvm::Type* getScalarTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:441

Templates

ScalarTy

Parameters

llvm::LLVMContext& C

inline llvm::Type* getScalarType() const

Description

If this is a vector type, return the element type, otherwise return 'this'.

Declared at: llvm/include/llvm/IR/Type.h:314

inline llvm::Type* getStructElementType(
    unsigned int N) const

Declared at: llvm/include/llvm/IR/Type.h:366

Parameters

unsigned int N

inline llvm::StringRef getStructName() const

Declared at: llvm/include/llvm/IR/Type.h:364

inline unsigned int getStructNumElements() const

Declared at: llvm/include/llvm/IR/Type.h:365

unsigned int getSubclassData() const

Declared at: llvm/include/llvm/IR/Type.h:97

static llvm::Type* getTokenTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:433

Parameters

llvm::LLVMContext& C

llvm::Type::TypeID getTypeID() const

Description

Return the type id for the type. This will return one of the TypeID enum elements defined above.

Declared at: llvm/include/llvm/IR/Type.h:136

static llvm::Type* getVoidTy(llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:421

Parameters

llvm::LLVMContext& C

inline llvm::Type* getWithNewBitWidth(
    unsigned int NewBitWidth) const

Description

Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old number of lanes.

Declared at: llvm/include/llvm/IR/Type.h:401

Parameters

unsigned int NewBitWidth

inline llvm::Type* getWithNewType(
    llvm::Type* EltTy) const

Description

Given vector type, change the element type, whilst keeping the old number of elements. For non-vectors simply returns \p EltTy.

Declared at: llvm/include/llvm/IR/Type.h:397

Parameters

llvm::Type* EltTy

static llvm::PointerType* getX86_AMXPtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:469

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getX86_AMXTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:432

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getX86_FP80PtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:465

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getX86_FP80Ty(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:428

Parameters

llvm::LLVMContext& C

static llvm::PointerType* getX86_MMXPtrTy(
    llvm::LLVMContext& C,
    unsigned int AS = 0)

Declared at: llvm/include/llvm/IR/Type.h:468

Parameters

llvm::LLVMContext& C
unsigned int AS = 0

static llvm::Type* getX86_MMXTy(
    llvm::LLVMContext& C)

Declared at: llvm/include/llvm/IR/Type.h:431

Parameters

llvm::LLVMContext& C

bool is16bitFPTy() const

Description

Return true if this is a 16-bit float type.

Declared at: llvm/include/llvm/IR/Type.h:148

bool isAggregateType() const

Description

Return true if the type is an aggregate type. This means it is valid as the first operand of an insertvalue or extractvalue instruction. This includes struct and array types, but does not include vector types.

Declared at: llvm/include/llvm/IR/Type.h:262

bool isArrayTy() const

Description

True if this is an instance of ArrayType.

Declared at: llvm/include/llvm/IR/Type.h:220

bool isBFloatTy() const

Description

Return true if this is 'bfloat', a 16-bit bfloat type.

Declared at: llvm/include/llvm/IR/Type.h:145

bool isDoubleTy() const

Description

Return true if this is 'double', a 64-bit IEEE fp type.

Declared at: llvm/include/llvm/IR/Type.h:156

bool isEmptyTy() const

Description

Return true if this type is empty, that is, it has no elements or all of its elements are empty.

Declared at: llvm/include/llvm/IR/Type.h:244

bool isFP128Ty() const

Description

Return true if this is 'fp128'.

Declared at: llvm/include/llvm/IR/Type.h:162

bool isFPOrFPVectorTy() const

Description

Return true if this is a FP type or a vector of FP.

Declared at: llvm/include/llvm/IR/Type.h:184

bool isFirstClassType() const

Description

Return true if the type is "first class", meaning it is a valid type for a Value.

Declared at: llvm/include/llvm/IR/Type.h:248

bool isFloatTy() const

Description

Return true if this is 'float', a 32-bit IEEE fp type.

Declared at: llvm/include/llvm/IR/Type.h:153

bool isFloatingPointTy() const

Description

Return true if this is one of the six floating-point types

Declared at: llvm/include/llvm/IR/Type.h:168

bool isFunctionTy() const

Description

True if this is an instance of FunctionType.

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

inline bool isFunctionVarArg() const

Declared at: llvm/include/llvm/IR/Type.h:362

bool isHalfTy() const

Description

Return true if this is 'half', a 16-bit IEEE fp type.

Declared at: llvm/include/llvm/IR/Type.h:142

bool isIEEE() const

Description

Return whether the type is IEEE compatible, as defined by the eponymous method in APFloat.

Declared at: llvm/include/llvm/IR/Type.h:310

bool isIntOrIntVectorTy() const

Description

Return true if this is an integer type or a vector of integer types.

Declared at: llvm/include/llvm/IR/Type.h:202

bool isIntOrIntVectorTy(
    unsigned int BitWidth) const

Description

Return true if this is an integer type or a vector of integer types of the given width.

Declared at: llvm/include/llvm/IR/Type.h:206

Parameters

unsigned int BitWidth

bool isIntOrPtrTy() const

Description

Return true if this is an integer type or a pointer type.

Declared at: llvm/include/llvm/IR/Type.h:211

bool isIntegerTy(unsigned int Bitwidth) const

Description

Return true if this is an IntegerType of the given width.

Declared at: llvm/include/llvm/IR/Type.h:199

Parameters

unsigned int Bitwidth

bool isIntegerTy() const

Description

True if this is an instance of IntegerType.

Declared at: llvm/include/llvm/IR/Type.h:196

bool isLabelTy() const

Description

Return true if this is 'label'.

Declared at: llvm/include/llvm/IR/Type.h:187

bool isMetadataTy() const

Description

Return true if this is 'metadata'.

Declared at: llvm/include/llvm/IR/Type.h:190

bool isOpaquePointerTy() const

Description

True if this is an instance of an opaque PointerType.

Declared at: llvm/include/llvm/IR/Type.h:226

bool isPPC_FP128Ty() const

Description

Return true if this is powerpc long double.

Declared at: llvm/include/llvm/IR/Type.h:165

bool isPointerTy() const

Description

True if this is an instance of PointerType.

Declared at: llvm/include/llvm/IR/Type.h:223

bool isPtrOrPtrVectorTy() const

Description

Return true if this is a pointer type or a vector of pointer types.

Declared at: llvm/include/llvm/IR/Type.h:229

bool isSingleValueType() const

Description

Return true if the type is a valid type for a register in codegen. This includes all first-class types except struct and array types.

Declared at: llvm/include/llvm/IR/Type.h:254

bool isSized(SmallPtrSetImpl<llvm::Type*>*
                 Visited = nullptr) const

Description

Return true if it makes sense to take the size of this type. To get the actual size for a particular target, it is reasonable to use the DataLayout subsystem to do this.

Declared at: llvm/include/llvm/IR/Type.h:269

Parameters

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

bool isSizedDerivedType(
    SmallPtrSetImpl<llvm::Type*>* Visited =
        nullptr) const

Description

Derived types like structures and arrays are sized iff all of the members of the type are sized as well. Since asking for their size is relatively uncommon, move this operation out-of-line.

Declared at: llvm/include/llvm/IR/Type.h:486

Parameters

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

bool isStructTy() const

Description

True if this is an instance of StructType.

Declared at: llvm/include/llvm/IR/Type.h:217

bool isTokenTy() const

Description

Return true if this is 'token'.

Declared at: llvm/include/llvm/IR/Type.h:193

inline bool isVectorTy() const

Description

True if this is an instance of VectorType.

Declared at: llvm/include/llvm/IR/Type.h:232

bool isVoidTy() const

Description

Return true if this is 'void'.

Declared at: llvm/include/llvm/IR/Type.h:139

bool isX86_AMXTy() const

Description

Return true if this is X86 AMX.

Declared at: llvm/include/llvm/IR/Type.h:181

bool isX86_FP80Ty() const

Description

Return true if this is x86 long double.

Declared at: llvm/include/llvm/IR/Type.h:159

bool isX86_MMXTy() const

Description

Return true if this is X86 MMX.

Declared at: llvm/include/llvm/IR/Type.h:178

void print(llvm::raw_ostream& O,
           bool IsForDebug = false,
           bool NoDetails = false) const

Description

Print the current type. Omit the type details if \p NoDetails == true. E.g., let %st = type { i32, i16 } When \p NoDetails is true, we only print %st. Put differently, \p NoDetails prints the type as if inlined with the operands when printing an instruction.

Declared at: llvm/include/llvm/IR/Type.h:122

Parameters

llvm::raw_ostream& O
bool IsForDebug = false
bool NoDetails = false

void setSubclassData(unsigned int val)

Declared at: llvm/include/llvm/IR/Type.h:99

Parameters

unsigned int val

llvm::Type::subtype_iterator subtype_begin() const

Declared at: llvm/include/llvm/IR/Type.h:325

llvm::Type::subtype_iterator subtype_end() const

Declared at: llvm/include/llvm/IR/Type.h:326

llvm::Type::subtype_reverse_iterator
subtype_rbegin() const

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

llvm::Type::subtype_reverse_iterator
subtype_rend() const

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

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

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

~Type()

Declared at: llvm/include/llvm/IR/Type.h:95