@@ -121,132 +121,158 @@ public enum ConstantExpressions {
121121 return Value ( llvm: valueRef)
122122 }
123123
124- func constGEP2( _ type: LLVMTypeRef , _ constantVal: LLVMValueRef , _ constantIndices: [ LLVMValueRef ] , _ numIndices: UInt32 ) -> LLVMValueRef {
124+ public func constGEP2( _ type: TypeRef , _ constantVal: ValueRef , _ constantIndices: [ ValueRef ] , _ numIndices: UInt32 ) -> Value {
125125 let indices = UnsafeMutablePointer< LLVMValueRef?> . allocate( capacity: Int ( numIndices) )
126126 defer {
127127 indices. deallocate ( )
128128 }
129129
130130 for (index, value) in constantIndices. enumerated ( ) {
131131 guard index < numIndices else { break }
132- indices [ index] = value
132+ indices [ index] = value. valueRef
133133 }
134134
135- return LLVMConstGEP2 ( type, constantVal, indices, numIndices)
135+ let valueRef = LLVMConstGEP2 ( type. typeRef, constantVal. valueRef, indices, numIndices) !
136+ return Value ( llvm: valueRef)
136137 }
137138
138- func constInBoundsGEP2( _ type: LLVMTypeRef , _ constantVal: LLVMValueRef , _ constantIndices: [ LLVMValueRef ] , _ numIndices: UInt32 ) -> LLVMValueRef {
139+ public func constInBoundsGEP2( _ type: TypeRef , _ constantVal: ValueRef , _ constantIndices: [ ValueRef ] , _ numIndices: UInt32 ) -> Value {
139140 let indices = UnsafeMutablePointer< LLVMValueRef?> . allocate( capacity: Int ( numIndices) )
140141 defer {
141142 indices. deallocate ( )
142143 }
143144
144145 for (index, value) in constantIndices. enumerated ( ) {
145146 guard index < numIndices else { break }
146- indices [ index] = value
147+ indices [ index] = value. valueRef
147148 }
148149
149- return LLVMConstInBoundsGEP2 ( type, constantVal, indices, numIndices)
150+ let valueRef = LLVMConstInBoundsGEP2 ( type. typeRef, constantVal. valueRef, indices, numIndices) !
151+ return Value ( llvm: valueRef)
150152 }
151153
152- func constTrunc( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
153- LLVMConstTrunc ( constantVal, toType)
154+ public func constTrunc( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
155+ let valueRef = LLVMConstTrunc ( constantVal. valueRef, toType. typeRef) !
156+ return Value ( llvm: valueRef)
154157 }
155158
156- func constSExt( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
157- LLVMConstSExt ( constantVal, toType)
159+ public func constSExt( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
160+ let valueRef = LLVMConstSExt ( constantVal. valueRef, toType. typeRef) !
161+ return Value ( llvm: valueRef)
158162 }
159163
160- func constZExt( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
161- LLVMConstZExt ( constantVal, toType)
164+ public func constZExt( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
165+ let valueRef = LLVMConstZExt ( constantVal. valueRef, toType. typeRef) !
166+ return Value ( llvm: valueRef)
162167 }
163168
164- func constFPTrunc( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
165- LLVMConstFPTrunc ( constantVal, toType)
169+ public func constFPTrunc( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
170+ let valueRef = LLVMConstFPTrunc ( constantVal. valueRef, toType. typeRef) !
171+ return Value ( llvm: valueRef)
166172 }
167173
168- func constFPExt( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
169- LLVMConstFPExt ( constantVal, toType)
174+ public func constFPExt( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
175+ let valueRef = LLVMConstFPExt ( constantVal. valueRef, toType. typeRef) !
176+ return Value ( llvm: valueRef)
170177 }
171178
172- func constUIToFP( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
173- LLVMConstUIToFP ( constantVal, toType)
179+ public func constUIToFP( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
180+ let valueRef = LLVMConstUIToFP ( constantVal. valueRef, toType. typeRef) !
181+ return Value ( llvm: valueRef)
174182 }
175183
176- func constSIToFP( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
177- LLVMConstSIToFP ( constantVal, toType)
184+ public func constSIToFP( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
185+ let valueRef = LLVMConstSIToFP ( constantVal. valueRef, toType. typeRef) !
186+ return Value ( llvm: valueRef)
178187 }
179188
180- func constFPToUI( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
181- LLVMConstFPToUI ( constantVal, toType)
189+ public func constFPToUI( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
190+ let valueRef = LLVMConstFPToUI ( constantVal. valueRef, toType. typeRef) !
191+ return Value ( llvm: valueRef)
182192 }
183193
184- func constFPToSI( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
185- LLVMConstFPToSI ( constantVal, toType)
194+ public func constFPToSI( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
195+ let valueRef = LLVMConstFPToSI ( constantVal. valueRef, toType. typeRef) !
196+ return Value ( llvm: valueRef)
186197 }
187198
188- func constPtrToInt( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
189- LLVMConstPtrToInt ( constantVal, toType)
199+ public func constPtrToInt( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
200+ let valueRef = LLVMConstPtrToInt ( constantVal. valueRef, toType. typeRef) !
201+ return Value ( llvm: valueRef)
190202 }
191203
192- func constIntToPtr( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
193- LLVMConstIntToPtr ( constantVal, toType)
204+ public func constIntToPtr( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
205+ let valueRef = LLVMConstIntToPtr ( constantVal. valueRef, toType. typeRef) !
206+ return Value ( llvm: valueRef)
194207 }
195208
196- func constBitCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
197- LLVMConstBitCast ( constantVal, toType)
209+ public func constBitCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
210+ let valueRef = LLVMConstBitCast ( constantVal. valueRef, toType. typeRef) !
211+ return Value ( llvm: valueRef)
198212 }
199213
200- func constAddrSpaceCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
201- LLVMConstAddrSpaceCast ( constantVal, toType)
214+ public func constAddrSpaceCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
215+ let valueRef = LLVMConstAddrSpaceCast ( constantVal. valueRef, toType. typeRef) !
216+ return Value ( llvm: valueRef)
202217 }
203218
204- func constZExtOrBitCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
205- LLVMConstZExtOrBitCast ( constantVal, toType)
219+ public func constZExtOrBitCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
220+ let valueRef = LLVMConstZExtOrBitCast ( constantVal. valueRef, toType. typeRef) !
221+ return Value ( llvm: valueRef)
206222 }
207223
208- func constSExtOrBitCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
209- LLVMConstSExtOrBitCast ( constantVal, toType)
224+ public func constSExtOrBitCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
225+ let valueRef = LLVMConstSExtOrBitCast ( constantVal. valueRef, toType. typeRef) !
226+ return Value ( llvm: valueRef)
210227 }
211228
212- func constTruncOrBitCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
213- LLVMConstTruncOrBitCast ( constantVal, toType)
229+ public func constTruncOrBitCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
230+ let valueRef = LLVMConstTruncOrBitCast ( constantVal. valueRef, toType. typeRef) !
231+ return Value ( llvm: valueRef)
214232 }
215233
216- func constPointerCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
217- LLVMConstPointerCast ( constantVal, toType)
234+ public func constPointerCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
235+ let valueRef = LLVMConstPointerCast ( constantVal. valueRef, toType. typeRef) !
236+ return Value ( llvm: valueRef)
218237 }
219238
220- func constIntCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef , _ isSigned: Bool ) -> LLVMValueRef {
221- LLVMConstIntCast ( constantVal, toType, LLVMBool ( isSigned ? 1 : 0 ) )
239+ public func constIntCast( _ constantVal: ValueRef , _ toType: TypeRef , _ isSigned: Bool ) -> Value {
240+ let valueRef = LLVMConstIntCast ( constantVal. valueRef, toType. typeRef, isSigned. llvm) !
241+ return Value ( llvm: valueRef)
222242 }
223243
224- func constFPCast( _ constantVal: LLVMValueRef , _ toType: LLVMTypeRef ) -> LLVMValueRef {
225- LLVMConstFPCast ( constantVal, toType)
244+ public func constFPCast( _ constantVal: ValueRef , _ toType: TypeRef ) -> Value {
245+ let valueRef = LLVMConstFPCast ( constantVal. valueRef, toType. typeRef) !
246+ return Value ( llvm: valueRef)
226247 }
227248
228- func constExtractElement( _ vectorConstant: LLVMValueRef , _ indexConstant: LLVMValueRef ) -> LLVMValueRef {
229- LLVMConstExtractElement ( vectorConstant, indexConstant)
249+ public func constExtractElement( _ vectorConstant: ValueRef , _ indexConstant: ValueRef ) -> Value {
250+ let valueRef = LLVMConstExtractElement ( vectorConstant. valueRef, indexConstant. valueRef) !
251+ return Value ( llvm: valueRef)
230252 }
231253
232- func constInsertElement( _ vectorConstant: LLVMValueRef , _ elementValueConstant: LLVMValueRef , _ indexConstant: LLVMValueRef ) -> LLVMValueRef {
233- LLVMConstInsertElement ( vectorConstant, elementValueConstant, indexConstant)
254+ public func constInsertElement( _ vectorConstant: ValueRef , _ elementValueConstant: ValueRef , _ indexConstant: ValueRef ) -> Value {
255+ let valueRef = LLVMConstInsertElement ( vectorConstant. valueRef, elementValueConstant. valueRef, indexConstant. valueRef) !
256+ return Value ( llvm: valueRef)
234257 }
235258
236- func constShuffleVector( _ vectorAConstant: LLVMValueRef , _ vectorBConstant: LLVMValueRef , _ maskConstant: LLVMValueRef ) -> LLVMValueRef {
237- LLVMConstShuffleVector ( vectorAConstant, vectorBConstant, maskConstant)
259+ public func constShuffleVector( _ vectorAConstant: ValueRef , _ vectorBConstant: ValueRef , _ maskConstant: ValueRef ) -> Value {
260+ let valueRef = LLVMConstShuffleVector ( vectorAConstant. valueRef, vectorBConstant. valueRef, maskConstant. valueRef) !
261+ return Value ( llvm: valueRef)
238262 }
239263
240- func blockAddress( _ function: LLVMValueRef , _ basicBlock: LLVMBasicBlockRef ) -> LLVMValueRef {
241- LLVMBlockAddress ( function, basicBlock)
264+ public func blockAddress( _ function: ValueRef , _ basicBlock: BasicBlockRef ) -> Value {
265+ let valueRef = LLVMBlockAddress ( function. valueRef, basicBlock. basicBlockRef) !
266+ return Value ( llvm: valueRef)
242267 }
243268
244269 @available ( * , deprecated, message: " Use LLVMGetInlineAsm instead " )
245- func constInlineAsm( type: LLVMTypeRef , asmString: String , constraints: String , hasSideEffects: Bool , isAlignStack: Bool ) -> LLVMValueRef {
246- asmString. withCString { asmStr in
270+ public func constInlineAsm( type: TypeRef , asmString: String , constraints: String , hasSideEffects: Bool , isAlignStack: Bool ) -> Value {
271+ let valueRef = asmString. withCString { asmStr in
247272 constraints. withCString { consStr in
248- LLVMConstInlineAsm ( type, asmStr, consStr, LLVMBool ( hasSideEffects ? 1 : 0 ) , LLVMBool ( isAlignStack ? 1 : 0 ) )
273+ LLVMConstInlineAsm ( type. typeRef , asmStr, consStr, hasSideEffects. llvm , isAlignStack. llvm ) !
249274 }
250275 }
276+ return Value ( llvm: valueRef)
251277 }
252278}
0 commit comments