From af20d46a39e4431b85d593f56912a185a157554e Mon Sep 17 00:00:00 2001 From: Mihai Preda Date: Mon, 2 May 2022 15:14:48 +0300 Subject: [PATCH] gallium: add opaque pointers shim for LLVM < 8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Acked-by: Marek Olšák Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/gallium/auxiliary/gallivm/lp_bld.h | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) 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 */