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)
-
Computes the byte offset of the indexed struct element for a target.
Declaration
Swift
public func offsetOfElement(at index: Int, type: StructType) -> Int
Parameters
element
The index of the element in the given structure to compute.
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 = .global, addressSpace: AddressSpace = .zero) -> 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 minimum ABI-required alignment for the specified type.
This function is equivalent to
TargetData.abiAlignment(of:)
.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 pointer size for the platform, optionally in a given address space.
Declaration
Swift
public func pointerSize(addressSpace: AddressSpace = .zero) -> 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.
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 the given size value and is a multiple of the given alignment value. The alignment must be non-zero.
If a non-zero skew value is specified, the return value will be a minimal integer that is greater than or equal to the given size value and equal to
align * n + skew
for some integern
. If the given skew value is larger than the given alignment value, its value is adjusted toskew mod alignment
.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