TargetData

public class TargetData

A TargetData encapsulates information about the data requirements of a particular target architecture and can be used to retrieve information about sizes and offsets of types with respect to this target.

  • Creates a Target Data object from an LLVMTargetDataRef object.

    Declaration

    Swift

    public init(llvm: LLVMTargetDataRef)
  • Declaration

    Swift

    public func offsetOfElement(at index: Int, type: StructType) -> Int

    Parameters

    type

    The type of the structure to compute the offset with.

    Return Value

    The offset of the given element within the structure.

  • Declaration

    Swift

    public func elementAtOffset(_ offset: Int, type: StructType) -> Int

    Parameters

    type

    The type of the structure to compute the offset with.

    Return Value

    The offset of the given element within the structure.

  • Computes the number of bits necessary to hold a value of the given type for this target environment.

    Declaration

    Swift

    public func sizeOfTypeInBits(_ type: IRType) -> Int

    Parameters

    type

    The type to compute the size of.

    Return Value

    The size of the type in bits.

  • The current platform byte order, either big or little endian.

    Declaration

    Swift

    public var byteOrder: ByteOrder { get }
  • Creates a string representation of the target data.

    Declaration

    Swift

    public var layoutString: String { get }
  • The integer type that is the same size as a pointer on this target. This is analoguous to the intptr_t type in C++.

    Declaration

    Swift

    public func intPointerType(context: Context? = nil, addressSpace: Int? = nil) -> IntType

    Parameters

    context

    The context in which to derive the type (optional).

    addressSpace

    The address space in which to derive the type.

    Return Value

    An IntegerType that is the same size as the pointer type on this target.

  • Computes the preferred alignment of the given global for this target

    Declaration

    Swift

    public func preferredAlignment(of global: Global) -> Alignment

    Parameters

    global

    The global variable

    Return Value

    The variable’s preferred alignment in this target

  • Computes the preferred alignment of the given type for this target

    Declaration

    Swift

    public func preferredAlignment(of type: IRType) -> Alignment

    Parameters

    type

    The type for which you’re computing the alignment

    Return Value

    The type’s preferred alignment in this target

  • Computes the minimum ABI-required alignment for the specified type.

    Declaration

    Swift

    public func abiAlignment(of type: IRType) -> Alignment

    Parameters

    type

    The type to whose ABI alignment you wish to compute.

    Return Value

    The minimum ABI-required alignment for the specified type.

  • Computes the minimum ABI-required alignment for the specified type.

    This function is equivalent to TargetData.abiAlignment(of:).

    Declaration

    Swift

    public func callFrameAlignment(of type: IRType) -> Alignment

    Parameters

    type

    The type to whose ABI alignment you wish to compute.

    Return Value

    The minimum ABI-required alignment for the specified type.

  • Computes the ABI size of a type in bytes for a target.

    Declaration

    Swift

    public func abiSize(of type: IRType) -> Size

    Parameters

    type

    The type to whose ABI size you wish to compute.

    Return Value

    The ABI size for the specified type.

  • Computes the maximum number of bytes that may be overwritten by storing the specified type.

    Declaration

    Swift

    public func storeSize(of type: IRType) -> Size

    Parameters

    type

    The type to whose store size you wish to compute.

    Return Value

    The store size of the type in the given target.

  • Computes the pointer size for the platform, optionally in a given address space.

    Declaration

    Swift

    public func pointerSize(addressSpace: Int? = nil) -> Size

    Parameters

    addressSpace

    The address space in which to compute pointer size.

    Return Value

    The size of a pointer in the target address space.

  • Returns the offset in bytes between successive objects of the specified type, including alignment padding.

    This is the amount that alloca reserves for this type. For example, returns 12 or 16 for x86_fp80, depending on alignment.

    Declaration

    Swift

    public func allocationSize(of type: IRType) -> Size

    Parameters

    type

    The type whose allocation size you wish to compute.

    Return Value

    The size an alloca would reserve for the given type.

  • Returns a StructLayout object containing the alignment of the struct, its size, and the offsets of its fields with respect to this data layout.

    Declaration

    Swift

    public func layout(of struct: StructType) -> StructLayout

    Parameters

    struct

    The struct type whose layout you wish to retrieve.

    Return Value

    A StructLayout describing the layout of the given type.

  • Returns the next integer (mod 2**64) that is greater than or equal to \p Value and is a multiple of \p Align. \p Align must be non-zero.

    If non-zero \p Skew is specified, the return value will be a minimal integer that is greater than or equal to \p Value and equal to \p Align * N + \p Skew for some integer N. If \p Skew is larger than \p Align, its value is adjusted to ‘\p Skew mod \p Align’.

    Computes the next size value that is greater than or equal to the given value and is a multiple of the given alignment.

    If the skew value is non-zero, the return value will be the next size value that is greater than or equal to the given value multipled by the provided alignment with a skew value added

    Declaration

    Swift

    public static func align(_ value: Size, to align: Alignment, skew: Size = Size.zero) -> Size
  • Computes the preferred alignment of the given global for this target

    Declaration

    Swift

    @available(*, message: "Prefer the overload of prefferedAlignment(of:﹚ that returns an Alignment")
    public func preferredAlignment(of global: Global) -> Int

    Parameters

    global

    The global variable

    Return Value

    The variable’s preferred alignment in this target

  • Computes the preferred alignment of the given type for this target

    Declaration

    Swift

    @available(*, message: "Prefer the overload of prefferedAlignment(of:﹚ that returns an Alignment")
    public func preferredAlignment(of type: IRType) -> Int

    Parameters

    type

    The type for which you’re computing the alignment

    Return Value

    The type’s preferred alignment in this target

  • Computes the minimum ABI-required alignment for the specified type.

    Declaration

    Swift

    @available(*, message: "Prefer the overload of abiAlignment(of:﹚ that returns an Alignment")
    public func abiAlignment(of type: IRType) -> Int

    Parameters

    type

    The type to whose ABI alignment you wish to compute.

    Return Value

    The minimum ABI-required alignment for the specified type.

  • Computes the minimum ABI-required alignment for the specified type.

    This function is equivalent to TargetData.abiAlignment(of:).

    Declaration

    Swift

    @available(*, message: "Prefer the overload of callFrameAlignment(of:﹚ that returns an Alignment")
    public func callFrameAlignment(of type: IRType) -> Int

    Parameters

    type

    The type to whose ABI alignment you wish to compute.

    Return Value

    The minimum ABI-required alignment for the specified type.

  • Computes the ABI size of a type in bytes for a target.

    Declaration

    Swift

    @available(*, message: "Prefer the overload of abiSize(of:﹚ that returns a Size")
    public func abiSize(of type: IRType) -> Int

    Parameters

    type

    The type to whose ABI size you wish to compute.

    Return Value

    The ABI size for the specified type.

  • Computes the maximum number of bytes that may be overwritten by storing the specified type.

    Declaration

    Swift

    @available(*, message: "Prefer the overload of storeSize(of:﹚ that returns a Size")
    public func storeSize(of type: IRType) -> Int

    Parameters

    type

    The type to whose store size you wish to compute.

    Return Value

    The store size of the type in the given target.

  • Computes the pointer size for the platform, optionally in a given address space.

    Declaration

    Swift

    @available(*, message: "Prefer the overload of pointerSize(addressSpace:﹚ that returns a Size")
    public func pointerSize(addressSpace: Int? = nil) -> Int

    Parameters

    addressSpace

    The address space in which to compute pointer size.

    Return Value

    The size of a pointer in the target address space.