Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor spu_iname and ppu_iname #7860

Merged
merged 3 commits into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm
Submodule llvm updated 1 files
+3 −3 azure-pipelines.yml
13 changes: 0 additions & 13 deletions rpcs3/Emu/Cell/PPUAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,6 @@ void fmt_class_string<bs_t<ppu_attr>>::format(std::string& out, u64 arg)
format_bitset(out, arg, "[", ",", "]", &fmt_class_string<ppu_attr>::format);
}

template <>
void fmt_class_string<ppu_iname::type>::format(std::string& out, u64 arg)
{
// Decode instruction name from the enum value
for (u32 i = 0; i < 10; i++)
{
if (u64 value = (arg >> (54 - i * 6)) & 0x3f)
{
out += static_cast<char>(value + 0x20);
}
}
}

void ppu_module::validate(u32 reloc)
{
// Load custom PRX configuration if available
Expand Down
19 changes: 1 addition & 18 deletions rpcs3/Emu/Cell/PPUAnalyser.h
Original file line number Diff line number Diff line change
Expand Up @@ -554,18 +554,9 @@ struct ppu_itype
}
};

// Encode instruction name: 6 bits per character (0x20..0x5f), max 10
static constexpr u64 ppu_iname_encode(const char* ptr, u64 value = 0)
{
return *ptr == '\0' ? value : ppu_iname_encode(ptr + 1, (*ptr - 0x20) | (value << 6));
}

struct ppu_iname
{
#define NAME(x) x = ppu_iname_encode(#x),

enum type : u64
{
#define NAME(x) static constexpr const char& x = *#x;
NAME(UNK)
NAME(MFVSCR)
NAME(MTVSCR)
Expand Down Expand Up @@ -946,15 +937,7 @@ struct ppu_iname
NAME(FCTID)
NAME(FCTIDZ)
NAME(FCFID)
};

#undef NAME

// Enable address-of operator for ppu_decoder<>
friend constexpr type operator &(type value)
{
return value;
}
};

// PPU Analyser Context
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/Emu/Cell/PPUTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using namespace llvm;

constexpr ppu_decoder<PPUTranslator> s_ppu_decoder;
constexpr ppu_decoder<ppu_iname> s_ppu_iname;

PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_module& info, ExecutionEngine& engine)
: cpu_translator(module, false)
Expand Down Expand Up @@ -200,7 +201,7 @@ Function* PPUTranslator::Translate(const ppu_function& info)
if (m_rel)
{
// This is very bad. m_rel is normally set to nullptr after a relocation is handled (so it wasn't)
ppu_log.error("LLVM: [0x%x] Unsupported relocation(%u) in '%s' (opcode=0x%x). Please report.", rel_found->first, m_rel->type, m_info.name, op);
ppu_log.error("LLVM: [0x%x] Unsupported relocation(%u) in '%s' (opcode=0x%x '%s'). Please report.", rel_found->first, m_rel->type, m_info.name, op, s_ppu_iname.decode(op));
return nullptr;
}
}
Expand Down
13 changes: 0 additions & 13 deletions rpcs3/Emu/Cell/SPUAnalyser.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,2 @@
#include "stdafx.h"
#include "SPUAnalyser.h"

template <>
void fmt_class_string<spu_iname::type>::format(std::string& out, u64 arg)
{
// Decode instruction name from the enum value
for (u32 i = 0; i < 10; i++)
{
if (u64 value = (arg >> (54 - i * 6)) & 0x3f)
{
out += static_cast<char>(value + 0x20);
}
}
}