Skip to content

Commit

Permalink
Make ppu_decoder<> objects constexpr (partial)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Mar 24, 2020
1 parent ecb6d38 commit 1ceb779
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUAnalyser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

LOG_CHANNEL(ppu_validator);

const ppu_decoder<ppu_itype> s_ppu_itype;
constexpr ppu_decoder<ppu_itype> s_ppu_itype;

template<>
void fmt_class_string<ppu_attr>::format(std::string& out, u64 arg)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUDisAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "PPUDisAsm.h"
#include "PPUFunction.h"

const ppu_decoder<PPUDisAsm> s_ppu_disasm;
constexpr ppu_decoder<PPUDisAsm> s_ppu_disasm;

u32 PPUDisAsm::disasm(u32 pc)
{
Expand Down
15 changes: 9 additions & 6 deletions rpcs3/Emu/Cell/PPUOpcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,22 @@ template <typename D, typename T = decltype(&D::UNK)>
class ppu_decoder
{
// Fast lookup table
std::array<T, 0x20000> m_table;
std::array<T, 0x20000> m_table{};

struct instruction_info
{
u32 value;
T pointer;
u32 magn; // Non-zero for "columns" (effectively, number of most significant bits "eaten")

instruction_info(u32 v, T p, u32 m = 0)
constexpr instruction_info(u32 v, T p, u32 m = 0)
: value(v)
, pointer(p)
, magn(m)
{
}

instruction_info(u32 v, const T* p, u32 m = 0)
constexpr instruction_info(u32 v, const T* p, u32 m = 0)
: value(v)
, pointer(*p)
, magn(m)
Expand All @@ -101,7 +101,7 @@ class ppu_decoder
};

// Fill lookup table
void fill_table(u32 main_op, u32 count, u32 sh, std::initializer_list<instruction_info> entries)
constexpr void fill_table(u32 main_op, u32 count, u32 sh, std::initializer_list<instruction_info> entries)
{
if (sh < 11)
{
Expand Down Expand Up @@ -130,9 +130,12 @@ class ppu_decoder
}

public:
ppu_decoder()
constexpr ppu_decoder()
{
m_table.fill(&D::UNK);
for (auto& x : m_table)
{
x = &D::UNK;
}

// Main opcodes (field 0..5)
fill_table(0x00, 6, -1,
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/PPUThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const std::pair<ppu_inter_func_t, ppu_inter_func_t> s_ppu_dispatch_table[]
#undef FUNC
};

extern const ppu_decoder<ppu_interpreter_precise> g_ppu_interpreter_precise([](auto& table)
static const ppu_decoder<ppu_interpreter_precise> g_ppu_interpreter_precise([](auto& table)
{
if (s_use_ssse3)
{
Expand All @@ -135,7 +135,7 @@ extern const ppu_decoder<ppu_interpreter_precise> g_ppu_interpreter_precise([](a
}
});

extern const ppu_decoder<ppu_interpreter_fast> g_ppu_interpreter_fast([](auto& table)
static const ppu_decoder<ppu_interpreter_fast> g_ppu_interpreter_fast([](auto& table)
{
if (!s_use_ssse3)
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/PPUTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using namespace llvm;

const ppu_decoder<PPUTranslator> s_ppu_decoder;
constexpr ppu_decoder<PPUTranslator> s_ppu_decoder;

PPUTranslator::PPUTranslator(LLVMContext& context, Module* module, const ppu_module& info, ExecutionEngine& engine)
: cpu_translator(module, false)
Expand Down
3 changes: 2 additions & 1 deletion rpcs3/cmake_modules/ConfigureCompiler.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check and configure compiler options for RPCS3

if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew /D _CRT_SECURE_NO_DEPRECATE=1 /D _CRT_NON_CONFORMING_SWPRINTFS=1 /D _SCL_SECURE_NO_WARNINGS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew /constexpr:steps16777216 /D _CRT_SECURE_NO_DEPRECATE=1 /D _CRT_NON_CONFORMING_SWPRINTFS=1 /D _SCL_SECURE_NO_WARNINGS=1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _ENABLE_EXTENDED_ALIGNED_STORAGE=1 /D _HAS_EXCEPTIONS=0")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libc.lib /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcd.lib /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:msvcrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /DYNAMICBASE:NO /BASE:0x10000 /FIXED")
Expand Down Expand Up @@ -40,6 +40,7 @@ else()
add_compile_options(-Wno-comment)

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-fconstexpr-steps=16777216)
add_compile_options(-Wno-sometimes-uninitialized)
add_compile_options(-Wno-unused-lambda-capture)
add_compile_options(-Wno-unused-private-field)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3_default.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<ExceptionHandling>false</ExceptionHandling>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<AdditionalOptions>/Zc:throwingNew %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/Zc:throwingNew /constexpr:steps16777216 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<AdditionalDependencies>xxhash.lib;ws2_32.lib;Bcrypt.lib;avcodec.lib;avformat.lib;avutil.lib;swresample.lib;swscale.lib</AdditionalDependencies>
Expand Down

0 comments on commit 1ceb779

Please sign in to comment.