From 70cd51a64b2035f1689574f580e7a1eaff1b1726 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 25 Aug 2010 15:32:17 +0000 Subject: [PATCH] A 'nice' fix for GCC's fickle dislike of packed structs. 1) the VU registers struct no longer needs packed (the unions ensure proper packing); 2) introduction of 128-bit UQ/SQ members. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3689 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/Memory.h | 16 ++++++++++++---- pcsx2/R5900OpcodeImpl.cpp | 2 +- pcsx2/VU.h | 14 +++----------- pcsx2/VU0.cpp | 15 ++++----------- pcsx2/VU0micro.cpp | 3 +-- pcsx2/vtlb.cpp | 10 +--------- pcsx2/vtlb.h | 2 -- 7 files changed, 22 insertions(+), 40 deletions(-) diff --git a/pcsx2/Memory.h b/pcsx2/Memory.h index f9c3fbd269..4a0a72659e 100644 --- a/pcsx2/Memory.h +++ b/pcsx2/Memory.h @@ -135,13 +135,21 @@ extern void mmap_ResetBlockTracking(); #define memRead8 vtlb_memRead #define memRead16 vtlb_memRead #define memRead32 vtlb_memRead -#define memRead64 vtlb_memRead64 -#define memRead128 vtlb_memRead128 #define memWrite8 vtlb_memWrite #define memWrite16 vtlb_memWrite #define memWrite32 vtlb_memWrite -#define memWrite64 vtlb_memWrite64 -#define memWrite128 vtlb_memWrite128 + +static __fi void memRead64(u32 mem, mem64_t* out) { vtlb_memRead64(mem, out); } +static __fi void memRead64(u32 mem, mem64_t& out) { vtlb_memRead64(mem, &out); } + +static __fi void memRead128(u32 mem, mem128_t* out) { vtlb_memRead128(mem, out); } +static __fi void memRead128(u32 mem, mem128_t& out) { vtlb_memRead128(mem, &out); } + +static __fi void memWrite64(u32 mem, const mem64_t* val) { vtlb_memWrite64(mem, val); } +static __fi void memWrite64(u32 mem, const mem64_t& val) { vtlb_memWrite64(mem, &val); } +static __fi void memWrite128(u32 mem, const mem128_t* val) { vtlb_memWrite128(mem, val); } +static __fi void memWrite128(u32 mem, const mem128_t& val) { vtlb_memWrite128(mem, &val); } + extern u16 ba0R16(u32 mem); diff --git a/pcsx2/R5900OpcodeImpl.cpp b/pcsx2/R5900OpcodeImpl.cpp index a990677278..31b0aafb74 100644 --- a/pcsx2/R5900OpcodeImpl.cpp +++ b/pcsx2/R5900OpcodeImpl.cpp @@ -816,7 +816,7 @@ void SQ() // an address error due to unaligned access isn't possible like it is on other loads/stores. u32 addr = cpuRegs.GPR.r[_Rs_].UL[0] + _Imm_; - memWrite128(addr & ~0xf, cpuRegs.GPR.r[_Rt_].UD); + memWrite128(addr & ~0xf, cpuRegs.GPR.r[_Rt_].UQ); } /********************************************************* diff --git a/pcsx2/VU.h b/pcsx2/VU.h index bec6ae8ebf..b10312dfd2 100644 --- a/pcsx2/VU.h +++ b/pcsx2/VU.h @@ -16,10 +16,6 @@ #pragma once #include "Vif.h" -#ifdef _MSC_VER // Most of the structs here should be packed -# pragma pack(1) -#endif - enum VURegFlags { REG_STATUS_FLAG = 16, @@ -68,7 +64,7 @@ union VECTOR { s16 SS[8]; u8 UC[16]; s8 SC[16]; -} __packed; +}; struct REG_VI { union { @@ -82,7 +78,7 @@ struct REG_VI { }; u32 padding[3]; // needs padding to make them 128bit; VU0 maps VU1's VI regs as 128bits to addr 0x4xx0 in // VU0 mem, with only lower 16 bits valid, and the upper 112bits are hardwired to 0 (cottonvibes) -} __packed; +}; //#define VUFLAG_BREAKONMFLAG 0x00000001 #define VUFLAG_MFLAGSET 0x00000002 @@ -158,7 +154,7 @@ struct VURegs { , Micro( NULL ) { } -} __packed; +}; enum VUPipeState { @@ -184,10 +180,6 @@ struct _VURegsNum { int cycles; }; -#ifdef _MSC_VER // Restore to default pack alignment -# pragma pack() -#endif - extern VURegs* g_pVU1; extern __aligned16 VURegs VU0; diff --git a/pcsx2/VU0.cpp b/pcsx2/VU0.cpp index 73bff3eac7..89f123f044 100644 --- a/pcsx2/VU0.cpp +++ b/pcsx2/VU0.cpp @@ -88,15 +88,10 @@ namespace OpcodeImpl void LQC2() { u32 addr = cpuRegs.GPR.r[_Rs_].UL[0] + (s16)cpuRegs.code; if (_Ft_) { -#ifdef __LINUX__ - // Ifdeffing mainly because I haven't gotten around to checking it in Windows yet. - memRead128(addr, &VU0.VF[_Ft_].UQ); -#else - memRead128(addr, VU0.VF[_Ft_].UD); -#endif + memRead128(addr, VU0.VF[_Ft_].UQ); } else { - u64 val[2]; - memRead128(addr, val); + u128 val; + memRead128(addr, val); } } @@ -105,9 +100,7 @@ namespace OpcodeImpl // HUH why ? doesn't make any sense ... void SQC2() { u32 addr = _Imm_ + cpuRegs.GPR.r[_Rs_].UL[0]; - //memWrite64(addr, VU0.VF[_Ft_].UD[0]); - //memWrite64(addr+8,VU0.VF[_Ft_].UD[1]); - memWrite128(addr, VU0.VF[_Ft_].UD); + memWrite128(addr, VU0.VF[_Ft_].UQ); } }}} diff --git a/pcsx2/VU0micro.cpp b/pcsx2/VU0micro.cpp index 7a73094079..ce61075325 100644 --- a/pcsx2/VU0micro.cpp +++ b/pcsx2/VU0micro.cpp @@ -20,11 +20,10 @@ #include "PrecompiledHeader.h" #include "Common.h" +#include "VUmicro.h" #include -#include "VUmicro.h" - using namespace R5900; #define VF_VAL(x) ((x==0x80000000)?0:(x)) diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 7d87bd4f9e..b0beb6783c 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -126,10 +126,6 @@ void __fastcall vtlb_memRead128(u32 mem, mem128_t *out) ((vtlbMemR128FP*)vtlbdata.RWFT[4][0][hand])(paddr, out); } } -void __fastcall vtlb_memRead128(u32 mem, u64 (&out)[2]) -{ - vtlb_memRead128(mem, (mem128_t*)out); -} template< typename DataType > void __fastcall vtlb_memWrite(u32 addr, DataType data) @@ -159,6 +155,7 @@ void __fastcall vtlb_memWrite(u32 addr, DataType data) } } } + void __fastcall vtlb_memWrite64(u32 mem, const mem64_t* value) { u32 vmv=vtlbdata.vmap[mem>>VTLB_PAGE_BITS]; @@ -197,11 +194,6 @@ void __fastcall vtlb_memWrite128(u32 mem, const mem128_t *value) } } -void __fastcall vtlb_memWrite128(u32 mem, const u64 (&out)[2]) -{ - vtlb_memWrite128(mem, (const mem128_t*)out); -} - template mem8_t vtlb_memRead(u32 mem); template mem16_t vtlb_memRead(u32 mem); template mem32_t vtlb_memRead(u32 mem); diff --git a/pcsx2/vtlb.h b/pcsx2/vtlb.h index 7957ac466f..5b048a384e 100644 --- a/pcsx2/vtlb.h +++ b/pcsx2/vtlb.h @@ -71,13 +71,11 @@ template< typename DataType > extern DataType __fastcall vtlb_memRead(u32 mem); extern void __fastcall vtlb_memRead64(u32 mem, mem64_t *out); extern void __fastcall vtlb_memRead128(u32 mem, mem128_t *out); -extern void __fastcall vtlb_memRead128(u32 mem, u64 (&out)[2]); template< typename DataType > extern void __fastcall vtlb_memWrite(u32 mem, DataType value); extern void __fastcall vtlb_memWrite64(u32 mem, const mem64_t* value); extern void __fastcall vtlb_memWrite128(u32 mem, const mem128_t* value); -extern void __fastcall vtlb_memWrite128(u32 mem, const u64 (&value)[2]); extern void vtlb_DynGenWrite(u32 sz); extern void vtlb_DynGenRead32(u32 bits, bool sign);