/* This file is part of the dynarmic project. * Copyright (c) 2018 MerryMage * This software may be used and distributed according to the terms of the GNU * General Public License version 2 or any later version. */ #include "frontend/A64/translate/impl/impl.h" namespace Dynarmic::A64 { static bool OrderedSharedDecodeAndOperation(TranslatorVisitor& tv, size_t size, bool L, bool o0, Reg Rn, Reg Rt) { // Shared Decode const AccType acctype = !o0 ? AccType::LIMITEDORDERED : AccType::ORDERED; const MemOp memop = L ? MemOp::LOAD : MemOp::STORE; const size_t elsize = 8 << size; const size_t regsize = elsize == 64 ? 64 : 32; const size_t datasize = elsize; // Operation const size_t dbytes = datasize / 8; IR::U64 address; if (Rn == Reg::SP) { // TODO: Check SP Alignment address = tv.SP(64); } else { address = tv.X(64, Rn); } switch (memop) { case MemOp::STORE: { IR::UAny data = tv.X(datasize, Rt); tv.Mem(address, dbytes, acctype, data); break; } case MemOp::LOAD: { IR::UAny data = tv.Mem(address, dbytes, acctype); tv.X(regsize, Rt, tv.ZeroExtend(data, regsize)); break; } default: UNREACHABLE(); } return true; } bool TranslatorVisitor::STLR(Imm<2> sz, Reg Rn, Reg Rt) { const size_t size = sz.ZeroExtend(); const bool L = 0; const bool o0 = 1; return OrderedSharedDecodeAndOperation(*this, size, L, o0, Rn, Rt); } bool TranslatorVisitor::LDAR(Imm<2> sz, Reg Rn, Reg Rt) { const size_t size = sz.ZeroExtend(); const bool L = 1; const bool o0 = 1; return OrderedSharedDecodeAndOperation(*this, size, L, o0, Rn, Rt); } } // namespace Dynarmic::A64