Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rpcs3/Emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ target_sources(rpcs3_emu PRIVATE
Cell/SPUCommonRecompiler.cpp
Cell/SPULLVMRecompiler.cpp
Cell/SPUThread.cpp
Cell/spu_optimizer.cpp
Cell/lv2/lv2.cpp
Cell/lv2/sys_bdemu.cpp
Cell/lv2/sys_btsetting.cpp
Expand Down
48 changes: 26 additions & 22 deletions rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
u8 output[20];

sha1_starts(&ctx);
sha1_update(&ctx, reinterpret_cast<const u8*>(func.data.data()), func.data.size() * 4);
sha1_update(&ctx, reinterpret_cast<const u8*>(func.get_data().data()), func.get_data().size() * 4);
sha1_finish(&ctx, output);

be_t<u64> hash_start;
Expand Down Expand Up @@ -167,14 +167,14 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
// Start compilation
m_pos = func.lower_bound;
m_base = func.entry_point;
m_size = ::size32(func.data) * 4;
m_size = ::size32(func.get_data()) * 4;
const u32 start = m_pos;
const u32 end = start + m_size;

// Create block labels
for (u32 i = 0; i < func.data.size(); i++)
for (u32 i = 0; i < func.get_data().size(); i++)
{
if (func.data[i] && m_block_info[i + start / 4])
if (func.get_data()[i] && m_block_info[i + start / 4])
{
instr_labels[i * 4 + start] = c->newLabel();
}
Expand Down Expand Up @@ -208,7 +208,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
for (u32 addr = starta, m = 1; addr < enda && m; addr += 4, m <<= 1)
{
// Filter out if out of range, or is a hole
if (addr >= start && addr < end && func.data[(addr - start) / 4])
if (addr >= start && addr < end && func.get_data()[(addr - start) / 4])
{
result |= m;
}
Expand All @@ -223,7 +223,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
// Skip holes at the beginning (giga only)
for (u32 j = start; j < end; j += 4)
{
if (!func.data[(j - start) / 4])
if (!func.get_data()[(j - start) / 4])
{
starta += 4;
}
Expand Down Expand Up @@ -258,7 +258,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
}
else if (m_size == 8)
{
c->mov(x86::rax, static_cast<u64>(func.data[1]) << 32 | func.data[0]);
c->mov(x86::rax, static_cast<u64>(func.get_data()[1]) << 32 | func.get_data()[0]);
c->cmp(x86::rax, x86::qword_ptr(*ls, *pc0));
c->jnz(label_diff);

Expand All @@ -269,7 +269,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
}
else if (m_size == 4)
{
c->cmp(x86::dword_ptr(*ls, *pc0), func.data[0]);
c->cmp(x86::dword_ptr(*ls, *pc0), func.get_data()[0]);
c->jnz(label_diff);

if (utils::has_avx())
Expand Down Expand Up @@ -348,7 +348,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = j; i < j + 64; i += 4)
{
words.push_back(i >= start && i < end ? func.data[(i - start) / 4] : 0);
words.push_back(i >= start && i < end ? func.get_data()[(i - start) / 4] : 0);
}

code_off += 64;
Expand Down Expand Up @@ -388,7 +388,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = starta; i < enda; i += 4)
{
words.push_back(i >= start && i < end ? func.data[(i - start) / 4] : 0);
words.push_back(i >= start && i < end ? func.get_data()[(i - start) / 4] : 0);
}
}
else if (sizea == 2 && (end - start) <= 32)
Expand All @@ -405,7 +405,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = starta; i < starta + 32; i += 4)
{
words.push_back(i >= start ? func.data[(i - start) / 4] : i + 32 < end ? func.data[(i + 32 - start) / 4] : 0);
words.push_back(i >= start ? func.get_data()[(i - start) / 4] : i + 32 < end ? func.get_data()[(i + 32 - start) / 4] : 0);
}
}
else
Expand Down Expand Up @@ -468,7 +468,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = j; i < j + 32; i += 4)
{
words.push_back(i >= start && i < end ? func.data[(i - start) / 4] : 0);
words.push_back(i >= start && i < end ? func.get_data()[(i - start) / 4] : 0);
}

code_off += 32;
Expand Down Expand Up @@ -510,7 +510,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = starta; i < enda; i += 4)
{
words.push_back(i >= start && i < end ? func.data[(i - start) / 4] : 0);
words.push_back(i >= start && i < end ? func.get_data()[(i - start) / 4] : 0);
}
}
else if (sizea == 2 && (end - start) <= 32)
Expand All @@ -527,7 +527,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = starta; i < starta + 32; i += 4)
{
words.push_back(i >= start ? func.data[(i - start) / 4] : i + 32 < end ? func.data[(i + 32 - start) / 4] : 0);
words.push_back(i >= start ? func.get_data()[(i - start) / 4] : i + 32 < end ? func.get_data()[(i + 32 - start) / 4] : 0);
}
}
else
Expand Down Expand Up @@ -602,7 +602,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)

for (u32 i = j; i < j + 32; i += 4)
{
words.push_back(i >= start && i < end ? func.data[(i - start) / 4] : 0);
words.push_back(i >= start && i < end ? func.get_data()[(i - start) / 4] : 0);
}

code_off += 32;
Expand Down Expand Up @@ -672,10 +672,10 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
}

// Determine which value will be duplicated at hole positions
const u32 w3 = ::at32(func.data, (j - start + ~static_cast<u32>(std::countl_zero(cmask)) % 4 * 4) / 4);
words.push_back(cmask & 1 ? func.data[(j - start + 0) / 4] : w3);
words.push_back(cmask & 2 ? func.data[(j - start + 4) / 4] : w3);
words.push_back(cmask & 4 ? func.data[(j - start + 8) / 4] : w3);
const u32 w3 = ::at32(func.get_data(), (j - start + ~static_cast<u32>(std::countl_zero(cmask)) % 4 * 4) / 4);
words.push_back(cmask & 1 ? func.get_data()[(j - start + 0) / 4] : w3);
words.push_back(cmask & 2 ? func.get_data()[(j - start + 4) / 4] : w3);
words.push_back(cmask & 4 ? func.get_data()[(j - start + 8) / 4] : w3);
words.push_back(w3);

// PSHUFD immediate table for all possible hole mask values, holes repeat highest valid word
Expand Down Expand Up @@ -768,10 +768,10 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
m_pos = -1;
}

for (u32 i = 0; i < func.data.size(); i++)
for (u32 i = 0; i < func.get_data().size(); i++)
{
const u32 pos = start + i * 4;
const u32 op = std::bit_cast<be_t<u32>>(func.data[i]);
const u32 op = std::bit_cast<be_t<u32>>(func.get_data()[i]);

if (!op)
{
Expand Down Expand Up @@ -904,7 +904,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func)
const bool added = !add_loc->compiled && add_loc->compiled.compare_and_swap_test(nullptr, fn);

// Rebuild trampoline if necessary
if (!m_spurt->rebuild_ubertrampoline(func.data[0]))
if (!m_spurt->rebuild_ubertrampoline(func.get_data()[0]))
{
return nullptr;
}
Expand Down Expand Up @@ -4876,3 +4876,7 @@ void spu_recompiler::FMS(spu_opcode_t op)
c->subps(va, SPU_OFF_128(gpr, op.rc));
c->movaps(SPU_OFF_128(gpr, op.rt4), va);
}

void spu_recompiler::RPCS3_OPTIMIZER(spu_opcode_t op)
{
}
1 change: 1 addition & 0 deletions rpcs3/Emu/Cell/SPUASMJITRecompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -297,4 +297,5 @@ class spu_recompiler : public spu_recompiler_base
void FNMS(spu_opcode_t op);
void FMA(spu_opcode_t op);
void FMS(spu_opcode_t op);
void RPCS3_OPTIMIZER(spu_opcode_t op);
};
6 changes: 5 additions & 1 deletion rpcs3/Emu/Cell/SPUAnalyser.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ struct spu_itype
CLGTHI,
CLGT,
CLGTI, // compare_tag last

RPCS3_OPTIMIZER,
};

using enum type;
Expand All @@ -257,7 +259,7 @@ struct spu_itype
// Test for 4-op instruction
friend constexpr bool operator &(type value, quadrop_tag)
{
return value >= MPYA && value <= FMS;
return (value >= MPYA && value <= FMS) || value == RPCS3_OPTIMIZER;
}

// Test for xfloat instruction
Expand Down Expand Up @@ -519,6 +521,7 @@ struct spu_iflag
FCMEQ,
FCGT,
FCMGT,
RPCS3_OPTIMIZER,
};

// Enable address-of operator for spu_decoder<>
Expand Down Expand Up @@ -732,6 +735,7 @@ struct spu_iname
NAME(FMA);
NAME(FNMS);
NAME(FMS);
NAME(RPCS3_OPTIMIZER);
};

#undef NAME
Loading
Loading