@@ -144,15 +144,8 @@ public class TargetMachine {
144144 /// The data layout semantics associated with this target machine.
145145 public let dataLayout : TargetData
146146
147- /// A string representing the target triple for this target machine. In the
148- /// form `<arch><sub>-<vendor>-<sys>-<abi>` where
149- ///
150- /// - arch = x86_64, i386, arm, thumb, mips, etc.
151- /// - sub = for ex. on ARM: v5, v6m, v7a, v7m, etc.
152- /// - vendor = pc, apple, nvidia, ibm, etc.
153- /// - sys = none, linux, win32, darwin, cuda, etc.
154- /// - abi = eabi, gnu, android, macho, elf, etc.
155- public let triple : String
147+ /// The target triple for this target machine.
148+ public let triple : Triple
156149
157150 /// The CPU associated with this target machine.
158151 public var cpu : String {
@@ -190,24 +183,24 @@ public class TargetMachine {
190183 /// - parameter codeModel: The kind of code to produce for this target. If
191184 /// no model is provided, the default model for the target architecture is
192185 /// assumed.
193- public init ( triple: String ? = nil , cpu: String = " " , features: String = " " ,
186+ public init ( triple: Triple = . default , cpu: String = " " , features: String = " " ,
194187 optLevel: CodeGenOptLevel = . default, relocations: RelocationModel = . default,
195188 codeModel: CodeModel = . default) throws {
196189
197190 // Ensure the LLVM initializer is called when the first module is created
198191 initializeLLVM ( )
199192
200- self . triple = triple ?? String ( cString : LLVMGetDefaultTargetTriple ( ) ! )
193+ self . triple = triple
201194 var target : LLVMTargetRef ?
202195 var error : UnsafeMutablePointer < Int8 > ?
203- LLVMGetTargetFromTriple ( self . triple, & target, & error)
196+ LLVMGetTargetFromTriple ( self . triple. data , & target, & error)
204197 if let error = error {
205198 defer { LLVMDisposeMessage ( error) }
206- throw TargetMachineError . couldNotCreateTarget ( self . triple,
199+ throw TargetMachineError . couldNotCreateTarget ( self . triple. data ,
207200 String ( cString: error) )
208201 }
209202 self . target = Target ( llvm: target!)
210- self . llvm = LLVMCreateTargetMachine ( target!, self . triple, cpu, features,
203+ self . llvm = LLVMCreateTargetMachine ( target!, self . triple. data , cpu, features,
211204 optLevel. asLLVM ( ) ,
212205 relocations. asLLVM ( ) ,
213206 codeModel. asLLVM ( ) )
0 commit comments