From 5c755f09f0e3cb2914e4c529fcf8c4d3ee6cc629 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 12 Jan 2014 19:21:40 -0800 Subject: [PATCH] Fixing addresses, perhaps. --- src/alloy/backend/ivm/ivm_intcode.cc | 4 ++-- src/alloy/frontend/ppc/ppc_emit_altivec.cc | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index 61f6e0e0a..d8942a343 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -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) { diff --git a/src/alloy/frontend/ppc/ppc_emit_altivec.cc b/src/alloy/frontend/ppc/ppc_emit_altivec.cc index 535f206a6..ed6a2cae5 100644 --- a/src/alloy/frontend/ppc/ppc_emit_altivec.cc +++ b/src/alloy/frontend/ppc/ppc_emit_altivec.cc @@ -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; }