layout: page
title: Type (llvm.core)

llvm.core.Type

  • This will become a table of contents (this text will be scraped). {:toc}

Static Constructors

int(n)

Create an integer type of bit width n.

float()

Create a 32-bit floating point type.

double()

Create a 64-bit floating point type.

x86_fp80()

Create a 80-bit 80x87-style floating point type.

fp128()

Create a 128-bit floating point type (112-bit mantissa).

ppc_fp128()

Create a 128-bit float (two 64-bits).

function(ret, params, vararg=False)

Create a function type, having the return type ret (must be a Type), accepting the parameters params, where params is an iterable, that yields Type objects representing the type of each function argument in order. If vararg is True, function is variadic.

struct(eltys, name='')

Create an unpacked structure. eltys is an iterable, that yields Type objects representing the type of each element in order.

If name is evaulates True (not empty), create an identified structure; otherwise, create a literal structure by default.

packed_struct(eltys, name='')

Like struct(eltys), but creates a packed struct.

array(elty, count)

Creates an array type, holding count elements, each of type elty (which should be a Type).

pointer(pty, addrspc=0)

Create a pointer to type pty (which should be a Type). addrspc is an integer that represents the address space of the pointer (see LLVM docs or ask on llvm-dev for more info).

void()

Creates a void type. Used for function return types.

label()

Creates a label type.

opaque(name)

Opaque StructType, used for creating self-referencing types.

Properties

kind

[read-only]

A value (enum) representing the “type” of the object. It will be one of the following constants defined in llvm.core:

# Warning: do not rely on actual numerical
values! TYPE_VOID = 0 TYPE_FLOAT = 1 TYPE_DOUBLE = 2 TYPE_X86_FP80
= 3 TYPE_FP128 = 4 TYPE_PPC_FP128 = 5 TYPE_LABEL = 6 TYPE_INTEGER =
7 TYPE_FUNCTION = 8 TYPE_STRUCT = 9 TYPE_ARRAY = 10 TYPE_POINTER =
11 TYPE_OPAQUE = 12 TYPE_VECTOR = 13 TYPE_METADATA = 14 TYPE_UNION =
15

Example:

assert Type.int().kind == TYPE_INTEGER assert
Type.void().kind == TYPE_VOID

Automatically Generated Documentation

class llvm.core.Type(ptr)

Represents a type, like a 32-bit integer or an 80-bit x86 float.

Use one of the static methods to create an instance. Example: ty = Type.double()

static array(element_ty, count)

Create an array type.

Creates a type for an array of elements of type `element_ty’, having ‘count’ elements.

static double()

Create a 64-bit floating point type.

static float()

Create a 32-bit floating point type.

static fp128()

Create a 128-bit floating point type (with 112-bit mantissa).

static function(return_ty, param_tys, var_arg=False)

Create a function type.

Creates a function type that returns a value of type `return_ty’, takes arguments of types as given in the iterable `param_tys’. Set `var_arg’ to True (default is False) for a variadic function.

static int(bits=32)

Create an integer type having the given bit width.

kind
static label()

Create a label type.

static opaque(name)

Create a opaque StructType

static packed_struct(element_tys, name='')

Create a (packed) structure type.

Creates a structure type with elements of types as given in the iterable `element_tys’. This method creates a packed structure. For an unpacked one, use the struct() method.

If name is not ‘’, creates a identified type; otherwise, creates a literal type.

static pointer(pointee_ty, addr_space=0)

Create a pointer type.

Creates a pointer type, which can point to values of type `pointee_ty’, in the address space `addr_space’.

static ppc_fp128()

Create a 128-bit floating point type (two 64-bits).

static struct(element_tys, name='')

Create a (unpacked) structure type.

Creates a structure type with elements of types as given in the iterable `element_tys’. This method creates a unpacked structure. For a packed one, use the packed_struct() method.

If name is not ‘’, creates a identified type; otherwise, creates a literal type.

static vector(element_ty, count)

Create a vector type.

Creates a type for a vector of elements of type `element_ty’, having `count’ elements.

static void()

Create a void type.

Represents the `void’ type.

static x86_fp80()

Create a 80-bit x86 floating point type.