Jit64: turn 32 bit addresses into offsets

This commit is contained in:
Tillmann Karras
2015-04-20 20:47:51 +02:00
parent 9f15054358
commit a0597f0d62
11 changed files with 82 additions and 74 deletions

View File

@ -218,17 +218,17 @@ inline OpArg M(const T* ptr) {return OpArg((u64)(const void*)ptr, (int)SCALE_
inline OpArg R(X64Reg value) {return OpArg(0, SCALE_NONE, value);}
inline OpArg MatR(X64Reg value) {return OpArg(0, SCALE_ATREG, value);}
inline OpArg MDisp(X64Reg value, int offset)
inline OpArg MDisp(X64Reg value, ptrdiff_t offset)
{
return OpArg((u32)offset, SCALE_ATREG, value);
return OpArg(offset, SCALE_ATREG, value);
}
inline OpArg MComplex(X64Reg base, X64Reg scaled, int scale, int offset)
inline OpArg MComplex(X64Reg base, X64Reg scaled, int scale, ptrdiff_t offset)
{
return OpArg(offset, scale, base, scaled);
}
inline OpArg MScaled(X64Reg scaled, int scale, int offset)
inline OpArg MScaled(X64Reg scaled, int scale, ptrdiff_t offset)
{
if (scale == SCALE_1)
return OpArg(offset, SCALE_ATREG, scaled);
@ -247,17 +247,10 @@ inline OpArg Imm32(u32 imm) {return OpArg(imm, SCALE_IMM32);}
inline OpArg Imm64(u64 imm) {return OpArg(imm, SCALE_IMM64);}
inline OpArg ImmPtr(const void* imm) {return Imm64((u64)imm);}
inline u32 PtrOffset(const void* ptr, const void* base)
inline bool FitsInS32(const ptrdiff_t distance)
{
s64 distance = (s64)ptr-(s64)base;
if (distance >= 0x80000000LL ||
distance < -0x80000000LL)
{
_assert_msg_(DYNA_REC, 0, "pointer offset out of range");
return 0;
}
return (u32)distance;
return distance < 0x80000000LL &&
distance >= -0x80000000LL;
}
//usage: int a[]; ARRAY_OFFSET(a,10)