diff --git a/include/dynarmic/A64/a64.h b/include/dynarmic/A64/a64.h index 189e2857..58276efc 100644 --- a/include/dynarmic/A64/a64.h +++ b/include/dynarmic/A64/a64.h @@ -6,6 +6,7 @@ #pragma once +#include #include #include #include @@ -68,16 +69,24 @@ public: /// Modify general-purpose register. void SetRegister(size_t index, std::uint64_t value); - struct Vector { - std::uint64_t low; - std::uint64_t high; - }; + /// Read all general-purpose registers. + std::array GetRegisters() const; + /// Modify all general-purpose registers. + void SetRegisters(const std::array& value); + + using Vector = std::array; + static_assert(sizeof(Vector) == sizeof(std::uint64_t) * 2); /// Read floating point and SIMD register. Vector GetVector(std::size_t index) const; /// Modify floating point and SIMD register. void SetVector(std::size_t index, Vector value); + /// Read all floating point and SIMD registers. + std::array GetVectors() const; + /// Modify all floating point and SIMD registers. + void SetVectors(const std::array& value); + /// View FPCR. std::uint32_t GetFpcr() const; /// Modify FPCR. diff --git a/src/backend_x64/a64_interface.cpp b/src/backend_x64/a64_interface.cpp index 9208c516..68823abb 100644 --- a/src/backend_x64/a64_interface.cpp +++ b/src/backend_x64/a64_interface.cpp @@ -4,6 +4,7 @@ * General Public License version 2 or any later version. */ +#include #include #include @@ -108,13 +109,33 @@ public: jit_state.reg.at(index) = value; } + std::array GetRegisters() const { + return jit_state.reg; + } + + void SetRegisters(const std::array& value) { + jit_state.reg = value; + } + Vector GetVector(size_t index) const { return {jit_state.vec.at(index * 2), jit_state.vec.at(index * 2 + 1)}; } void SetVector(size_t index, Vector value) { - jit_state.vec.at(index * 2) = value.low; - jit_state.vec.at(index * 2 + 1) = value.high; + jit_state.vec.at(index * 2) = value[0]; + jit_state.vec.at(index * 2 + 1) = value[1]; + } + + std::array GetVectors() const { + std::array ret; + static_assert(sizeof(ret) == sizeof(jit_state.vec)); + std::memcpy(ret.data(), jit_state.vec.data(), sizeof(jit_state.vec)); + return ret; + } + + void SetVectors(const std::array& value) { + static_assert(sizeof(value) == sizeof(jit_state.vec)); + std::memcpy(jit_state.vec.data(), value.data(), sizeof(jit_state.vec)); } u32 GetFpcr() const { @@ -249,6 +270,14 @@ void Jit::SetRegister(size_t index, u64 value) { impl->SetRegister(index, value); } +std::array Jit::GetRegisters() const { + return impl->GetRegisters(); +} + +void Jit::SetRegisters(const std::array& value) { + impl->SetRegisters(value); +} + Jit::Vector Jit::GetVector(size_t index) const { return impl->GetVector(index); } @@ -257,6 +286,14 @@ void Jit::SetVector(size_t index, Vector value) { impl->SetVector(index, value); } +std::array Jit::GetVectors() const { + return impl->GetVectors(); +} + +void Jit::SetVectors(const std::array& value) { + impl->SetVectors(value); +} + u32 Jit::GetFpcr() const { return impl->GetFpcr(); }