@@ -339,14 +339,15 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
339
339
m_seg0 = m_function->getArg (1 );
340
340
341
341
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 );
350
351
351
352
// Store function addresses in PPU jumptable using internal resolving instead of patching it externally.
352
353
// Because, LLVM processed it extremely slow. (regression)
@@ -380,7 +381,7 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
380
381
const auto addr_array = new GlobalVariable (*m_module, addr_array_type, false , GlobalValue::PrivateLinkage, ConstantDataArray::get (m_context, vec_addrs));
381
382
382
383
// 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 ());
384
385
const auto init_func_table = ConstantArray::get (func_table_type, functions);
385
386
const auto func_table = new GlobalVariable (*m_module, func_table_type, false , GlobalVariable::PrivateLinkage, init_func_table);
386
387
@@ -407,7 +408,7 @@ Function* PPUTranslator::GetSymbolResolver(const ppu_module<lv2_obj>& info)
407
408
const auto func_pc = ZExt (m_ir->CreateLoad (ptr_inst->getResultElementType (), ptr_inst), get_type<u64>());
408
409
409
410
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 ());
411
412
412
413
const auto faddr = m_ir->CreateLoad (ptr_inst->getResultElementType (), ptr_inst);
413
414
const auto faddr_int = m_ir->CreatePtrToInt (faddr, get_type<uptr>());
@@ -605,7 +606,7 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect)
605
606
const auto pos = m_ir->CreateShl (indirect, 1 );
606
607
const auto ptr = dyn_cast<GetElementPtrInst>(m_ir->CreateGEP (get_type<u8>(), m_exec, pos));
607
608
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 ()));
609
610
610
611
// Load new segment address
611
612
seg0 = m_ir->CreateShl (m_ir->CreateLShr (val, 48 ), 13 );
@@ -2782,8 +2783,8 @@ void PPUTranslator::MFOCRF(ppu_opcode_t op)
2782
2783
else if (std::none_of (m_cr + 0 , m_cr + 32 , [](auto * p) { return p; }))
2783
2784
{
2784
2785
// 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 ());
2787
2788
2788
2789
ln0 = m_ir->CreateLoad (GetType<u8[16 ]>(), ln0);
2789
2790
ln1 = m_ir->CreateLoad (GetType<u8[16 ]>(), ln1);
@@ -5371,22 +5372,23 @@ MDNode* PPUTranslator::CheckBranchProbability(u32 bo)
5371
5372
5372
5373
void PPUTranslator::build_interpreter ()
5373
5374
{
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); \
5390
5392
}
5391
5393
5392
5394
BUILD_VEC_INST (VADDCUW);
0 commit comments