llvm::Type

The root of the LLVM type system hierarchy.

Synopsis

Declared in <llvm/IR/Type.h>

class Type;

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.

Type Aliases

NameDescription
subtype_iterator Iterator over this type's contained (subtype) types.
subtype_reverse_iterator Reverse iterator over contained (subtype) types.

Enums

NameDescription
TypeID Identifiers for all base types in the LLVM type system.

Member Functions

NameDescription
canLosslesslyBitCastTo Return true if this type could be converted with a lossless BitCast to Ty.
containsNonGlobalTargetExtType Return true if this type is or contains a target extension type that disallows being used as a global.
containsNonLocalTargetExtType Return true if this type is or contains a target extension type that disallows being used as a local.
dump Dump this type to stderr for debugging.
getArrayElementType Return the element type of this array type.
getArrayNumElements Return the number of elements in this array type.
getByteBitWidth Return the bit width of this byte type (or of its scalar element).
getContainedType Return the type contained at index i in this derived type.
getContext Return the LLVMContext in which this type was uniqued.
getExtendedType Given scalar/vector integer type, returns a type with elements twice as wide as in the original type. For vectors, preserves element count.
getFPMantissaWidth Return the width of the mantissa of this floating-point type.
getFltSemantics Return the floating-point semantics for this floating-point type.
getFunctionNumParams Return the number of fixed parameters of this function type.
getFunctionParamType Return the type of formal parameter i of this function type.
getIntegerBitWidth Return the bit width of this integer type.
getNumContainedTypes Return the number of types in the derived type.
getPointerAddressSpace Get the address space of this pointer or pointer vector type.
getPrimitiveSizeInBits Return the basic size of this type if it is a primitive type.
getScalarSizeInBits If this is a vector type, return the getPrimitiveSizeInBits value for the element type. Otherwise return the getPrimitiveSizeInBits value for this type.
getScalarType If this is a vector type, return the element type, otherwise return 'this'.
getStructElementType Return the type of element N in this struct type.
getStructName Return the name of this identified struct type.
getStructNumElements Return the number of elements in this struct type.
getTargetExtName Return the name of this target extension type.
getTruncatedType Given scalar/vector integer type, returns a type with elements half as wide as in the original type. For vectors, preserves element count.
getTypeID Return the type id for the type. This will return one of the TypeID enum elements defined above.
getWithNewBitWidth Given an integer or vector type, change the lane bitwidth to NewBitwidth, whilst keeping the old number of lanes.
getWithNewType Given vector type, change the element type, whilst keeping the old number of elements. For non-vectors simply returns EltTy.
is16bitFPTy Return true if this is a 16-bit float type.
isAggregateType Return true if the type is an aggregate type.
isArrayTy True if this is an instance of ArrayType.
isBFloatTy Return true if this is 'bfloat', a 16-bit bfloat type.
isByteOrByteVectorTy isByteOrByteVectorTy overloads
isByteTy isByteTy overloads
isDoubleTy Return true if this is 'double', a 64-bit IEEE fp type.
isEmptyTy Return true if this type is empty, that is, it has no elements or all of its elements are empty.
isFP128Ty Return true if this is 'fp128'.
isFPOrFPVectorTy Return true if this is a FP type or a vector of FP.
isFirstClassType Return true if the type is "first class", meaning it is a valid type for a Value.
isFloatTy Return true if this is 'float', a 32-bit IEEE fp type.
isFloatingPointTy Return true if this is one of the floating-point types.
isFunctionTy True if this is an instance of FunctionType.
isFunctionVarArg Return true if this function type is variadic.
isHalfTy Return true if this is 'half', a 16-bit IEEE fp type.
isIEEELikeFPTy Return true if this is a well-behaved IEEE-like type, which has a IEEE compatible layout, and does not have non-IEEE values, such as x86_fp80's unnormal values.
isIntOrIntVectorTy isIntOrIntVectorTy overloads
isIntOrPtrTy Return true if this is an integer type or a pointer type.
isIntegerTy isIntegerTy overloads
isLabelTy Return true if this is 'label'.
isMetadataTy Return true if this is 'metadata'.
isMultiUnitFPType Return true if this is a multi-unit floating-point type.
isPPC_FP128Ty Return true if this is powerpc long double.
isPointerTy True if this is an instance of PointerType.
isPtrOrPtrVectorTy Return true if this is a pointer type or a vector of pointer types.
isRISCVVectorTupleTy True if this is an instance of TargetExtType of RISC-V vector tuple.
isScalableTargetExtTy Return true if this is a target extension type with a scalable layout.
isScalableTy isScalableTy overloads
isSingleValueType 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.
isSized Return true if it makes sense to take the size of this type.
isStructTy True if this is an instance of StructType.
isTargetExtTy Return true if this is a target extension type.
isTokenLikeTy Returns true if this is 'token' or a token-like target type.s
isTokenTy Return true if this is 'token'.
isVectorTy True if this is an instance of VectorType.
isVoidTy Return true if this is 'void'.
isX86_AMXTy Return true if this is X86 AMX.
isX86_FP80Ty Return true if this is x86 long double.
print Print the current type.
subtype_begin Iterator to the first contained (subtype) type.
subtype_end Iterator past the last contained (subtype) type.
subtype_rbegin Reverse iterator to the last contained (subtype) type.
subtype_rend Reverse iterator past the first contained (subtype) type.
subtypes Return an array view of this type's contained subtypes.

Static Member Functions

NameDescription
getBFloatTy Return the bfloat (16-bit) floating-point type.
getByte128Ty Return the 128-bit byte type.
getByte16Ty Return the 16-bit byte type for the given context.
getByte1Ty Return the 1-bit byte type.
getByte32Ty Return the 32-bit byte type for the given context.
getByte64Ty Return the 64-bit byte type.
getByte8Ty Return the 8-bit byte type.
getByteFromIntType Returns a byte (vector of byte) type with the same size of an integer of the given integer (vector of integer) type.
getByteNTy Return a byte type with bit width N.
getDoubleTy Return the IEEE double-precision (64-bit) floating-point type.
getFP128Ty Return the 128-bit IEEE floating-point type (fp128).
getFloatTy Return the IEEE single-precision (32-bit) floating-point type.
getFloatingPointTy Return the floating-point type matching semantics S.
getHalfTy Return the IEEE half-precision (16-bit) floating-point type.
getInt128Ty Return the 128-bit integer type.
getInt16Ty Return the 16-bit integer type.
getInt1Ty Return the 1-bit integer type.
getInt32Ty Return the 32-bit integer type.
getInt64Ty Return the 64-bit integer type.
getInt8Ty Return the 8-bit integer type.
getIntFromByteType Returns an integer (vector of integer) type with the same size of a byte of the given byte (vector of byte) type.
getIntNTy Return an integer type with bit width N.
getLabelTy Return the label type.
getMetadataTy Return the metadata type used for metadata operands in the IR.
getPPC_FP128Ty Return the PowerPC double-double (ppc_fp128) floating-point type.
getPrimitiveType Return a type based on an identifier.
getScalarTy Return the LLVM scalar type corresponding to a C++ scalar type ScalarTy.
getTokenTy Return the token type.
getVoidTy Return the void type.
getWasm_ExternrefTy Return the WebAssembly externref target-extension type.
getWasm_FuncrefTy Return the WebAssembly funcref target-extension type.
getX86_AMXTy Return the X86 AMX type for the given context.
getX86_FP80Ty Return the x86 80-bit extended-precision floating-point type.

Protected Member Functions

NameDescription
Type [constructor]Construct a uniqued primitive or placeholder type with id tid in C.
~Type [destructor]Destroy this type; types are never freed in practice.
getSubclassData Return the subclass-specific data packed into this type.
setSubclassData Store subclass-specific data into this type's SubclassData field.

Protected Data Members

NameDescription
ContainedTys Pointer to the array of Types contained by this Type.
NumContainedTys Keeps track of how many Type*'s there are in the ContainedTys list.

Friends

NameDescription
llvm::LLVMContextImplPrivate implementation details of LLVMContext.

Non-Member Functions

NameDescription
ComputeLinearIndexCompute the linearized index of a member in a nested aggregate.
ComputeLinearIndexCompute the linearized index of a member in a nested aggregate/struct/array.
ConstantFoldGetElementPtrAttempt to constant fold a getelementptr instruction with the specified operands.
canVectorizeTyReturns true if Ty can be used as a vector element or vectorized struct.
checkGEPTypeReturn Ty after asserting it is a valid GEP index result type.
gep_type_beginReturn a begin iterator over GEP indices from type Op0 and operands A.
gep_type_endReturn an end iterator for GEP indices from operands A.
getContainedTypesReturns the types contained in Ty. For struct types, it returns the elements, all other types are returned directly.
getLLTForTypeConstruct a low-level type based on an LLVM type.
getLoadStoreTypeReturn the value type accessed by load or store instruction I.
getPointersDiffReturns the distance between compatible pointers PtrA and PtrB.
getTypeForLLTGet the type back from LLT. It won't be 100 percent accurate but returns an estimate of the type.
getVectorizedTypeVFReturns the number of vector elements for a vectorized type.
isVectorizedTyReturns true if Ty is a vector type or a struct of vector types where all vector types share the same VF.
parseTypeParse a type in the given string.
parseTypeAtBeginningParse a type at the beginning of the given string.
simplifyGEPInstGiven operands for a GetElementPtrInst, fold the result or return null.
toScalarizedStructTyConvert a struct of vector types to a struct of scalar types.
toScalarizedTyConvert a vectorized type to its scalarized (non-vector) form.
toVectorTyConvert a scalar type to a vector type.
toVectorTyConvert a scalar type to a fixed-length vector type.
toVectorizedStructTyConvert a struct of scalar types to a struct of vector types.
toVectorizedTyConvert a scalar or struct type to its vectorized form.
unwrapUnwrap an array of opaque LLVMTypeRef values as Type pointers.
unwrapC API conversion helpers for Type / LLVMTypeRef, including typed unwrap.
wrapC API conversion helpers for Type / LLVMTypeRef, including typed unwrap.
wrapWrap an array of Type pointers for the C API.
AttributeFuncs::isNoFPClassCompatibleTypeReturns true if this is a type legal for the 'nofpclass' attribute. This follows the same type rules as FPMathOperator.
AttributeFuncs::typeIncompatibleReturn the mask of attributes incompatible with type Ty.
PatternMatch::m_SpecificTypeMatch a value of a specific type, capturing it if we match.
PatternMatch::m_SpecificTypeMatch any value of a specific type.
PatternMatch::m_SpecificTypeMatch a const value of a specific type, capturing it if we match.
PatternMatch::m_SpecificTypeMatch a value of a specific type.
VNCoercion::analyzeLoadFromClobberingLoadThis function determines whether a value for the pointer LoadPtr can be extracted from the load at DepLI.
VNCoercion::analyzeLoadFromClobberingMemInstThis function determines whether a value for the pointer LoadPtr can be extracted from the memory intrinsic at DepMI.
VNCoercion::analyzeLoadFromClobberingStoreThis function determines whether a value for the pointer LoadPtr can be extracted from the store at DepSI.
fuzzerop::makeConstantsWithTypePopulate a small list of potentially interesting constants of a given type.
fuzzerop::makeConstantsWithTypeReturn a small list of potentially interesting constants of a given type.
hlsl::getDXILElementTypeConverts a scalar or vector LLVM type to its DXIL element type.

Derived Classes

NameDescription
ArrayType Class to represent array types.
ByteType Class to represent byte types.
FunctionType Class to represent function types.
IntegerType Class to represent integer types.
PointerType Class to represent pointers.
StructType Class to represent struct types. There are two different kinds of struct types: Literal structs and Identified structs.
TargetExtType Class to represent target extensions types, which are generally unintrospectable from target-independent optimizations.
TypedPointerType A typed pointer type used by some GPU targets.
VectorType Base class of all SIMD vector types