@@ -110,6 +110,7 @@ indirectbr!(builder::IRBuilder, Addr::Value, NumDests::Integer=10) =
110110function invoke! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} , Then:: BasicBlock ,
111111 Catch:: BasicBlock , Name:: String = " " )
112112 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
113+ Base. depwarn (" invoke! without specifying the function type is deprecated" , :invoke )
113114 Instruction (API. LLVMBuildInvoke (builder, Fn, Args, length (Args), Then, Catch, Name))
114115end
115116
@@ -259,11 +260,16 @@ free!(builder::IRBuilder, PointerVal::Value) =
259260
260261function load! (builder:: IRBuilder , PointerVal:: Value , Name:: String = " " )
261262 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
263+ Base. depwarn (" load! without specifying the destination type is deprecated" , :load )
262264 Instruction (API. LLVMBuildLoad (builder, PointerVal, Name))
263265end
264266
265267function load! (builder:: IRBuilder , Ty:: LLVMType , PointerVal:: Value , Name:: String = " " )
266- Instruction (API. LLVMBuildLoad2 (builder, Ty, PointerVal, Name))
268+ @static if version () >= v " 11"
269+ Instruction (API. LLVMBuildLoad2 (builder, Ty, PointerVal, Name))
270+ else
271+ Instruction (API. LLVMBuildLoad (builder, PointerVal, Name))
272+ end
267273end
268274
269275store! (builder:: IRBuilder , Val:: Value , Ptr:: Value ) =
@@ -286,32 +292,47 @@ atomic_cmpxchg!(builder::IRBuilder, Ptr::Value, Cmp::Value, New::Value,
286292
287293function gep! (builder:: IRBuilder , Pointer:: Value , Indices:: Vector{<:Value} , Name:: String = " " )
288294 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
295+ Base. depwarn (" gep! without specifying the destination type is deprecated" , :gep )
289296 Value (API. LLVMBuildGEP (builder, Pointer, Indices, length (Indices), Name))
290297end
291298
292299function gep! (builder:: IRBuilder , Ty:: LLVMType , Pointer:: Value , Indices:: Vector{<:Value} ,
293300 Name:: String = " " )
294- return Value (API. LLVMBuildGEP2 (builder, Ty, Pointer, Indices, length (Indices), Name))
301+ @static if version () >= v " 11"
302+ Value (API. LLVMBuildGEP2 (builder, Ty, Pointer, Indices, length (Indices), Name))
303+ else
304+ Value (API. LLVMBuildGEP (builder, Pointer, Indices, length (Indices), Name))
305+ end
295306end
296307
297308function inbounds_gep! (builder:: IRBuilder , Pointer:: Value , Indices:: Vector{<:Value} ,
298309 Name:: String = " " )
299310 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
311+ Base. depwarn (" inbounds_gep! without specifying the destination type is deprecated" , :inbounds_gep )
300312 Value (API. LLVMBuildInBoundsGEP (builder, Pointer, Indices, length (Indices), Name))
301313end
302314
303315function inbounds_gep! (builder:: IRBuilder , Ty:: LLVMType , Pointer:: Value ,
304316 Indices:: Vector{<:Value} , Name:: String = " " )
305- Value (API. LLVMBuildInBoundsGEP2 (builder, Ty, Pointer, Indices, length (Indices), Name))
317+ @static if version () >= v " 11"
318+ Value (API. LLVMBuildInBoundsGEP2 (builder, Ty, Pointer, Indices, length (Indices), Name))
319+ else
320+ Value (API. LLVMBuildInBoundsGEP (builder, Pointer, Indices, length (Indices), Name))
321+ end
306322end
307323
308324function struct_gep! (builder:: IRBuilder , Pointer:: Value , Idx, Name:: String = " " )
309325 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
326+ Base. depwarn (" struct_gep! without specifying the destination type is deprecated" , :struct_gep )
310327 Value (API. LLVMBuildStructGEP (builder, Pointer, Idx, Name))
311328end
312329
313330function struct_gep! (builder:: IRBuilder , Ty:: LLVMType , Pointer:: Value , Idx, Name:: String = " " )
314- Value (API. LLVMBuildStructGEP2 (builder, Ty, Pointer, Idx, Name))
331+ @static if version () >= v " 11"
332+ Value (API. LLVMBuildStructGEP2 (builder, Ty, Pointer, Idx, Name))
333+ else
334+ Value (API. LLVMBuildStructGEP (builder, Pointer, Idx, Name))
335+ end
315336end
316337
317338# conversion operations
@@ -394,25 +415,47 @@ select!(builder::IRBuilder, If::Value, Then::Value, Else::Value, Name::String=""
394415
395416function call! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} = Value[], Name:: String = " " )
396417 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
418+ Base. depwarn (" call! without specifying the function type is deprecated" , :call )
397419 Instruction (API. LLVMBuildCall (builder, Fn, Args, length (Args), Name))
398420end
399421
400422function call! (builder:: IRBuilder , Ty:: LLVMType , Fn:: Value , Args:: Vector{<:Value} = Value[],
401423 Name:: String = " " )
402- Instruction (API. LLVMBuildCall2 (builder, Ty, Fn, Args, length (Args), Name))
424+ @static if version () >= v " 11"
425+ Instruction (API. LLVMBuildCall2 (builder, Ty, Fn, Args, length (Args), Name))
426+ else
427+ Instruction (API. LLVMBuildCall (builder, Fn, Args, length (Args), Name))
428+ end
403429end
404430
405- call! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} ,
406- Bundles:: Vector{OperandBundleDef} , Name:: String = " " ) =
431+ function call! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} ,
432+ Bundles:: Vector{OperandBundleDef} , Name:: String = " " )
433+ supports_typed_pointers (context (builder)) || throw_typedpointererror ()
434+ Base. depwarn (" call! without specifying the function type is deprecated" , :call )
407435 Instruction (API. LLVMBuildCallWithOpBundle (builder, Fn, Args, length (Args), Bundles,
408436 length (Bundles), Name))
437+ end
438+ function call! (builder:: IRBuilder , Ty:: LLVMType , Fn:: Value , Args:: Vector{<:Value} ,
439+ Bundles:: Vector{OperandBundleDef} , Name:: String = " " )
440+ Instruction (API. LLVMBuildCallWithOpBundle2 (builder, Ty, Fn, Args, length (Args), Bundles,
441+ length (Bundles), Name))
442+ end
409443
410444# convenience function that performs the OperandBundle(Iterator|Use)->Def conversion
411- call! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} ,
412- Bundles, Name:: String = " " ) =
445+ function call! (builder:: IRBuilder , Fn:: Value , Args:: Vector{<:Value} ,
446+ Bundles, Name:: String = " " )
447+ supports_typed_pointers (context (builder)) || throw_typedpointererror ()
448+ Base. depwarn (" call! without specifying the function type is deprecated" , :call )
413449 Instruction (API. LLVMBuildCallWithOpBundle (builder, Fn, Args, length (Args),
414450 OperandBundleDef .(Bundles),
415451 length (Bundles), Name))
452+ end
453+ function call! (builder:: IRBuilder , Ty:: LLVMType , Fn:: Value , Args:: Vector{<:Value} ,
454+ Bundles, Name:: String = " " )
455+ Instruction (API. LLVMBuildCallWithOpBundle2 (builder, Ty, Fn, Args, length (Args),
456+ OperandBundleDef .(Bundles),
457+ length (Bundles), Name))
458+ end
416459
417460va_arg! (builder:: IRBuilder , List:: Value , Ty:: LLVMType , Name:: String = " " ) =
418461 Instruction (API. LLVMBuildVAArg (builder, List, Ty, Name))
@@ -453,9 +496,15 @@ isnotnull!(builder::IRBuilder, Val::Value, Name::String="") =
453496
454497function ptrdiff! (builder:: IRBuilder , LHS:: Value , RHS:: Value , Name:: String = " " )
455498 supports_typed_pointers (context (builder)) || throw_typedpointererror ()
499+ Base. depwarn (" ptrdiff! without specifying a pointer type is deprecated" , :ptrdiff )
456500 Value (API. LLVMBuildPtrDiff (builder, LHS, RHS, Name))
457501end
458502
459503function ptrdiff! (builder:: IRBuilder , Ty:: LLVMType , LHS:: Value , RHS:: Value , Name:: String = " " )
460- Value (API. LLVMBuildPtrDiff2 (builder, Ty, LHS, RHS, Name))
504+ @static if version () >= v " 15"
505+ # XXX : backport this to LLVM 11, if we care
506+ Value (API. LLVMBuildPtrDiff2 (builder, Ty, LHS, RHS, Name))
507+ else
508+ Value (API. LLVMBuildPtrDiff (builder, LHS, RHS, Name))
509+ end
461510end
0 commit comments