diff --git a/src/gallium/auxiliary/gallivm/lp_bld.h b/src/gallium/auxiliary/gallivm/lp_bld.h index 9144428c8e1..5846afa3ce0 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld.h +++ b/src/gallium/auxiliary/gallivm/lp_bld.h @@ -87,4 +87,46 @@ #define GALLIVM_HAVE_CORO 0 #endif +/* LLVM is transitioning to "opaque pointers", and as such deprecates + * LLVMBuildGEP, LLVMBuildCall, LLVMBuildLoad, replacing them with + * LLVMBuildGEP2, LLVMBuildCall2, LLVMBuildLoad2 respectivelly. + * These new functions were added in LLVM 8.0; so for LLVM before 8.0 we + * simply forward to the non-opaque-pointer variants. + */ +#if LLVM_VERSION_MAJOR < 8 + +static inline LLVMValueRef +LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, LLVMValueRef *Indices, + unsigned NumIndices, const char *Name) +{ + return LLVMBuildGEP(B, Pointer, Indices, NumIndices, Name); +} + +static inline LLVMValueRef +LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, LLVMValueRef *Indices, + unsigned NumIndices, const char *Name) +{ + return LLVMBuildInBoundsGEP(B, Pointer, Indices, NumIndices, Name); +} + +static inline LLVMValueRef +LLVMBuildLoad2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef PointerVal, const char *Name) +{ + LLVMValueRef val = LLVMBuildLoad(B, PointerVal, Name); + return LLVMTypeOf(val) == Ty ? val : LLVMBuildBitCast(B, val, Ty, Name); +} + +static inline LLVMValueRef +LLVMBuildCall2(LLVMBuilderRef B, LLVMTypeRef Ty, LLVMValueRef Fn, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name) +{ + return LLVMBuildCall(B, Fn, Args, NumArgs, Name); +} + +#endif /* LLVM_VERSION_MAJOR < 8 */ + #endif /* LP_BLD_H */