From 9fe2bf873348e7cfbb4728c439abc1b83f172872 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Thu, 26 Jul 2018 19:25:35 +0100 Subject: [PATCH] a32_emit_x64: Assert that memory layout assumption in EmitA32GetCpsr is valid --- src/backend_x64/a32_emit_x64.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/backend_x64/a32_emit_x64.cpp b/src/backend_x64/a32_emit_x64.cpp index 09c91451..5c9d8a89 100644 --- a/src/backend_x64/a32_emit_x64.cpp +++ b/src/backend_x64/a32_emit_x64.cpp @@ -287,6 +287,7 @@ void A32EmitX64::EmitA32GetCpsr(A32EmitContext& ctx, IR::Inst* inst) { // Here we observe that CPSR_q and CPSR_nzcv are right next to each other in memory, // so we load them both at the same time with one 64-bit read. This allows us to // extract all of their bits together at once with one pext. + static_assert(offsetof(A32JitState, CPSR_q) + 4 == offsetof(A32JitState, CPSR_nzcv)); code.mov(result.cvt64(), qword[r15 + offsetof(A32JitState, CPSR_q)]); code.mov(b.cvt64(), 0xF000000000000001ull); code.pext(result.cvt64(), result.cvt64(), b.cvt64());