Triple

public struct Triple : Equatable

A Triple provides an abstraction over “Target Triples”.

A Target Triple encodes information about the target of a compilation session including the underlying processor architecture, OS, platform vendor, and additional information about the runtime environment.

A target triple is usually specified at the command line as a - delimited string in the format:

<arch><sub>-<vendor>-<sys>-<abi>

For example:

nvptx64-nvidia-cuda
x86_64-unknown-linux-gnu
x86_64-apple-ios8.3-simulator

For this reason, Triple provides an initializer that parses strings in this format.

  • The raw target triple string.

    Declaration

    Swift

    public let data: String
  • The target’s architecture.

    Declaration

    Swift

    public let architecture: Architecture
  • The target’s vendor.

    Declaration

    Swift

    public let vendor: Vendor
  • os

    The target’s operating system.

    Declaration

    Swift

    public let os: OS
  • The target’s environment.

    Declaration

    Swift

    public let environment: Environment
  • The target’s object file format.

    Declaration

    Swift

    public let objectFormat: ObjectFormat
  • Returns the default target triple for the host machine.

    Declaration

    Swift

    public static let `default`: Triple
  • Create a target triple from known components.

    Declaration

    Swift

    public init(
      architecture: Architecture = .unknown,
      vendor: Vendor = .unknown,
      os: OS = .unknown,
      environment: Environment = .unknown,
      objectFormat: ObjectFormat = .unknown
    )

    Parameters

    architecture

    The target’s architecture. If none is specified, an unknown architecture is assumed.

    vendor

    The target’s vendor. If none is specified, an unknown vendor is assumed.

    os

    The target’s operating system. If none is specified, an unknown operating system is assumed.

    environment

    The target’s environment. If none is specified, an unknown environment is assumed.

    objectFormat

    The target’s object file format. If none is specified, an unknown object file format is assumed.

  • Create a target triple by parsing a string in the standard LLVM triple format.

    The expected format of a target triple string is as follows:

    <arch><sub>-<vendor>-<sys>-<abi>
    

    Declaration

    Swift

    public init(_ str: String)

    Parameters

    str

    The target triple format string to parse.

  • Create a target triple from string components.

    The environment is assumed to be unknown and the object file format is determined from a combination of the given target architecture and operating system.

    Declaration

    Swift

    public init(arch: String, vendor: String, os: String)

    Parameters

    arch

    The target’s architecture.

    vendor

    The target’s vendor

    os

    The target’s operating system.

  • Create a target triple from string components.

    Declaration

    Swift

    public init(arch: String, vendor: String, os: String, environment: String)

    Parameters

    arch

    The target’s architecture.

    vendor

    The target’s vendor

    os

    The target’s operating system.

    environment

    The target’s environment.

  • Declaration

    Swift

    public static func == (lhs: Triple, rhs: Triple) -> Bool
  • Normalizes a target triple format string.

    The normalization process converts an arbitrary machine specification into the canonical triple form. In particular, it handles the common case in which otherwise valid components are in the wrong order.

    Examples:

    Triple.normalize("---") == "unknown-unknown-unknown-unknown"
    Triple.normalize("-pc-i386") == "i386-pc-unknown"
    Triple.normalize("a-b-c-i386") == "i386-a-b-c"
    

    Declaration

    Swift

    public static func normalize(_ string: String) -> String

    Parameters

    string

    The target triple format string.

    Return Value

    A normalized target triple string.

  • Returns the architecture component of the triple, if it exists.

    If the environment component does not exist, the empty string is returned.

    Declaration

    Swift

    public var architectureName: Substring { get }
  • Returns the vendor component of the triple, if it exists.

    If the environment component does not exist, the empty string is returned.

    Declaration

    Swift

    public var vendorName: Substring { get }
  • Returns the operating system component of the triple, if it exists.

    If the environment component does not exist, the empty string is returned.

    Declaration

    Swift

    public var osName: Substring { get }
  • Returns the environment component of the triple, if it exists.

    If the environment component does not exist, the empty string is returned.

    Declaration

    Swift

    public var environmentName: Substring { get }
  • Returns whether this environment is a simulator.

    Declaration

    Swift

    public var isSimulatorEnvironment: Bool { get }
  • Returns whether this environment is a Windows OS in an MSVC environment.

    Declaration

    Swift

    public var isKnownWindowsMSVCEnvironment: Bool { get }
  • Checks if the environment could be MSVC.

    Declaration

    Swift

    public var isWindowsMSVCEnvironment: Bool { get }
  • Returns whether this environment is a Windows OS in a CoreCLR environment.

    Declaration

    Swift

    public var isWindowsCoreCLREnvironment: Bool { get }
  • Returns whether this environment is a Windows OS in an Itanium environment.

    Declaration

    Swift

    public var isWindowsItaniumEnvironment: Bool { get }
  • Returns whether this environment is a Windows OS in a Cygnus environment.

    Declaration

    Swift

    public var isWindowsCygwinEnvironment: Bool { get }
  • Returns whether this environment is a Windows OS in a GNU environment.

    Declaration

    Swift

    public var isWindowsGNUEnvironment: Bool { get }
  • Returns whether the OS uses glibc.

    Declaration

    Swift

    public var isOSGlibc: Bool { get }
  • Tests for either Cygwin or MinGW OS

    Declaration

    Swift

    public var isOSCygMing: Bool { get }
  • Is this a “Windows” OS targeting a “MSVCRT.dll” environment.

    Declaration

    Swift

    public var isOSMSVCRT: Bool { get }
  • Returns whether the OS uses the ELF binary format.

    Declaration

    Swift

    public var isOSBinFormatELF: Bool { get }
  • Returns whether the OS uses the COFF binary format.

    Declaration

    Swift

    public var isOSBinFormatCOFF: Bool { get }
  • Returns whether the environment is MachO.

    Declaration

    Swift

    public var isOSBinFormatMachO: Bool { get }
  • Returns whether the OS uses the Wasm binary format.

    Declaration

    Swift

    public var isOSBinFormatWasm: Bool { get }
  • Returns whether the OS uses the XCOFF binary format.

    Declaration

    Swift

    public var isOSBinFormatXCOFF: Bool { get }
  • Returns whether the target is the PS4 CPU

    Declaration

    Swift

    public var isPS4CPU: Bool { get }
  • Returns whether the target is the PS4 platform

    Declaration

    Swift

    public var isPS4: Bool { get }
  • Returns whether the target is Android

    Declaration

    Swift

    public var isAndroid: Bool { get }
  • Returns whether the environment is musl-libc

    Declaration

    Swift

    public var isMusl: Bool { get }
  • Returns whether the target is NVPTX (32- or 64-bit).

    Declaration

    Swift

    public var isNVPTX: Bool { get }
  • Returns whether the target is Thumb (little and big endian).

    Declaration

    Swift

    public var isThumb: Bool { get }
  • Returns whether the target is ARM (little and big endian).

    Declaration

    Swift

    public var isARM: Bool { get }
  • Returns whether the target is AArch64 (little and big endian).

    Declaration

    Swift

    public var isAArch64: Bool { get }
  • Returns whether the target is MIPS 32-bit (little and big endian).

    Declaration

    Swift

    public var isMIPS32: Bool { get }
  • Returns whether the target is MIPS 64-bit (little and big endian).

    Declaration

    Swift

    public var isMIPS64: Bool { get }
  • Returns whether the target is MIPS (little and big endian, 32- or 64-bit).

    Declaration

    Swift

    public var isMIPS: Bool { get }
  • Returns whether the target supports comdat

    Declaration

    Swift

    public var supportsCOMDAT: Bool { get }
  • Returns whether the target uses emulated TLS as default.

    Declaration

    Swift

    public var hasDefaultEmulatedTLS: Bool { get }

Triple Data

  • Represents an architecture known to LLVM.

    See more

    Declaration

    Swift

    public enum Architecture : String, CaseIterable
  • Represents a vendor known to LLVM.

    See more

    Declaration

    Swift

    public enum Vendor : String, CaseIterable
  • OS

    Represents an operating system known to LLVM.

    See more

    Declaration

    Swift

    public enum OS : String, CaseIterable
  • Represents a runtime environment known to LLVM.

    See more

    Declaration

    Swift

    public enum Environment : String, CaseIterable
  • Represents an object file format known to LLVM.

    See more

    Declaration

    Swift

    public enum ObjectFormat : String, CaseIterable