Fixing addresses, perhaps.

This commit is contained in:
Ben Vanik 2014-01-12 19:21:40 -08:00
parent 413aa06605
commit 5c755f09f0
2 changed files with 16 additions and 10 deletions

View File

@ -1456,7 +1456,7 @@ uint32_t IntCode_LOAD_V128(IntCodeState& ics, const IntCode* i) {
uint32_t address = ics.rf[i->src1_reg].u32;
vec128_t& dest = ics.rf[i->dest_reg].v128;
for (int n = 0; n < 4; n++) {
dest.i4[n] = *((uint32_t*)(ics.membase + (address & ~0xF) + n * 4));
dest.i4[n] = *((uint32_t*)(ics.membase + address + n * 4));
}
DPRINT("[%e, %e, %e, %e] [%.8X, %.8X, %.8X, %.8X] = load v128 %.8X\n",
dest.f4[0], dest.f4[1], dest.f4[2], dest.f4[3],
@ -1558,7 +1558,7 @@ uint32_t IntCode_STORE_V128(IntCodeState& ics, const IntCode* i) {
ics.rf[i->src2_reg].v128.f4[0], ics.rf[i->src2_reg].v128.f4[1], ics.rf[i->src2_reg].v128.f4[2], ics.rf[i->src2_reg].v128.f4[3],
ics.rf[i->src2_reg].v128.i4[0], ics.rf[i->src2_reg].v128.i4[1], ics.rf[i->src2_reg].v128.i4[2], ics.rf[i->src2_reg].v128.i4[3]);
DFLUSH();
*((vec128_t*)(ics.membase + (address & ~0xF))) = ics.rf[i->src2_reg].v128;
*((vec128_t*)(ics.membase + address)) = ics.rf[i->src2_reg].v128;
return IA_NEXT;
}
int Translate_STORE(TranslationContext& ctx, Instr* i) {

View File

@ -174,7 +174,7 @@ XEEMITTER(lvsr128, VX128_1(4, 67), VX128_1)(PPCHIRBuilder& f, InstrData
}
int InstrEmit_lvx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, uint32_t rb) {
Value* ea = CalculateEA_0(f, ra, rb);
Value* ea = f.And(CalculateEA_0(f, ra, rb), f.LoadConstant(~0xFull));
f.StoreVR(vd, f.ByteSwap(f.Load(ea, VEC128_TYPE)));
return 0;
}
@ -224,7 +224,7 @@ XEEMITTER(stvewx128, VX128_1(4, 387), VX128_1)(PPCHIRBuilder& f, InstrData
}
int InstrEmit_stvx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, uint32_t rb) {
Value* ea = CalculateEA_0(f, ra, rb);
Value* ea = f.And(CalculateEA_0(f, ra, rb), f.LoadConstant(~0xFull));
f.Store(ea, f.ByteSwap(f.LoadVR(vd)));
return 0;
}
@ -246,7 +246,8 @@ XEEMITTER(stvxl128, VX128_1(4, 963), VX128_1)(PPCHIRBuilder& f, InstrData
int InstrEmit_lvlx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, uint32_t rb) {
Value* ea = CalculateEA_0(f, ra, rb);
Value* eb = f.And(f.Truncate(ea, INT8_TYPE), f.LoadConstant((int8_t)0xF));
// ea &= ~0xF (load takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
// v = (new << eb)
Value* v = f.Permute(
f.LoadVectorShl(eb),
@ -272,7 +273,8 @@ XEEMITTER(lvlxl128, VX128_1(4, 1539), VX128_1)(PPCHIRBuilder& f, InstrData
int InstrEmit_lvrx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, uint32_t rb) {
Value* ea = CalculateEA_0(f, ra, rb);
Value* eb = f.And(f.Truncate(ea, INT8_TYPE), f.LoadConstant((int8_t)0xF));
// ea &= ~0xF (load takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
// v = (new >> (16 - eb))
Value* v = f.Permute(
f.LoadVectorShr(f.Sub(f.LoadConstant((int8_t)16), eb)),
@ -301,7 +303,8 @@ int InstrEmit_stvlx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, u
Value* ea = CalculateEA_0(f, ra, rb);
Value* eb = f.And(f.Truncate(ea, INT8_TYPE), f.LoadConstant((int8_t)0xF));
Value* new_value = f.LoadVR(vd);
// ea &= ~0xF (load takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
Value* old_value = f.ByteSwap(f.Load(ea, VEC128_TYPE));
// v = (new >> eb) | (old & (ONE << (16 - eb)))
Value* v = f.Permute(
@ -318,7 +321,8 @@ int InstrEmit_stvlx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, u
f.Not(f.LoadZero(VEC128_TYPE)),
f.LoadZero(VEC128_TYPE),
INT8_TYPE)));
// ea &= ~0xF (store takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
f.Store(ea, f.ByteSwap(v));
return 0;
}
@ -341,7 +345,8 @@ int InstrEmit_stvrx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, u
Value* ea = CalculateEA_0(f, ra, rb);
Value* eb = f.And(f.Truncate(ea, INT8_TYPE), f.LoadConstant((int8_t)0xF));
Value* new_value = f.LoadVR(vd);
// ea &= ~0xF (load takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
Value* old_value = f.ByteSwap(f.Load(ea, VEC128_TYPE));
// v = (new << (16 - eb)) | (old & (ONE >> eb))
Value* v = f.Permute(
@ -358,7 +363,8 @@ int InstrEmit_stvrx_(PPCHIRBuilder& f, InstrData& i, uint32_t vd, uint32_t ra, u
f.LoadZero(VEC128_TYPE),
f.Not(f.LoadZero(VEC128_TYPE)),
INT8_TYPE)));
// ea &= ~0xF (store takes care of this)
// ea &= ~0xF
ea = f.And(ea, f.LoadConstant(~0xFull));
f.Store(ea, f.ByteSwap(v));
return 0;
}