Skip to content

Commit dec8f27

Browse files
committed
llvm: fix deprecation warnings
1 parent f5264a2 commit dec8f27

File tree

5 files changed

+56
-53
lines changed

5 files changed

+56
-53
lines changed

rpcs3/Emu/CPU/CPUTranslator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ cpu_translator::cpu_translator(llvm::Module* _module, bool is_be)
7171
result = m_ir->CreateInsertElement(v, m_ir->CreateExtractElement(data0, m_ir->CreateExtractElement(mask, i)), i);
7272
v->addIncoming(result, loop);
7373
m_ir->CreateCondBr(m_ir->CreateICmpULT(i, m_ir->getInt32(16)), loop, next);
74-
m_ir->SetInsertPoint(next->getFirstNonPHI());
74+
m_ir->SetInsertPoint(next->getFirstNonPHIIt());
7575
result = m_ir->CreateSelect(m_ir->CreateICmpSLT(index, zeros), zeros, result);
7676

7777
return result;

rpcs3/Emu/CPU/CPUTranslator.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ struct llvm_value_t<T*> : llvm_value_t<T>
434434

435435
static llvm::Type* get_type(llvm::LLVMContext& context)
436436
{
437-
return llvm_value_t<T>::get_type(context)->getPointerTo();
437+
return llvm::PointerType::get(context, 0);
438438
}
439439
};
440440

@@ -1149,7 +1149,7 @@ struct llvm_fshl
11491149
static llvm::Function* get_fshl(llvm::IRBuilder<>* ir)
11501150
{
11511151
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
1152-
return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshl, {llvm_value_t<T>::get_type(ir->getContext())});
1152+
return llvm::Intrinsic::getOrInsertDeclaration(_module, llvm::Intrinsic::fshl, {llvm_value_t<T>::get_type(ir->getContext())});
11531153
}
11541154

11551155
static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3)
@@ -1221,7 +1221,7 @@ struct llvm_fshr
12211221
static llvm::Function* get_fshr(llvm::IRBuilder<>* ir)
12221222
{
12231223
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
1224-
return llvm::Intrinsic::getDeclaration(_module, llvm::Intrinsic::fshr, {llvm_value_t<T>::get_type(ir->getContext())});
1224+
return llvm::Intrinsic::getOrInsertDeclaration(_module, llvm::Intrinsic::fshr, {llvm_value_t<T>::get_type(ir->getContext())});
12251225
}
12261226

12271227
static llvm::Value* fold(llvm::IRBuilder<>* ir, llvm::Value* v1, llvm::Value* v2, llvm::Value* v3)
@@ -2220,7 +2220,7 @@ struct llvm_add_sat
22202220
static llvm::Function* get_add_sat(llvm::IRBuilder<>* ir)
22212221
{
22222222
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
2223-
return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
2223+
return llvm::Intrinsic::getOrInsertDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
22242224
}
22252225

22262226
llvm::Value* eval(llvm::IRBuilder<>* ir) const
@@ -2303,7 +2303,7 @@ struct llvm_sub_sat
23032303
static llvm::Function* get_sub_sat(llvm::IRBuilder<>* ir)
23042304
{
23052305
const auto _module = ir->GetInsertBlock()->getParent()->getParent();
2306-
return llvm::Intrinsic::getDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
2306+
return llvm::Intrinsic::getOrInsertDeclaration(_module, intr, {llvm_value_t<T>::get_type(ir->getContext())});
23072307
}
23082308

23092309
llvm::Value* eval(llvm::IRBuilder<>* ir) const
@@ -3592,7 +3592,7 @@ class cpu_translator
35923592
llvm::Function* get_intrinsic(llvm::Intrinsic::ID id)
35933593
{
35943594
const auto _module = m_ir->GetInsertBlock()->getParent()->getParent();
3595-
return llvm::Intrinsic::getDeclaration(_module, id, {get_type<Types>()...});
3595+
return llvm::Intrinsic::getOrInsertDeclaration(_module, id, {get_type<Types>()...});
35963596
}
35973597

35983598
template <typename T1, typename T2>

rpcs3/Emu/Cell/PPUThread.cpp

+9-8
Original file line numberDiff line numberDiff line change
@@ -5748,14 +5748,15 @@ static void ppu_initialize2(jit_compiler& jit, const ppu_module<lv2_obj>& module
57485748

57495749
// Define some types
57505750
const auto _func = FunctionType::get(translator.get_type<void>(), {
5751-
translator.get_type<u8*>(), // Exec base
5752-
translator.GetContextType()->getPointerTo(), // PPU context
5753-
translator.get_type<u64>(), // Segment address (for PRX)
5754-
translator.get_type<u8*>(), // Memory base
5755-
translator.get_type<u64>(), // r0
5756-
translator.get_type<u64>(), // r1
5757-
translator.get_type<u64>(), // r2
5758-
}, false);
5751+
translator.get_type<u8*>(), // Exec base
5752+
PointerType::get(jit.get_context(), 0), // PPU context
5753+
translator.get_type<u64>(), // Segment address (for PRX)
5754+
translator.get_type<u8*>(), // Memory base
5755+
translator.get_type<u64>(), // r0
5756+
translator.get_type<u64>(), // r1
5757+
translator.get_type<u64>(), // r2
5758+
},
5759+
false);
57595760

57605761
// Difference between function name and current location
57615762
const u32 reloc = module_part.is_relocatable ? ::at32(module_part.segs, 0).addr : 0;

rpcs3/Emu/Cell/PPUTranslator.cpp

+31-29
Original file line numberDiff line numberDiff line change
@@ -339,14 +339,15 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
339339
m_seg0 = m_function->getArg(1);
340340

341341
const auto ftype = FunctionType::get(get_type<void>(), {
342-
get_type<u8*>(), // Exec base
343-
GetContextType()->getPointerTo(), // PPU context
344-
get_type<u64>(), // Segment address (for PRX)
345-
get_type<u8*>(), // Memory base
346-
get_type<u64>(), // r0
347-
get_type<u64>(), // r1
348-
get_type<u64>(), // r2
349-
}, false);
342+
get_type<u8*>(), // Exec base
343+
m_ir->getPtrTy(), // PPU context
344+
get_type<u64>(), // Segment address (for PRX)
345+
get_type<u8*>(), // Memory base
346+
get_type<u64>(), // r0
347+
get_type<u64>(), // r1
348+
get_type<u64>(), // r2
349+
},
350+
false);
350351

351352
// Store function addresses in PPU jumptable using internal resolving instead of patching it externally.
352353
// Because, LLVM processed it extremely slow. (regression)
@@ -380,7 +381,7 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
380381
const auto addr_array = new GlobalVariable(*m_module, addr_array_type, false, GlobalValue::PrivateLinkage, ConstantDataArray::get(m_context, vec_addrs));
381382

382383
// Create an array of function pointers
383-
const auto func_table_type = ArrayType::get(ftype->getPointerTo(), functions.size());
384+
const auto func_table_type = ArrayType::get(m_ir->getPtrTy(), functions.size());
384385
const auto init_func_table = ConstantArray::get(func_table_type, functions);
385386
const auto func_table = new GlobalVariable(*m_module, func_table_type, false, GlobalVariable::PrivateLinkage, init_func_table);
386387

@@ -407,7 +408,7 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
407408
const auto func_pc = ZExt(m_ir->CreateLoad(ptr_inst->getResultElementType(), ptr_inst), get_type<u64>());
408409

409410
ptr_inst = dyn_cast<GetElementPtrInst>(m_ir->CreateGEP(func_table->getValueType(), func_table, {m_ir->getInt64(0), index_value}));
410-
assert(ptr_inst->getResultElementType() == ftype->getPointerTo());
411+
assert(ptr_inst->getResultElementType() == m_ir->getPtrTy());
411412

412413
const auto faddr = m_ir->CreateLoad(ptr_inst->getResultElementType(), ptr_inst);
413414
const auto faddr_int = m_ir->CreatePtrToInt(faddr, get_type<uptr>());
@@ -605,7 +606,7 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect)
605606
const auto pos = m_ir->CreateShl(indirect, 1);
606607
const auto ptr = dyn_cast<GetElementPtrInst>(m_ir->CreateGEP(get_type<u8>(), m_exec, pos));
607608
const auto val = m_ir->CreateLoad(get_type<u64>(), ptr);
608-
callee = FunctionCallee(type, m_ir->CreateIntToPtr(m_ir->CreateAnd(val, 0xffff'ffff'ffff), type->getPointerTo()));
609+
callee = FunctionCallee(type, m_ir->CreateIntToPtr(m_ir->CreateAnd(val, 0xffff'ffff'ffff), m_ir->getPtrTy()));
609610

610611
// Load new segment address
611612
seg0 = m_ir->CreateShl(m_ir->CreateLShr(val, 48), 13);
@@ -2782,8 +2783,8 @@ void PPUTranslator::MFOCRF(ppu_opcode_t op)
27822783
else if (std::none_of(m_cr + 0, m_cr + 32, [](auto* p) { return p; }))
27832784
{
27842785
// MFCR (optimized)
2785-
Value* ln0 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread_type, m_thread, 99), GetType<uptr>()), GetType<u8[16]>()->getPointerTo());
2786-
Value* ln1 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread_type, m_thread, 115), GetType<uptr>()), GetType<u8[16]>()->getPointerTo());
2786+
Value* ln0 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread_type, m_thread, 99), GetType<uptr>()), m_ir->getPtrTy());
2787+
Value* ln1 = m_ir->CreateIntToPtr(m_ir->CreatePtrToInt(m_ir->CreateStructGEP(m_thread_type, m_thread, 115), GetType<uptr>()), m_ir->getPtrTy());
27872788

27882789
ln0 = m_ir->CreateLoad(GetType<u8[16]>(), ln0);
27892790
ln1 = m_ir->CreateLoad(GetType<u8[16]>(), ln1);
@@ -5371,22 +5372,23 @@ MDNode* PPUTranslator::CheckBranchProbability(u32 bo)
53715372

53725373
void PPUTranslator::build_interpreter()
53735374
{
5374-
#define BUILD_VEC_INST(i) { \
5375-
m_function = llvm::cast<llvm::Function>(m_module->getOrInsertFunction("op_" #i, get_type<void>(), m_thread_type->getPointerTo()).getCallee()); \
5376-
std::fill(std::begin(m_globals), std::end(m_globals), nullptr); \
5377-
std::fill(std::begin(m_locals), std::end(m_locals), nullptr); \
5378-
IRBuilder<> irb(BasicBlock::Create(m_context, "__entry", m_function)); \
5379-
m_ir = &irb; \
5380-
m_thread = m_function->getArg(0); \
5381-
ppu_opcode_t op{}; \
5382-
op.vd = 0; \
5383-
op.va = 1; \
5384-
op.vb = 2; \
5385-
op.vc = 3; \
5386-
this->i(op); \
5387-
FlushRegisters(); \
5388-
m_ir->CreateRetVoid(); \
5389-
run_transforms(*m_function); \
5375+
#define BUILD_VEC_INST(i) \
5376+
{ \
5377+
m_function = llvm::cast<llvm::Function>(m_module->getOrInsertFunction("op_" #i, get_type<void>(), m_ir->getPtrTy()).getCallee()); \
5378+
std::fill(std::begin(m_globals), std::end(m_globals), nullptr); \
5379+
std::fill(std::begin(m_locals), std::end(m_locals), nullptr); \
5380+
IRBuilder<> irb(BasicBlock::Create(m_context, "__entry", m_function)); \
5381+
m_ir = &irb; \
5382+
m_thread = m_function->getArg(0); \
5383+
ppu_opcode_t op{}; \
5384+
op.vd = 0; \
5385+
op.va = 1; \
5386+
op.vb = 2; \
5387+
op.vc = 3; \
5388+
this->i(op); \
5389+
FlushRegisters(); \
5390+
m_ir->CreateRetVoid(); \
5391+
run_transforms(*m_function); \
53905392
}
53915393

53925394
BUILD_VEC_INST(VADDCUW);

rpcs3/Emu/Cell/SPULLVMRecompiler.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -2561,13 +2561,13 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
25612561
{
25622562
if (b2 != bqbi)
25632563
{
2564-
auto ins = b2->block->getFirstNonPHI();
2564+
auto ins = b2->block->getFirstNonPHIIt();
25652565

25662566
if (b2->bb->preds.size() == 1)
25672567
{
25682568
if (!dt.dominates(bs->getOperand(0), ins))
25692569
continue;
2570-
if (!pdt.dominates(ins, bs))
2570+
if (!pdt.dominates(&*ins, bs))
25712571
continue;
25722572

25732573
m_ir->SetInsertPoint(ins);
@@ -2630,10 +2630,10 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
26302630
spu_log.trace("Postponed r%u store from block 0x%x (multiple)", i, block_q[bi].first);
26312631
}
26322632

2633-
ins = edge->getTerminator();
2633+
ins = edge->getTerminator()->getIterator();
26342634
if (!dt.dominates(bs->getOperand(0), ins))
26352635
continue;
2636-
if (!pdt.dominates(ins, bs))
2636+
if (!pdt.dominates(&*ins, bs))
26372637
continue;
26382638

26392639
m_ir->SetInsertPoint(ins);
@@ -2886,7 +2886,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
28862886

28872887
// Create interpreter table
28882888
const auto if_type = get_ftype<void, u8*, u8*, u32, u32, u8*, u32, u8*>();
2889-
m_function_table = new GlobalVariable(*m_module, ArrayType::get(if_type->getPointerTo(), 1ull << m_interp_magn), true, GlobalValue::InternalLinkage, nullptr);
2889+
m_function_table = new GlobalVariable(*m_module, ArrayType::get(m_ir->getPtrTy(), 1ull << m_interp_magn), true, GlobalValue::InternalLinkage, nullptr);
28902890

28912891
init_luts();
28922892

@@ -2930,7 +2930,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
29302930
m_ir->CreateStore(m_ir->CreateCall(get_intrinsic<u64>(Intrinsic::read_register), {rsp_name}), native_sp);
29312931

29322932
// Decode (shift) and load function pointer
2933-
const auto first = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_interp_table, m_ir->CreateLShr(m_interp_op, 32u - m_interp_magn)));
2933+
const auto first = m_ir->CreateLoad(m_ir->getPtrTy(), m_ir->CreateGEP(m_ir->getPtrTy(), m_interp_table, m_ir->CreateLShr(m_interp_op, 32u - m_interp_magn)));
29342934
const auto call0 = m_ir->CreateCall(if_type, first, {m_lsptr, m_thread, m_interp_pc, m_interp_op, m_interp_table, m_interp_7f0, m_interp_regs});
29352935
call0->setCallingConv(CallingConv::GHC);
29362936
m_ir->CreateRetVoid();
@@ -3074,7 +3074,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
30743074
const auto next_pc = itype & spu_itype::branch ? m_interp_pc : m_interp_pc_next;
30753075
const auto be32_op = m_ir->CreateLoad(get_type<u32>(), m_ir->CreateGEP(get_type<u8>(), m_lsptr, m_ir->CreateZExt(next_pc, get_type<u64>())));
30763076
const auto next_op = m_ir->CreateCall(get_intrinsic<u32>(Intrinsic::bswap), {be32_op});
3077-
const auto next_if = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_interp_table, m_ir->CreateLShr(next_op, 32u - m_interp_magn)));
3077+
const auto next_if = m_ir->CreateLoad(m_ir->getPtrTy(), m_ir->CreateGEP(m_ir->getPtrTy(), m_interp_table, m_ir->CreateLShr(next_op, 32u - m_interp_magn)));
30783078
llvm::cast<LoadInst>(next_if)->setVolatile(true);
30793079

30803080
if (!(itype & spu_itype::branch))
@@ -3199,7 +3199,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
31993199
}
32003200
}
32013201

3202-
m_function_table->setInitializer(ConstantArray::get(ArrayType::get(if_type->getPointerTo(), 1ull << m_interp_magn), iptrs));
3202+
m_function_table->setInitializer(ConstantArray::get(ArrayType::get(m_ir->getPtrTy(), 1ull << m_interp_magn), iptrs));
32033203
m_function_table = nullptr;
32043204

32053205
for (auto& f : *_module)
@@ -7808,7 +7808,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
78087808
m_ir->CreateStore(splat<u64[2]>(-1).eval(m_ir), m_ir->CreateGEP(get_type<u8>(), m_thread, stack0.value));
78097809
const auto targ = m_ir->CreateAdd(m_ir->CreateLShr(_ret, 32), get_segment_base());
78107810
const auto type = m_finfo->chunk->getFunctionType();
7811-
const auto fval = m_ir->CreateIntToPtr(targ, type->getPointerTo());
7811+
const auto fval = m_ir->CreateIntToPtr(targ, m_ir->getPtrTy());
78127812
tail_chunk({type, fval}, m_ir->CreateTrunc(m_ir->CreateLShr(link, 32), get_type<u32>()));
78137813
m_ir->SetInsertPoint(fail);
78147814
}

0 commit comments

Comments
 (0)