gallivm: add wrappers for missing functions in LLVM <= 3.8
authorMarek Olšák <marek.olsak@amd.com>
Wed, 19 Oct 2016 22:09:44 +0000 (00:09 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 20 Oct 2016 09:07:50 +0000 (11:07 +0200)
radeonsi needs these.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
src/gallium/auxiliary/gallivm/lp_bld_misc.h

index 791a4702556dbfd3471b83515a704c6faaf9382e..f4045ad1d89645054d6c17890b7577c7bc49af13 100644 (file)
@@ -77,6 +77,7 @@
 
 #include <llvm/Support/TargetSelect.h>
 
+#include <llvm/IR/CallSite.h>
 #include <llvm/IR/IRBuilder.h>
 #include <llvm/IR/Module.h>
 #include <llvm/Support/CBindingWrapping.h>
@@ -708,3 +709,23 @@ lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes)
    A->addAttr(llvm::AttributeSet::get(A->getContext(), A->getArgNo() + 1,  B));
 #endif
 }
+
+extern "C" LLVMValueRef
+lp_get_called_value(LLVMValueRef call)
+{
+#if HAVE_LLVM >= 0x0309
+       return LLVMGetCalledValue(call);
+#else
+       return llvm::wrap(llvm::CallSite(llvm::unwrap<llvm::Instruction>(call)).getCalledValue());
+#endif
+}
+
+extern "C" bool
+lp_is_function(LLVMValueRef v)
+{
+#if HAVE_LLVM >= 0x0309
+       return LLVMGetValueKind(v) == LLVMFunctionValueKind;
+#else
+       return llvm::isa<llvm::Function>(llvm::unwrap(v));
+#endif
+}
index c127c480d52d6cdf196f246164cfd9feac9f0055..a55c6bd508d1c1b9580187339792e9506e2426f0 100644 (file)
@@ -76,6 +76,12 @@ lp_free_memory_manager(LLVMMCJITMemoryManagerRef memorymgr);
 extern void
 lp_add_attr_dereferenceable(LLVMValueRef val, uint64_t bytes);
 
+extern LLVMValueRef
+lp_get_called_value(LLVMValueRef call);
+
+extern bool
+lp_is_function(LLVMValueRef v);
+
 #ifdef __cplusplus
 }
 #endif