mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-25 07:09:48 -06:00
Fixes spacing for "for", "while", "switch" and "if"
Also moved && and || to ends of lines instead of start. Fixed misc vertical alignments and some { needed newlining.
This commit is contained in:
@ -193,9 +193,9 @@ void ARMXEmitter::ORI2R(ARMReg rd, ARMReg rs, u32 val, ARMReg scratch)
|
||||
|
||||
void ARMXEmitter::FlushLitPool()
|
||||
{
|
||||
for(LiteralPool& pool : currentLitPool) {
|
||||
for (LiteralPool& pool : currentLitPool) {
|
||||
// Search for duplicates
|
||||
for(LiteralPool& old_pool : currentLitPool) {
|
||||
for (LiteralPool& old_pool : currentLitPool) {
|
||||
if (old_pool.val == pool.val)
|
||||
pool.loc = old_pool.loc;
|
||||
}
|
||||
@ -242,7 +242,7 @@ void ARMXEmitter::MOVI2R(ARMReg reg, u32 val, bool optimize)
|
||||
{
|
||||
// Use MOVW+MOVT for ARMv7+
|
||||
MOVW(reg, val & 0xFFFF);
|
||||
if(val & 0xFFFF0000)
|
||||
if (val & 0xFFFF0000)
|
||||
MOVT(reg, val, true);
|
||||
} else if (!TrySetValue_TwoOp(reg,val)) {
|
||||
// Use literal pool for ARMv6.
|
||||
|
@ -161,7 +161,7 @@ public:
|
||||
|
||||
Operand2(ARMReg base, ShiftType type, u8 shift)// For IMM shifted register
|
||||
{
|
||||
if(shift == 32) shift = 0;
|
||||
if (shift == 32) shift = 0;
|
||||
switch (type)
|
||||
{
|
||||
case ST_LSL:
|
||||
@ -198,7 +198,7 @@ public:
|
||||
}
|
||||
u32 GetData()
|
||||
{
|
||||
switch(Type)
|
||||
switch (Type)
|
||||
{
|
||||
case TYPE_IMM:
|
||||
return Imm12Mod(); // This'll need to be changed later
|
||||
|
@ -73,11 +73,11 @@ std::vector<std::string> cdio_get_devices()
|
||||
std::vector<std::string> drives;
|
||||
|
||||
kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
|
||||
if( kern_result != KERN_SUCCESS )
|
||||
if (kern_result != KERN_SUCCESS)
|
||||
return( drives );
|
||||
|
||||
classes_to_match = IOServiceMatching( kIOCDMediaClass );
|
||||
if( classes_to_match == nullptr )
|
||||
if (classes_to_match == nullptr)
|
||||
return( drives );
|
||||
|
||||
CFDictionarySetValue( classes_to_match,
|
||||
@ -85,11 +85,11 @@ std::vector<std::string> cdio_get_devices()
|
||||
|
||||
kern_result = IOServiceGetMatchingServices( master_port,
|
||||
classes_to_match, &media_iterator );
|
||||
if( kern_result != KERN_SUCCESS)
|
||||
if (kern_result != KERN_SUCCESS)
|
||||
return( drives );
|
||||
|
||||
next_media = IOIteratorNext( media_iterator );
|
||||
if( next_media != 0 )
|
||||
if (next_media != 0)
|
||||
{
|
||||
char psz_buf[0x32];
|
||||
size_t dev_path_length;
|
||||
@ -101,7 +101,7 @@ std::vector<std::string> cdio_get_devices()
|
||||
IORegistryEntryCreateCFProperty( next_media,
|
||||
CFSTR( kIOBSDNameKey ), kCFAllocatorDefault,
|
||||
0 );
|
||||
if( str_bsd_path == nullptr )
|
||||
if (str_bsd_path == nullptr)
|
||||
{
|
||||
IOObjectRelease( next_media );
|
||||
continue;
|
||||
@ -113,12 +113,12 @@ std::vector<std::string> cdio_get_devices()
|
||||
snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
|
||||
dev_path_length = strlen( psz_buf );
|
||||
|
||||
if( CFStringGetCString( (CFStringRef)str_bsd_path,
|
||||
if (CFStringGetCString( (CFStringRef)str_bsd_path,
|
||||
(char*)&psz_buf + dev_path_length,
|
||||
sizeof(psz_buf) - dev_path_length,
|
||||
kCFStringEncodingASCII))
|
||||
{
|
||||
if(psz_buf != nullptr)
|
||||
if (psz_buf != nullptr)
|
||||
{
|
||||
std::string str = psz_buf;
|
||||
drives.push_back(str);
|
||||
@ -127,7 +127,7 @@ std::vector<std::string> cdio_get_devices()
|
||||
CFRelease( str_bsd_path );
|
||||
IOObjectRelease( next_media );
|
||||
|
||||
} while( ( next_media = IOIteratorNext( media_iterator ) ) != 0 );
|
||||
} while (( next_media = IOIteratorNext( media_iterator ) ) != 0);
|
||||
}
|
||||
IOObjectRelease( media_iterator );
|
||||
return drives;
|
||||
@ -175,7 +175,7 @@ static bool is_cdrom(const std::string& drive, char *mnttype)
|
||||
bool is_cd=false;
|
||||
// If it does exist, verify that it is a cdrom/dvd drive
|
||||
int cdfd = open(drive.c_str(), (O_RDONLY|O_NONBLOCK), 0);
|
||||
if ( cdfd >= 0 )
|
||||
if (cdfd >= 0)
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (ioctl(cdfd, CDROM_GET_CAPABILITY, 0) != -1)
|
||||
|
@ -306,7 +306,7 @@ private:
|
||||
|
||||
void DoVoid(void *data, u32 size)
|
||||
{
|
||||
for(u32 i = 0; i != size; ++i)
|
||||
for (u32 i = 0; i != size; ++i)
|
||||
DoByte(reinterpret_cast<u8*>(data)[i]);
|
||||
}
|
||||
};
|
||||
|
@ -35,8 +35,8 @@ struct ArraySizeImpl : public std::extent<T>
|
||||
#define __GNUC_PREREQ(a, b) 0
|
||||
#endif
|
||||
|
||||
#if (defined __GNUC__ && !__GNUC_PREREQ(4,9)) \
|
||||
&& !defined __SSSE3__ && !defined _M_GENERIC
|
||||
#if (defined __GNUC__ && !__GNUC_PREREQ(4,9)) && \
|
||||
!defined __SSSE3__ && !defined _M_GENERIC
|
||||
#include <emmintrin.h>
|
||||
static __inline __m128i __attribute__((__always_inline__))
|
||||
_mm_shuffle_epi8(__m128i a, __m128i mask)
|
||||
@ -122,18 +122,18 @@ inline u64 _rotr64(u64 x, unsigned int shift){
|
||||
// Retrieve the current thread-specific locale
|
||||
locale_t old_locale = bIsPerThread ? _get_current_locale() : LC_GLOBAL_LOCALE;
|
||||
|
||||
if(new_locale == LC_GLOBAL_LOCALE)
|
||||
if (new_locale == LC_GLOBAL_LOCALE)
|
||||
{
|
||||
// Restore the global locale
|
||||
_configthreadlocale(_DISABLE_PER_THREAD_LOCALE);
|
||||
}
|
||||
else if(new_locale != nullptr)
|
||||
else if (new_locale != nullptr)
|
||||
{
|
||||
// Configure the thread to set the locale only for this thread
|
||||
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
|
||||
|
||||
// Set all locale categories
|
||||
for(int i = LC_MIN; i <= LC_MAX; i++)
|
||||
for (int i = LC_MIN; i <= LC_MAX; i++)
|
||||
setlocale(i, new_locale->locinfo->lc_category[i].locale);
|
||||
}
|
||||
|
||||
|
@ -318,7 +318,7 @@ static void silly_random(u8 * rndArea, u8 count)
|
||||
u16 i;
|
||||
srand((unsigned) (time(nullptr)));
|
||||
|
||||
for(i=0;i<count;i++)
|
||||
for (i=0;i<count;i++)
|
||||
{
|
||||
rndArea[i]=rand();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ void PCSTR2LPTSTR( PCSTR lpszIn, LPTSTR lpszOut )
|
||||
ULONG index = 0;
|
||||
PCSTR lpAct = lpszIn;
|
||||
|
||||
for( ; ; lpAct++ )
|
||||
for ( ; ; lpAct++ )
|
||||
{
|
||||
lpszOut[index++] = (TCHAR)(*lpAct);
|
||||
if ( *lpAct == 0 )
|
||||
@ -196,7 +196,7 @@ static BOOL GetFunctionInfoFromAddresses( ULONG fnAddress, ULONG stackAddress, L
|
||||
if ( _tcsstr( lpszUnDSymbol, _T("(void)") ) == nullptr && _tcsstr( lpszUnDSymbol, _T("()") ) == nullptr)
|
||||
{
|
||||
ULONG index = 0;
|
||||
for( ; ; index++ )
|
||||
for ( ; ; index++ )
|
||||
{
|
||||
lpszParamSep = _tcschr( lpszParsed, _T(',') );
|
||||
if ( lpszParamSep == nullptr )
|
||||
@ -331,7 +331,7 @@ void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
|
||||
|
||||
PrintFunctionAndSourceInfo(file, callStack);
|
||||
|
||||
for( ULONG index = 0; ; index++ )
|
||||
for ( ULONG index = 0; ; index++ )
|
||||
{
|
||||
bResult = StackWalk(
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
@ -347,14 +347,14 @@ void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
|
||||
if ( index == 0 )
|
||||
continue;
|
||||
|
||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||
if (!bResult || callStack.AddrFrame.Offset == 0)
|
||||
break;
|
||||
|
||||
PrintFunctionAndSourceInfo(file, callStack);
|
||||
|
||||
}
|
||||
|
||||
if ( hThread != GetCurrentThread() )
|
||||
if (hThread != GetCurrentThread())
|
||||
ResumeThread( hThread );
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
|
||||
|
||||
// If it's not this thread, let's suspend it, and resume it at the end
|
||||
if ( hThread != GetCurrentThread() )
|
||||
if ( SuspendThread( hThread ) == -1 )
|
||||
if (SuspendThread( hThread ) == -1)
|
||||
{
|
||||
// whaaat ?!
|
||||
etfprint(file, "Call stack info failed\n");
|
||||
@ -386,7 +386,7 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
|
||||
|
||||
PrintFunctionAndSourceInfo(file, callStack);
|
||||
|
||||
for( ULONG index = 0; ; index++ )
|
||||
for (ULONG index = 0; ; index++)
|
||||
{
|
||||
bResult = StackWalk(
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
@ -399,17 +399,17 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
|
||||
SymGetModuleBase,
|
||||
nullptr);
|
||||
|
||||
if ( index == 0 )
|
||||
if (index == 0)
|
||||
continue;
|
||||
|
||||
if( !bResult || callStack.AddrFrame.Offset == 0 )
|
||||
if (!bResult || callStack.AddrFrame.Offset == 0)
|
||||
break;
|
||||
|
||||
PrintFunctionAndSourceInfo(file, callStack);
|
||||
}
|
||||
|
||||
if ( hThread != GetCurrentThread() )
|
||||
ResumeThread( hThread );
|
||||
if (hThread != GetCurrentThread())
|
||||
ResumeThread(hThread);
|
||||
}
|
||||
|
||||
char g_uefbuf[2048];
|
||||
|
@ -78,9 +78,9 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
|
||||
{
|
||||
std::string found(dp->d_name);
|
||||
|
||||
if ((found != ".") && (found != "..")
|
||||
&& (found.size() >= end_match.size())
|
||||
&& std::equal(end_match.rbegin(), end_match.rend(), found.rbegin()))
|
||||
if ((found != ".") && (found != "..") &&
|
||||
(found.size() >= end_match.size()) &&
|
||||
std::equal(end_match.rbegin(), end_match.rend(), found.rbegin()))
|
||||
{
|
||||
std::string full_name;
|
||||
if (_strPath.c_str()[_strPath.size()-1] == DIR_SEP_CHR)
|
||||
|
@ -155,9 +155,9 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
|
||||
const u8 * data = (const u8*)src;
|
||||
const int nblocks = len / 16;
|
||||
u32 Step = (len / 8);
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
if (Step < 1) Step = 1;
|
||||
|
||||
u64 h1 = 0x9368e53c2f6af274;
|
||||
u64 h2 = 0x586dcd208f7cd3fd;
|
||||
@ -171,7 +171,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
|
||||
|
||||
const u64 * blocks = (const u64 *)(data);
|
||||
|
||||
for(int i = 0; i < nblocks; i+=Step)
|
||||
for (int i = 0; i < nblocks; i+=Step)
|
||||
{
|
||||
u64 k1 = getblock(blocks,i*2+0);
|
||||
u64 k2 = getblock(blocks,i*2+1);
|
||||
@ -187,7 +187,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples)
|
||||
u64 k1 = 0;
|
||||
u64 k2 = 0;
|
||||
|
||||
switch(len & 15)
|
||||
switch (len & 15)
|
||||
{
|
||||
case 15: k2 ^= u64(tail[14]) << 48;
|
||||
case 14: k2 ^= u64(tail[13]) << 40;
|
||||
@ -233,10 +233,10 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||
u32 Step = (len / 8);
|
||||
const u64 *data = (const u64 *)src;
|
||||
const u64 *end = data + Step;
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
while(data < end)
|
||||
if (Step < 1) Step = 1;
|
||||
while (data < end)
|
||||
{
|
||||
h = _mm_crc32_u64(h, data[0]);
|
||||
data += Step;
|
||||
@ -265,10 +265,10 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||
u32 Step = (len / 8);
|
||||
const u64 *data = (const u64 *)src;
|
||||
const u64 *end = data + Step;
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
while(data < end)
|
||||
if (Step < 1) Step = 1;
|
||||
while (data < end)
|
||||
{
|
||||
u64 k = data[0];
|
||||
data+=Step;
|
||||
@ -281,7 +281,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||
|
||||
const u8 * data2 = (const u8*)end;
|
||||
|
||||
switch(len & 7)
|
||||
switch (len & 7)
|
||||
{
|
||||
case 7: h ^= u64(data2[6]) << 48;
|
||||
case 6: h ^= u64(data2[5]) << 40;
|
||||
@ -308,10 +308,10 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
|
||||
u32 Step = (len/4);
|
||||
const u32 *data = (const u32 *)src;
|
||||
const u32 *end = data + Step;
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
while(data < end)
|
||||
if (Step < 1) Step = 1;
|
||||
while (data < end)
|
||||
{
|
||||
h = _mm_crc32_u32(h, data[0]);
|
||||
data += Step;
|
||||
@ -380,9 +380,9 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
|
||||
u32 out[2];
|
||||
const int nblocks = len / 8;
|
||||
u32 Step = (len / 4);
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
if (Step < 1) Step = 1;
|
||||
|
||||
u32 h1 = 0x8de1c3ac;
|
||||
u32 h2 = 0xbab98226;
|
||||
@ -395,7 +395,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
|
||||
|
||||
const u32 * blocks = (const u32 *)(data + nblocks*8);
|
||||
|
||||
for(int i = -nblocks; i < 0; i+=Step)
|
||||
for (int i = -nblocks; i < 0; i+=Step)
|
||||
{
|
||||
u32 k1 = getblock(blocks,i*2+0);
|
||||
u32 k2 = getblock(blocks,i*2+1);
|
||||
@ -411,7 +411,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
|
||||
u32 k1 = 0;
|
||||
u32 k2 = 0;
|
||||
|
||||
switch(len & 7)
|
||||
switch (len & 7)
|
||||
{
|
||||
case 7: k2 ^= tail[6] << 16;
|
||||
case 6: k2 ^= tail[5] << 8;
|
||||
@ -456,10 +456,10 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||
u32 Step = (len / 8);
|
||||
const u64 *data = (const u64 *)src;
|
||||
const u64 *end = data + Step;
|
||||
if(samples == 0) samples = max(Step, 1u);
|
||||
if (samples == 0) samples = max(Step, 1u);
|
||||
Step = Step / samples;
|
||||
if(Step < 1) Step = 1;
|
||||
while(data < end)
|
||||
if (Step < 1) Step = 1;
|
||||
while (data < end)
|
||||
{
|
||||
u64 k = data[0];
|
||||
data+=Step;
|
||||
@ -472,7 +472,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
|
||||
|
||||
const u8 * data2 = (const u8*)end;
|
||||
|
||||
switch(len & 7)
|
||||
switch (len & 7)
|
||||
{
|
||||
case 7: h ^= u64(data2[6]) << 48;
|
||||
case 6: h ^= u64(data2[5]) << 40;
|
||||
|
@ -373,8 +373,11 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||
// Lines starting with '$', '*' or '+' are kept verbatim.
|
||||
// Kind of a hack, but the support for raw lines inside an
|
||||
// INI is a hack anyway.
|
||||
if ((key == "" && value == "")
|
||||
|| (line.size() >= 1 && (line[0] == '$' || line[0] == '+' || line[0] == '*')))
|
||||
if ((key == "" && value == "") ||
|
||||
(line.size() >= 1 &&
|
||||
(line[0] == '$' ||
|
||||
line[0] == '+' ||
|
||||
line[0] == '*')))
|
||||
current_section->lines.push_back(line);
|
||||
else
|
||||
current_section->Set(key, value);
|
||||
|
@ -150,8 +150,8 @@ private:
|
||||
{
|
||||
char file_header[sizeof(Header)];
|
||||
|
||||
return (Read(file_header, sizeof(Header))
|
||||
&& !memcmp((const char*)&m_header, file_header, sizeof(Header)));
|
||||
return (Read(file_header, sizeof(Header)) &&
|
||||
!memcmp((const char*)&m_header, file_header, sizeof(Header)));
|
||||
}
|
||||
|
||||
template <typename D>
|
||||
|
@ -195,7 +195,7 @@ void Matrix44::LoadMatrix33(Matrix44 &mtx, const Matrix33 &m33)
|
||||
|
||||
void Matrix44::Set(Matrix44 &mtx, const float mtxArray[16])
|
||||
{
|
||||
for(int i = 0; i < 16; ++i)
|
||||
for (int i = 0; i < 16; ++i)
|
||||
{
|
||||
mtx.data[i] = mtxArray[i];
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ bool MsgAlert(bool yes_no, int Style, const char* format, ...)
|
||||
crit_caption = str_translator(_trans("Critical"));
|
||||
}
|
||||
|
||||
switch(Style)
|
||||
switch (Style)
|
||||
{
|
||||
case INFORMATION:
|
||||
caption = info_caption;
|
||||
|
@ -84,13 +84,13 @@ void SettingsHandler::Reset()
|
||||
|
||||
void SettingsHandler::AddSetting(const std::string& key, const std::string& value)
|
||||
{
|
||||
for(const char& c : key) {
|
||||
for (const char& c : key) {
|
||||
WriteByte(c);
|
||||
}
|
||||
|
||||
WriteByte('=');
|
||||
|
||||
for(const char& c : value) {
|
||||
for (const char& c : value) {
|
||||
WriteByte(c);
|
||||
}
|
||||
|
||||
|
@ -173,8 +173,8 @@ bool TryParse(const std::string &str, u32 *const output)
|
||||
return false;
|
||||
|
||||
#if ULONG_MAX > UINT_MAX
|
||||
if (value >= 0x100000000ull
|
||||
&& value <= 0xFFFFFFFF00000000ull)
|
||||
if (value >= 0x100000000ull &&
|
||||
value <= 0xFFFFFFFF00000000ull)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@ -275,7 +275,7 @@ std::string TabsToSpaces(int tab_size, const std::string &in)
|
||||
|
||||
std::string ReplaceAll(std::string result, const std::string& src, const std::string& dest)
|
||||
{
|
||||
while(1)
|
||||
while (1)
|
||||
{
|
||||
size_t pos = result.find(src);
|
||||
if (pos == std::string::npos) break;
|
||||
@ -336,8 +336,8 @@ std::string UriDecode(const std::string & sSrc)
|
||||
if (*pSrc == '%')
|
||||
{
|
||||
char dec1, dec2;
|
||||
if (16 != (dec1 = HEX2DEC[*(pSrc + 1)])
|
||||
&& 16 != (dec2 = HEX2DEC[*(pSrc + 2)]))
|
||||
if (16 != (dec1 = HEX2DEC[*(pSrc + 1)]) &&
|
||||
16 != (dec2 = HEX2DEC[*(pSrc + 2)]))
|
||||
{
|
||||
*pEnd++ = (dec1 << 4) + dec2;
|
||||
pSrc += 3;
|
||||
|
@ -153,7 +153,7 @@ u64 Timer::GetLocalTimeSinceJan1970()
|
||||
|
||||
// Account for DST where needed
|
||||
gmTime = localtime(&sysTime);
|
||||
if(gmTime->tm_isdst == 1)
|
||||
if (gmTime->tm_isdst == 1)
|
||||
tzDST = 3600;
|
||||
else
|
||||
tzDST = 0;
|
||||
|
@ -287,12 +287,15 @@ void XEmitter::ABI_PopAllCalleeSavedRegsAndAdjustStack() {
|
||||
void XEmitter::ABI_CallFunction(void *func) {
|
||||
ABI_AlignStack(0);
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -302,12 +305,15 @@ void XEmitter::ABI_CallFunctionC16(void *func, u16 param1) {
|
||||
ABI_AlignStack(0);
|
||||
MOV(32, R(ABI_PARAM1), Imm32((u32)param1));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -318,12 +324,15 @@ void XEmitter::ABI_CallFunctionCC16(void *func, u32 param1, u16 param2) {
|
||||
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||
MOV(32, R(ABI_PARAM2), Imm32((u32)param2));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -333,12 +342,15 @@ void XEmitter::ABI_CallFunctionC(void *func, u32 param1) {
|
||||
ABI_AlignStack(0);
|
||||
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -349,12 +361,15 @@ void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) {
|
||||
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -365,12 +380,15 @@ void XEmitter::ABI_CallFunctionCP(void *func, u32 param1, void *param2) {
|
||||
MOV(32, R(ABI_PARAM1), Imm32(param1));
|
||||
MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -382,12 +400,15 @@ void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param
|
||||
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||
MOV(32, R(ABI_PARAM3), Imm32(param3));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -399,12 +420,15 @@ void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *par
|
||||
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||
MOV(64, R(ABI_PARAM3), Imm64((u64)param3));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -417,12 +441,15 @@ void XEmitter::ABI_CallFunctionCCCP(void *func, u32 param1, u32 param2, u32 para
|
||||
MOV(32, R(ABI_PARAM3), Imm32(param3));
|
||||
MOV(64, R(ABI_PARAM4), Imm64((u64)param4));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -433,12 +460,15 @@ void XEmitter::ABI_CallFunctionPC(void *func, void *param1, u32 param2) {
|
||||
MOV(64, R(ABI_PARAM1), Imm64((u64)param1));
|
||||
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -450,12 +480,15 @@ void XEmitter::ABI_CallFunctionPPC(void *func, void *param1, void *param2, u32 p
|
||||
MOV(64, R(ABI_PARAM2), Imm64((u64)param2));
|
||||
MOV(32, R(ABI_PARAM3), Imm32(param3));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -467,12 +500,15 @@ void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
|
||||
if (reg1 != ABI_PARAM1)
|
||||
MOV(32, R(ABI_PARAM1), R(reg1));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -481,24 +517,30 @@ void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) {
|
||||
// Pass two registers as parameters.
|
||||
void XEmitter::ABI_CallFunctionRR(void *func, X64Reg reg1, X64Reg reg2, bool noProlog) {
|
||||
ABI_AlignStack(0, noProlog);
|
||||
if (reg2 != ABI_PARAM1) {
|
||||
if (reg2 != ABI_PARAM1)
|
||||
{
|
||||
if (reg1 != ABI_PARAM1)
|
||||
MOV(64, R(ABI_PARAM1), R(reg1));
|
||||
if (reg2 != ABI_PARAM2)
|
||||
MOV(64, R(ABI_PARAM2), R(reg2));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reg2 != ABI_PARAM2)
|
||||
MOV(64, R(ABI_PARAM2), R(reg2));
|
||||
if (reg1 != ABI_PARAM1)
|
||||
MOV(64, R(ABI_PARAM1), R(reg1));
|
||||
}
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0, noProlog);
|
||||
@ -511,12 +553,15 @@ void XEmitter::ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2
|
||||
MOV(32, R(ABI_PARAM1), arg1);
|
||||
MOV(32, R(ABI_PARAM2), Imm32(param2));
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
@ -528,12 +573,15 @@ void XEmitter::ABI_CallFunctionA(void *func, const Gen::OpArg &arg1)
|
||||
if (!arg1.IsSimpleReg(ABI_PARAM1))
|
||||
MOV(32, R(ABI_PARAM1), arg1);
|
||||
u64 distance = u64(func) - (u64(code) + 5);
|
||||
if (distance >= 0x0000000080000000ULL
|
||||
&& distance < 0xFFFFFFFF80000000ULL) {
|
||||
if (distance >= 0x0000000080000000ULL &&
|
||||
distance < 0xFFFFFFFF80000000ULL)
|
||||
{
|
||||
// Far call
|
||||
MOV(64, R(RAX), Imm64((u64)func));
|
||||
CALLptr(R(RAX));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
CALL(func);
|
||||
}
|
||||
ABI_RestoreStack(0);
|
||||
|
@ -49,7 +49,7 @@ bool DisassembleMov(const unsigned char *codePtr, InstructionInfo *info)
|
||||
|
||||
// Skip two-byte opcode byte
|
||||
bool twoByte = false;
|
||||
if(codeByte == 0x0F)
|
||||
if (codeByte == 0x0F)
|
||||
{
|
||||
twoByte = true;
|
||||
codeByte2 = *codePtr++;
|
||||
|
@ -208,11 +208,12 @@ void OpArg::WriteRest(XEmitter *emit, int extraBytes, X64Reg _operandReg,
|
||||
#if _M_X86_64
|
||||
u64 ripAddr = (u64)emit->GetCodePtr() + 4 + extraBytes;
|
||||
s64 distance = (s64)offset - (s64)ripAddr;
|
||||
_assert_msg_(DYNA_REC, (distance < 0x80000000LL
|
||||
&& distance >= -0x80000000LL) ||
|
||||
!warn_64bit_offset,
|
||||
"WriteRest: op out of range (0x%" PRIx64 " uses 0x%" PRIx64 ")",
|
||||
ripAddr, offset);
|
||||
_assert_msg_(DYNA_REC,
|
||||
(distance < 0x80000000LL &&
|
||||
distance >= -0x80000000LL) ||
|
||||
!warn_64bit_offset,
|
||||
"WriteRest: op out of range (0x%" PRIx64 " uses 0x%" PRIx64 ")",
|
||||
ripAddr, offset);
|
||||
s32 offs = (s32)distance;
|
||||
emit->Write32((u32)offs);
|
||||
#else
|
||||
@ -358,9 +359,9 @@ void XEmitter::JMP(const u8 *addr, bool force5Bytes)
|
||||
{
|
||||
s64 distance = (s64)(fn - ((u64)code + 5));
|
||||
|
||||
_assert_msg_(DYNA_REC, distance >= -0x80000000LL
|
||||
&& distance < 0x80000000LL,
|
||||
"Jump target too far away, needs indirect register");
|
||||
_assert_msg_(DYNA_REC,
|
||||
distance >= -0x80000000LL && distance < 0x80000000LL,
|
||||
"Jump target too far away, needs indirect register");
|
||||
Write8(0xE9);
|
||||
Write32((u32)(s32)distance);
|
||||
}
|
||||
@ -396,9 +397,10 @@ void XEmitter::CALLptr(OpArg arg)
|
||||
void XEmitter::CALL(const void *fnptr)
|
||||
{
|
||||
u64 distance = u64(fnptr) - (u64(code) + 5);
|
||||
_assert_msg_(DYNA_REC, distance < 0x0000000080000000ULL
|
||||
|| distance >= 0xFFFFFFFF80000000ULL,
|
||||
"CALL out of range (%p calls %p)", code, fnptr);
|
||||
_assert_msg_(DYNA_REC,
|
||||
distance < 0x0000000080000000ULL ||
|
||||
distance >= 0xFFFFFFFF80000000ULL,
|
||||
"CALL out of range (%p calls %p)", code, fnptr);
|
||||
Write8(0xE8);
|
||||
Write32(u32(distance));
|
||||
}
|
||||
@ -456,9 +458,9 @@ void XEmitter::J_CC(CCFlags conditionCode, const u8 * addr, bool force5Bytes)
|
||||
else
|
||||
{
|
||||
s64 distance = (s64)(fn - ((u64)code + 6));
|
||||
_assert_msg_(DYNA_REC, distance >= -0x80000000LL
|
||||
&& distance < 0x80000000LL,
|
||||
"Jump target too far away, needs indirect register");
|
||||
_assert_msg_(DYNA_REC,
|
||||
distance >= -0x80000000LL && distance < 0x80000000LL,
|
||||
"Jump target too far away, needs indirect register");
|
||||
Write8(0x0F);
|
||||
Write8(0x80 + conditionCode);
|
||||
Write32((u32)(s32)distance);
|
||||
|
Reference in New Issue
Block a user