Types

LLVM IR is a strong, statically typed language. As such, values and functions are tagged with their types, and conversions between them must be explicit (see Conversion Operators). LLVMSwift represents this with values conforming to the IRType protocol and defines the following types:

Type

Represents

VoidType

Nothing; Has no size

IntType

Integer and Boolean values (i1)

FloatType

Floating-point values

FunctionType

Function values

LabelType

Code labels

TokenType

Values paired with instructions

MetadataType

Embedded metadata

X86MMXType

X86 MMX values

PointerType

Pointer values

VectorType

SIMD data

ArrayType

Homogeneous values

Structure Type

Heterogeneous values

Control Flow

Control flow is changed through the unconditional and conditional br instruction.

LLVM is also famous for a control-flow specific IR construct called 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, let's try to build the following Swift program in IR: