Constant

public struct Constant<Repr> : IRConstant where Repr : ConstantRepresentation

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.

Constants keep track of the values they represent at the type level to disallow mixed-type arithmetic. Use the cast family of operations to safely convert constants to other representations.

  • Retrieves the underlying LLVM constant object.

    Declaration

    Swift

    public func asLLVM() -> LLVMValueRef

Negation

  • Creates a constant negate operation to negate a value.

    Declaration

    Swift

    public static func negate(_ lhs: Constant<Signed>, overflowBehavior: OverflowBehavior = .default) -> Constant<Signed>

    Parameters

    lhs

    The operand to negate.

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the negation of the given constant.

  • Creates a constant negate operation to negate a value.

    Declaration

    Swift

    public static func negate(_ lhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The operand to negate.

    Return Value

    A constant value representing the negation of the given constant.

Addition

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func add(_ lhs: Constant<Unsigned>, _ rhs: Constant<Unsigned>, overflowBehavior: OverflowBehavior = .default) -> Constant<Unsigned>

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the sum of the two operands.

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func add(_ lhs: Constant<Signed>, _ rhs: Constant<Signed>, overflowBehavior: OverflowBehavior = .default) -> Constant<Signed>

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the sum of the two operands.

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func add(_ lhs: Constant<Floating>, _ rhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    Return Value

    A constant value representing the sum of the two operands.

Subtraction

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func subtract(_ lhs: Constant<Unsigned>, _ rhs: Constant<Unsigned>, overflowBehavior: OverflowBehavior = .default) -> Constant<Unsigned>

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the difference of the two operands.

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func subtract(_ lhs: Constant<Signed>, _ rhs: Constant<Signed>, overflowBehavior: OverflowBehavior = .default) -> Constant<Signed>

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the difference of the two operands.

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func subtract(_ lhs: Constant<Floating>, _ rhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    Return Value

    A constant value representing the difference of the two operands.

Multiplication

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func multiply(_ lhs: Constant<Unsigned>, _ rhs: Constant<Unsigned>, overflowBehavior: OverflowBehavior = .default) -> Constant<Unsigned>

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the product of the two operands.

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func multiply(_ lhs: Constant<Signed>, _ rhs: Constant<Signed>, overflowBehavior: OverflowBehavior = .default) -> Constant<Signed>

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the product of the two operands.

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func multiply(_ lhs: Constant<Floating>, _ rhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    Return Value

    A constant value representing the product of the two operands.

Divide

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func divide(_ lhs: Constant<Unsigned>, _ rhs: Constant<Unsigned>) -> Constant<Unsigned>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func divide(_ lhs: Constant<Signed>, _ rhs: Constant<Signed>) -> Constant<Signed>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func divide(_ lhs: Constant<Floating>, _ rhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

Remainder

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func remainder(_ lhs: Constant<Unsigned>, _ rhs: Constant<Unsigned>) -> Constant<Unsigned>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func remainder(_ lhs: Constant<Signed>, _ rhs: Constant<Signed>) -> Constant<Signed>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func remainder(_ lhs: Constant<Floating>, _ rhs: Constant<Floating>) -> Constant<Floating>

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

Logical Operations

  • A constant bitwise logical not with the given integral value as an operand.

    Declaration

    Swift

    public static func not<T>(_ lhs: Constant<T>) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    val

    The value to negate.

    Return Value

    A constant value representing the logical negation of the given operand.

  • A constant bitwise logical AND with the given values as operands.

    Declaration

    Swift

    public static func and<T>(_ lhs: Constant<T>, _ rhs: Constant<T>) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    name

    The name for the newly inserted instruction.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant bitwise logical OR with the given values as operands.

    Declaration

    Swift

    public static func or<T>(_ lhs: Constant<T>, _ rhs: Constant<T>) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    name

    The name for the newly inserted instruction.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant bitwise logical exclusive OR with the given values as operands.

    Declaration

    Swift

    public static func xor<T>(_ lhs: Constant<T>, _ rhs: Constant<T>) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the exclusive OR of the values of the two given operands.

Bitshifting Operations

  • A constant left-shift of the first value by the second amount.

    Declaration

    Swift

    public static func leftShift<T>(_ lhs: Constant<T>, _ rhs: Constant<T>) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

  • A constant right-shift of the first value by the second amount.

    Declaration

    Swift

    public static func rightShift<T>(_ lhs: Constant<T>, _ rhs: Constant<T>, arithmetic: Bool = true) -> Constant<T> where T : IntegralConstantRepresentation

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    arithmetic

    Should the shift be arithmetic or logical (defaults to true)

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

Conditional Operations

  • A constant select using the given condition to select among two values.

    Declaration

    Swift

    public static func select<T, U>(_ cond: Constant<T>, then: Constant<U>, else: Constant<U>) -> Constant<U> where T : IntegralConstantRepresentation, U : ConstantRepresentation

    Parameters

    cond

    The condition to evaluate. It must have type i1 or be a vector of i1.

    then

    The value to select if the given condition is true.

    else

    The value to select if the given condition is false.

    Return Value

    A constant value representing the constant value selected for by the condition.

Available where Repr: IntegralConstantRepresentation

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Signed>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Unsigned>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

Available where Repr == Unsigned

  • Creates a constant cast to a given floating type.

    Declaration

    Swift

    public func cast(to type: FloatType) -> Constant<Floating>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given floating type.

Available where Repr == Signed

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Signed>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Unsigned>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

  • Creates a constant cast to a given floating type.

    Declaration

    Swift

    public func cast(to type: FloatType) -> Constant<Floating>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given floating type.

Available where Repr == Floating

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Signed>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

  • Creates a constant cast to a given integral type.

    Declaration

    Swift

    public func cast(to type: IntType) -> Constant<Unsigned>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given integral type.

  • Creates a constant cast to a given floating type.

    Declaration

    Swift

    public func cast(to type: FloatType) -> Constant<Floating>

    Parameters

    type

    The type to cast towards.

    Return Value

    A const value representing this value cast to the given floating type.

Available where Repr == Signed

  • Creates a constant truncated to a given integral type.

    Declaration

    Swift

    public func truncate(to type: IntType) -> Constant<Signed>

    Parameters

    type

    The type to truncate towards.

    Return Value

    A const value representing this value truncated to the given integral type’s bitwidth.

Available where Repr == Unsigned

  • Creates a constant truncated to a given integral type.

    Declaration

    Swift

    public func truncate(to type: IntType) -> Constant<Unsigned>

    Parameters

    type

    The type to truncate towards.

    Return Value

    A const value representing this value truncated to the given integral type’s bitwidth.

Available where Repr == Floating

  • Creates a constant truncated to a given floating type.

    Declaration

    Swift

    public func truncate(to type: FloatType) -> Constant<Floating>

    Parameters

    type

    The type to truncate towards.

    Return Value

    A const value representing this value truncated to the given floating type’s bitwidth.

  • Creates a constant extended to a given floating type.

    Declaration

    Swift

    public func extend(to type: FloatType) -> Constant<Floating>

    Parameters

    type

    The type to extend towards.

    Return Value

    A const value representing this value extended to the given floating type’s bitwidth.

Available where Repr == Signed

  • Creates a constant negate operation to negate a value.

    Declaration

    Swift

    public func negate() -> Constant

    Return Value

    A constant value representing the negation of the given constant.

Available where Repr == Floating

  • Creates a constant negate operation to negate a value.

    Declaration

    Swift

    public func negate() -> Constant

    Return Value

    A constant value representing the negation of the given constant.

Available where Repr == Signed

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public func adding(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second summand value (the addend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the sum of the two operands.

Available where Repr == Unsigned

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public func adding(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second summand value (the addend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the sum of the two operands.

Available where Repr == Floating

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public func adding(_ rhs: Constant) -> Constant

    Parameters

    rhs

    The second summand value (the addend).

    Return Value

    A constant value representing the sum of the two operands.

Available where Repr == Unsigned

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public func subtracting(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second value (the subtrahend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the difference of the two operands.

Available where Repr == Signed

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public func subtracting(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second value (the subtrahend).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the difference of the two operands.

Available where Repr == Floating

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public func subtracting(_ rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the subtrahend).

    Return Value

    A constant value representing the difference of the two operands.

Available where Repr == Unsigned

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public func multiplying(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second factor value (the multiplicand).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the product of the two operands.

Available where Repr == Signed

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public func multiplying(_ rhs: Constant, overflowBehavior: OverflowBehavior = .default) -> Constant

    Parameters

    rhs

    The second factor value (the multiplicand).

    overflowBehavior

    Should overflow occur, specifies the behavior of the resulting constant value.

    Return Value

    A constant value representing the product of the two operands.

Available where Repr == Floating

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public func multiplying(_ rhs: Constant) -> Constant

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    Return Value

    A constant value representing the product of the two operands.

Available where Repr == Unsigned

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func dividing(by rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

Available where Repr == Signed

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func dividing(by rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

Available where Repr == Floating

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func dividing(by rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

Available where Repr == Unsigned

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func remainder(_ rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

Available where Repr == Signed

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func remainder(_ rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

Available where Repr == Floating

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public func remainder(_ rhs: Constant) -> Constant

    Parameters

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

Available where Repr: IntegralConstantRepresentation

  • A constant equality comparison between two values.

    Declaration

    Swift

    public static func equals(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

Available where Repr == Signed

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func lessThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func greaterThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func lessThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func greaterThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

Available where Repr == Unsigned

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func lessThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func greaterThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func lessThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func greaterThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

Available where Repr == Floating

  • A constant equality comparison between two values.

    Declaration

    Swift

    public static func equals(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func lessThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func greaterThan(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func lessThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func greaterThanOrEqual(_ lhs: Constant, _ rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

Available where Repr: IntegralConstantRepresentation

  • Creates a constant pointer-to-integer operation to convert the given constant global pointer value to the given integer type.

    Declaration

    Swift

    public static func pointerToInt(_ val: IRConstant, _ intType: IntType) -> Constant

    Parameters

    val

    The pointer value.

    intType

    The destination integer type.

    Return Value

    An constant value representing the constant value of the given pointer converted to the given integer type.

Available where Repr == Struct

  • Creates a constant operation retrieving the element at the index.

    Declaration

    Swift

    public func getElement(indices: [Int]) -> IRConstant

    Parameters

    indices

    A list of indices that indicate which of the elements of the aggregate object are indexed.

    Return Value

    The value in the struct at the provided index.

  • Build a constant GEP (Get Element Pointer) instruction with a resultant value that is undefined if the address is outside the actual underlying allocated object and not the address one-past-the-end.

    The GEP instruction is often the source of confusion. LLVM provides a document to answer questions around its semantics and correct usage.

    Declaration

    Swift

    public func getElementPointer(indices: [IRConstant]) -> IRConstant

    Parameters

    indices

    A list of indices that indicate which of the elements of the aggregate object are indexed.

    Return Value

    A value representing the address of a subelement of the given aggregate data structure value.

  • Build a GEP (Get Element Pointer) instruction.

    The GEP instruction is often the source of confusion. LLVM provides a document to answer questions around its semantics and correct usage.

    Declaration

    Swift

    public func inBoundsGetElementPointer(indices: [IRConstant]) -> IRConstant

    Parameters

    indices

    A list of indices that indicate which of the elements of the aggregate object are indexed.

    Return Value

    A value representing the address of a subelement of the given aggregate data structure value.

Available where Repr == Vector

  • Builds a constant operation to construct a permutation of elements from the two given input vectors, returning a vector with the same element type as the inputs and length that is the same as the shuffle mask.

    Declaration

    Swift

    public static func buildShuffleVector(_ vector1: Constant, and vector2: Constant, mask: Constant) -> Constant

    Parameters

    vector1

    The first constant vector to shuffle.

    vector2

    The second constant vector to shuffle.

    mask

    A constant vector of i32 values that acts as a mask for the shuffled vectors.

    Return Value

    A value representing a constant vector with the same element type as the inputs and length that is the same as the shuffle mask.

Available where Repr == Floating

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func + (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    Return Value

    A constant value representing the sum of the two operands.

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func - (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    Return Value

    A constant value representing the difference of the two operands.

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func * (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    Return Value

    A constant value representing the product of the two operands.

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func / (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func % (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

  • A constant equality comparison between two values.

    Declaration

    Swift

    public static func == (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func < (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func > (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func <= (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func >= (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

Available where Repr == Signed

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func + (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    Return Value

    A constant value representing the sum of the two operands.

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func - (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    Return Value

    A constant value representing the difference of the two operands.

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func * (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    Return Value

    A constant value representing the product of the two operands.

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func / (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func % (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

  • A constant equality comparison between two values.

    Declaration

    Swift

    public static func == (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func < (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func > (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func <= (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func >= (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant bitwise logical OR with the given values as operands.

    Declaration

    Swift

    public static func | (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant bitwise logical AND with the given values as operands.

    Declaration

    Swift

    public static func & (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant left-shift of the first value by the second amount.

    Declaration

    Swift

    public static func << (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

  • A constant right-shift of the first value by the second amount.

    Declaration

    Swift

    public static func >> (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

Available where Repr == Unsigned

  • Creates a constant add operation to add two homogenous constants together.

    Declaration

    Swift

    public static func + (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first summand value (the augend).

    rhs

    The second summand value (the addend).

    Return Value

    A constant value representing the sum of the two operands.

  • Creates a constant sub operation to subtract two homogenous constants.

    Declaration

    Swift

    public static func - (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the minuend).

    rhs

    The second value (the subtrahend).

    Return Value

    A constant value representing the difference of the two operands.

  • Creates a constant multiply operation with the given values as operands.

    Declaration

    Swift

    public static func * (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first factor value (the multiplier).

    rhs

    The second factor value (the multiplicand).

    Return Value

    A constant value representing the product of the two operands.

  • A constant divide operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func / (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the quotient of the first and second operands.

  • A constant remainder operation that provides the remainder after divison of the first value by the second value.

    Declaration

    Swift

    public static func % (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first value (the dividend).

    rhs

    The second value (the divisor).

    Return Value

    A constant value representing the remainder of division of the first operand by the second operand.

  • A constant equality comparison between two values.

    Declaration

    Swift

    public static func == (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than comparison between two values.

    Declaration

    Swift

    public static func < (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than comparison between two values.

    Declaration

    Swift

    public static func > (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant less-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func <= (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant greater-than-or-equal comparison between two values.

    Declaration

    Swift

    public static func >= (lhs: Constant, rhs: Constant) -> Constant<Signed>

    Parameters

    lhs

    The first value to compare.

    rhs

    The second value to compare.

    Return Value

    A constant integral value (i1) representing the result of the comparision of the given operands.

  • A constant bitwise logical OR with the given values as operands.

    Declaration

    Swift

    public static func | (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant bitwise logical AND with the given values as operands.

    Declaration

    Swift

    public static func & (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the logical OR of the values of the two given operands.

  • A constant left-shift of the first value by the second amount.

    Declaration

    Swift

    public static func << (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

  • A constant right-shift of the first value by the second amount.

    Declaration

    Swift

    public static func >> (lhs: Constant, rhs: Constant) -> Constant

    Parameters

    lhs

    The first operand.

    rhs

    The second operand.

    Return Value

    A constant value representing the value of the first operand shifted left by the number of bits specified in the second operand.

Available where Repr: IntegralConstantRepresentation

  • A constant bitwise logical not with the given integral value as an operand.

    Declaration

    Swift

    public prefix static func ! (lhs: Constant) -> Constant

    Parameters

    val

    The value to negate.

    Return Value

    A constant value representing the logical negation of the given operand.

  • Returns the special LLVM undef value for this type.

    The undef value can be used anywhere a constant is expected, and indicates that the user of the value may receive an unspecified bit-pattern.

    Declaration

    Swift

    public static func `undef`(_ ty: IntType) -> Constant

Available where Repr == Floating

  • Returns the special LLVM undef value for this type.

    The undef value can be used anywhere a constant is expected, and indicates that the user of the value may receive an unspecified bit-pattern.

    Declaration

    Swift

    public static func `undef`(_ ty: FloatType) -> Constant

Available where Repr == Struct

  • Returns the special LLVM undef value for this type.

    The undef value can be used anywhere a constant is expected, and indicates that the user of the value may receive an unspecified bit-pattern.

    Declaration

    Swift

    public static func `undef`(_ ty: StructType) -> Constant

Available where Repr == Vector

  • Returns the special LLVM undef value for this type.

    The undef value can be used anywhere a constant is expected, and indicates that the user of the value may receive an unspecified bit-pattern.

    Declaration

    Swift

    public static func `undef`(_ ty: VectorType) -> Constant