Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion Sources/LLVM/TargetMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class TargetMachine {
/// The target information associated with this target machine.
public let target: Target

/// The data layout semantics associated with this target machine
/// The data layout semantics associated with this target machine.
public let dataLayout: TargetData

/// A string representing the target triple for this target machine. In the
Expand All @@ -99,6 +99,24 @@ public class TargetMachine {
/// - abi = eabi, gnu, android, macho, elf, etc.
public let triple: String

/// The CPU associated with this target machine.
public var cpu: String {
guard let str = LLVMGetTargetMachineCPU(self.llvm) else {
return ""
}
defer { LLVMDisposeMessage(str) }
return String(validatingUTF8: UnsafePointer<CChar>(str)) ?? ""
}

/// The feature string associated with this target machine.
public var features: String {
guard let str = LLVMGetTargetMachineFeatureString(self.llvm) else {
return ""
}
defer { LLVMDisposeMessage(str) }
return String(validatingUTF8: UnsafePointer<CChar>(str)) ?? ""
}

/// Creates a Target Machine with information about its target environment.
///
/// - parameter triple: An optional target triple to target. If this is not
Expand Down