CPU: Declare state with constinit

This commit is contained in:
Stenzek 2025-01-02 21:42:41 +10:00
parent 87e367076d
commit e08dda0a0a
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View File

@ -98,7 +98,7 @@ static bool WriteMemoryByte(VirtualMemoryAddress addr, u32 value);
static bool WriteMemoryHalfWord(VirtualMemoryAddress addr, u32 value); static bool WriteMemoryHalfWord(VirtualMemoryAddress addr, u32 value);
static bool WriteMemoryWord(VirtualMemoryAddress addr, u32 value); static bool WriteMemoryWord(VirtualMemoryAddress addr, u32 value);
alignas(HOST_CACHE_LINE_SIZE) State g_state; constinit State g_state;
bool TRACE_EXECUTION = false; bool TRACE_EXECUTION = false;
static fastjmp_buf s_jmp_buf; static fastjmp_buf s_jmp_buf;

View File

@ -70,7 +70,7 @@ struct PGXPValue
} }
}; };
struct State struct ALIGN_TO_CACHE_LINE State
{ {
// ticks the CPU has executed // ticks the CPU has executed
u32 downcount = 0; u32 downcount = 0;
@ -80,8 +80,8 @@ struct State
Registers regs = {}; Registers regs = {};
Cop0Registers cop0_regs = {}; Cop0Registers cop0_regs = {};
u32 pc; // at execution time: the address of the next instruction to execute (already fetched) u32 pc = 0; // at execution time: the address of the next instruction to execute (already fetched)
u32 npc; // at execution time: the address of the next instruction to fetch u32 npc = 0; // at execution time: the address of the next instruction to fetch
// address of the instruction currently being executed // address of the instruction currently being executed
Instruction current_instruction = {}; Instruction current_instruction = {};
@ -125,7 +125,7 @@ struct State
static constexpr u32 GTERegisterOffset(u32 index) { return OFFSETOF(State, gte_regs.r32) + (sizeof(u32) * index); } static constexpr u32 GTERegisterOffset(u32 index) { return OFFSETOF(State, gte_regs.r32) + (sizeof(u32) * index); }
}; };
ALIGN_TO_CACHE_LINE extern State g_state; extern State g_state;
void Initialize(); void Initialize();
void Shutdown(); void Shutdown();