Structures
The following structures are available globally.
-
A
BasicBlock
represents a basic block in an LLVM IR program. A basic block contains a sequence of instructions, a pointer to its parent block and its follower block, and an optional label that gives the basic block an entry in the symbol table.A basic block can be thought of as a sequence of instructions, and indeed its member instructions may be iterated over with a
for-in
loop.The first basic block in a function is special in two ways: it is immediately executed on entrance to the function, and it is not allowed to have predecessor basic blocks (i.e. there can not be any branches to the entry block of a function). Because the block can have no predecessors, it also cannot have any PHI nodes.
See moreDeclaration
Swift
public struct BasicBlock : IRValue
-
A
Constant
represents a value initialized to a constant. Constant values may be manipulated with standard Swift arithmetic operations and used with standard IR Builder instructions like any other operand. The difference being any instructions acting solely on constants and any arithmetic performed on constants is evaluated at compile-time only.
See moreConstant
s keep track of the values they represent at the type level to disallow mixed-type arithmetic. Use thecast
family of operations to safely convert constants to other representations.Declaration
Swift
public struct Constant<Repr> : IRConstant where Repr : ConstantRepresentation
-
See moreFunctionType
represents a function’s type signature. It consists of a return type and a list of formal parameter types. The return type of a function type is avoid
type or first class type — except forLabelType
andMetadataType
.Declaration
Swift
public struct FunctionType : IRType
-
A
See moreTerminatorInstruction
represents an instruction that terminates a basic block.Declaration
Swift
public struct TerminatorInstruction
-
The
IntType
represents an integral value of a specified bit width.The
See moreIntType
is a very simple type that simply specifies an arbitrary bit width for the integer type desired. Any bit width from 1 bit to (2^23)-1 (about 8 million) can be specified.Declaration
Swift
public struct IntType : IRType
-
CompileUnitMetadata
nodes represent a compile unit, the root of a metadata hierarchy for a translation unit.Compile unit descriptors provide the root scope for objects declared in a specific compilation unit.
FileMetadata
descriptors are defined using this scope.These descriptors are collected by a named metadata node
See more!llvm.dbg.cu
. They keep track of global variables, type information, and imported entities (declarations and namespaces).Declaration
Swift
public struct CompileUnitMetadata : DIScope
-
DIBasicType
nodes represent primitive types, such asint
,bool
andfloat
.Basic types carry an encoding describing the details of the type to influence how it is presented in debuggers. LLVM currently supports specific DWARF
See moreAttribute Type Encodings
that are enumerated inDIAttributeTypeEncoding
.Declaration
Swift
public struct DIBasicType : DIType
-
DISubroutineType
nodes represent subroutine types.Subroutine types are meant to mirror their formal declarations in source: arguments are represented in order. The return type is optional and meant to represent the concept of
See morevoid
in C-like languages.Declaration
Swift
public struct DISubroutineType : DIType
-
LexicalBlockMetadata
nodes describe nested blocks within a subprogram. The line number and column numbers are used to distinguish two lexical blocks at same depth.Usually lexical blocks are distinct to prevent node merging based on operands.
See moreDeclaration
Swift
public struct LexicalBlockMetadata : DIScope
-
See moreLexicalBlockFile
nodes are used to discriminate between sections of a lexical block. The file field can be changed to indicate textual inclusion, or the discriminator field can be used to discriminate between control flow within a single block in the source language.Declaration
Swift
public struct LexicalBlockFileMetadata : DIScope
-
See moreNameSpaceMetadata
nodes represent subroutines in the source program. They are attached to corresponding LLVM IR functions.Declaration
Swift
public struct FunctionMetadata : DIScope
-
See moreNameSpaceMetadata
nodes represent entities like C++ modules.Declaration
Swift
public struct ModuleMetadata : DIScope
-
ExpressionMetadata
nodes represent expressions that are inspired by the DWARF expression language. They are used in debug intrinsics (such as llvm.dbg.declare and llvm.dbg.value) to describe how the referenced LLVM variable relates to the source language variable.Debug intrinsics are interpreted left-to-right: start by pushing the value/address operand of the intrinsic onto a stack, then repeatedly push and evaluate opcodes from the
ExpressionMetadata
until the final variable description is produced.Though DWARF supports hundreds of expressions, LLVM currently implements a very limited subset.
See moreDeclaration
Swift
public struct ExpressionMetadata : Metadata
-
Enumerates the known attributes that can appear on an Objective-C property.
See moreDeclaration
Swift
public struct ObjectiveCPropertyAttribute : OptionSet
-
Enumerates a set of flags that can be applied to metadata nodes to change their interpretation at compile time or attach additional semantic significance at runtime.
See moreDeclaration
Swift
public struct DIFlags : OptionSet
-
A Section represents one of the binary sections in an object file.
See moreDeclaration
Swift
public struct Section
-
A symbol is a top-level addressable entity in an object file.
See moreDeclaration
Swift
public struct Symbol
-
A Relocation represents the contents of a relocated symbol in the dynamic linker.
See moreDeclaration
Swift
public struct Relocation
-
A
PhiNode
object represents a PHI node.Because all instructions in LLVM IR are in SSA (Single Static Assignment) form, a PHI node is necessary when the value of a variable assignment depends on the path the flow of control takes through the program. For example:
var a = 1 if c == 42 { a = 2 } let b = a
The value of
b
in this program depends on the value of the condition involving the variablec
. Becauseb
must be assigned to once, a PHI node is created and the program effectively is transformed into the following:let aNoCond = 1 if c == 42 { let aCondTrue = 2 } let b = PHI(aNoCond, aCondTrue)
If the flow of control reaches
See moreaCondTrue
, the value ofb
is2
, else it is1
and SSA semantics are preserved.Declaration
Swift
public struct PhiNode : IRValue
-
PointerType
is used to specify memory locations. Pointers are commonly used to reference objects in memory.PointerType
may have an optional address space attribute defining the numbered address space where the pointed-to object resides. The default address space is number zero. The semantics of non-zero address spaces are target-specific.Note that LLVM does not permit pointers to void
See more(void*)
nor does it permit pointers to labels(label*)
. Usei8*
instead.Declaration
Swift
public struct PointerType : IRType
-
StructType
is used to represent a collection of data members together in memory. The elements of a structure may be any type that has a size.Structures in memory are accessed using
load
andstore
by getting a pointer to a field with the ‘getelementptr‘ instruction. Structures in registers are accessed using theextractvalue
andinsertvalue
instructions.Structures may optionally be
packed
structures, which indicate that the alignment of the struct is one byte, and that there is no padding between the elements. In non-packed structs, padding between field types is inserted as defined by theDataLayout
of the module, which is required to match what the underlying code generator expects.Structures can either be
See moreliteral
oridentified
. A literal structure is defined inline with other types (e.g. {i32, i32}*) whereas identified types are always defined at the top level with a name. Literal types are uniqued by their contents and can never be recursive or opaque since there is no way to write one. Identified types can be recursive, can be opaqued, and are never uniqued.Declaration
Swift
public struct StructType : IRType
-
A
See moreSwitch
represents aswitch
instruction. Aswitch
instruction defines a jump table of values and destination basic blocks to pass the flow of control to if a condition value matches. If no match is made, control flow passes to the default basic block.Declaration
Swift
public struct Switch : IRValue
-
A
See moreStructLayout
encapsulates information about the layout of aStructType
.Declaration
Swift
public struct StructLayout
-
An alignment value, expressed in bytes.
See moreDeclaration
Swift
public struct Alignment : Comparable, Hashable
-
This is an opaque type for sizes expressed in aggregate bit units, usually 8 bits per unit.
Instances of this type represent a quantity as a multiple of a radix size
- e.g. the size of a
char
in bits on the target architecture. As an opaque type,Size
protects you from accidentally combining operations on quantities in bit units and size units.
For portability, never assume that a target radix is 8 bits wide. Use Size values wherever you calculate sizes and offsets.
See moreDeclaration
Swift
public struct Size
- e.g. the size of a
-
See moreUse
represents an iterator over the uses and users of a particular value in an LLVM program.Declaration
Swift
public struct Use
-
A
See moreVectorType
is a simple derived type that represents a vector of elements.VectorType
s are used when multiple primitive data are operated in parallel using a single instruction (SIMD). A vector type requires a size (number of elements) and an underlying primitive data type.Declaration
Swift
public struct VectorType : IRType
-
X86MMXType
represents a value held in an MMX register on an x86 machine.The operations allowed on it are quite limited: parameters and return values, load and store, and bitcast. User-specified MMX instructions are represented as intrinsic or asm calls with arguments and/or results of this type. There are no arrays, vectors or constants of this type.
See moreDeclaration
Swift
public struct X86MMXType : IRType