From 18963da9a54fa92be03391dc3978c42f9d8b1699 Mon Sep 17 00:00:00 2001 From: Niram7777 Date: Tue, 2 Dec 2025 20:05:33 +0000 Subject: [PATCH] Build LLVM wrap getDeclaration by version --- rpcs3/Emu/CPU/CPUTranslator.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/rpcs3/Emu/CPU/CPUTranslator.h b/rpcs3/Emu/CPU/CPUTranslator.h index e2b768c74e..c709349080 100644 --- a/rpcs3/Emu/CPU/CPUTranslator.h +++ b/rpcs3/Emu/CPU/CPUTranslator.h @@ -1149,7 +1149,11 @@ struct llvm_fshl static llvm::Function* get_fshl(llvm::IRBuilder<>* ir) { const auto _module = ir->GetInsertBlock()->getParent()->getParent(); +#if LLVM_VERSION_MAJOR >= 21 || (LLVM_VERSION_MAJOR == 20 && LLVM_VERSION_MINOR >= 1) return llvm::Intrinsic::getOrInsertDeclaration(_module, llvm::Intrinsic::fshl, {llvm_value_t::get_type(ir->getContext())}); +#else + return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshl, {llvm_value_t::get_type(ir->getContext())}); +#endif } static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3) @@ -1221,7 +1225,11 @@ struct llvm_fshr static llvm::Function* get_fshr(llvm::IRBuilder<>* ir) { const auto _module = ir->GetInsertBlock()->getParent()->getParent(); +#if LLVM_VERSION_MAJOR >= 21 || (LLVM_VERSION_MAJOR == 20 && LLVM_VERSION_MINOR >= 1) return llvm::Intrinsic::getOrInsertDeclaration(_module, llvm::Intrinsic::fshr, {llvm_value_t::get_type(ir->getContext())}); +#else + return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshr, {llvm_value_t::get_type(ir->getContext())}); +#endif } static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3) @@ -2220,7 +2228,11 @@ struct llvm_add_sat static llvm::Function* get_add_sat(llvm::IRBuilder<>* ir) { const auto _module = ir->GetInsertBlock()->getParent()->getParent(); +#if LLVM_VERSION_MAJOR >= 21 || (LLVM_VERSION_MAJOR == 20 && LLVM_VERSION_MINOR >= 1) return llvm::Intrinsic::getOrInsertDeclaration(_module, intr, {llvm_value_t::get_type(ir->getContext())}); +#else + return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t::get_type(ir->getContext())}); +#endif } llvm::Value* eval(llvm::IRBuilder<>* ir) const @@ -2303,7 +2315,11 @@ struct llvm_sub_sat static llvm::Function* get_sub_sat(llvm::IRBuilder<>* ir) { const auto _module = ir->GetInsertBlock()->getParent()->getParent(); +#if LLVM_VERSION_MAJOR >= 21 || (LLVM_VERSION_MAJOR == 20 && LLVM_VERSION_MINOR >= 1) return llvm::Intrinsic::getOrInsertDeclaration(_module, intr, {llvm_value_t::get_type(ir->getContext())}); +#else + return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t::get_type(ir->getContext())}); +#endif } llvm::Value* eval(llvm::IRBuilder<>* ir) const @@ -3592,7 +3608,11 @@ public: llvm::Function* get_intrinsic(llvm::Intrinsic::ID id) { const auto _module = m_ir->GetInsertBlock()->getParent()->getParent(); +#if LLVM_VERSION_MAJOR >= 21 || (LLVM_VERSION_MAJOR == 20 && LLVM_VERSION_MINOR >= 1) return llvm::Intrinsic::getOrInsertDeclaration(_module, id, {get_type()...}); +#else + return llvm::Intrinsic::getDeclaration(_module, id, {get_type()...}); +#endif } template