2016-08-24 21:07:08 +02:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
|
|
* General Public License version 2 or any later version.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
|
|
|
|
#include "backend_x64/hostloc.h"
|
|
|
|
|
2018-01-26 14:51:48 +01:00
|
|
|
namespace Dynarmic::BackendX64 {
|
2016-08-24 21:07:08 +02:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
|
|
constexpr HostLoc ABI_RETURN = HostLoc::RAX;
|
|
|
|
|
|
|
|
constexpr HostLoc ABI_PARAM1 = HostLoc::RCX;
|
|
|
|
constexpr HostLoc ABI_PARAM2 = HostLoc::RDX;
|
|
|
|
constexpr HostLoc ABI_PARAM3 = HostLoc::R8;
|
|
|
|
constexpr HostLoc ABI_PARAM4 = HostLoc::R9;
|
|
|
|
|
2016-09-01 00:53:16 +02:00
|
|
|
constexpr std::array<HostLoc, 12> ABI_ALL_CALLER_SAVE = {
|
2016-08-24 21:07:08 +02:00
|
|
|
HostLoc::RCX,
|
|
|
|
HostLoc::RDX,
|
|
|
|
HostLoc::R8,
|
|
|
|
HostLoc::R9,
|
|
|
|
HostLoc::R10,
|
|
|
|
HostLoc::R11,
|
|
|
|
HostLoc::XMM0,
|
|
|
|
HostLoc::XMM1,
|
|
|
|
HostLoc::XMM2,
|
|
|
|
HostLoc::XMM3,
|
|
|
|
HostLoc::XMM4,
|
|
|
|
HostLoc::XMM5,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr std::array<HostLoc, 18> ABI_ALL_CALLEE_SAVE = {
|
|
|
|
HostLoc::RBX,
|
|
|
|
HostLoc::RSI,
|
|
|
|
HostLoc::RDI,
|
|
|
|
HostLoc::RBP,
|
|
|
|
HostLoc::R12,
|
|
|
|
HostLoc::R13,
|
|
|
|
HostLoc::R14,
|
|
|
|
HostLoc::R15,
|
|
|
|
HostLoc::XMM6,
|
|
|
|
HostLoc::XMM7,
|
|
|
|
HostLoc::XMM8,
|
|
|
|
HostLoc::XMM9,
|
|
|
|
HostLoc::XMM10,
|
|
|
|
HostLoc::XMM11,
|
|
|
|
HostLoc::XMM12,
|
|
|
|
HostLoc::XMM13,
|
|
|
|
HostLoc::XMM14,
|
|
|
|
HostLoc::XMM15,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr size_t ABI_SHADOW_SPACE = 32; // bytes
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
constexpr HostLoc ABI_RETURN = HostLoc::RAX;
|
|
|
|
|
|
|
|
constexpr HostLoc ABI_PARAM1 = HostLoc::RDI;
|
|
|
|
constexpr HostLoc ABI_PARAM2 = HostLoc::RSI;
|
|
|
|
constexpr HostLoc ABI_PARAM3 = HostLoc::RDX;
|
|
|
|
constexpr HostLoc ABI_PARAM4 = HostLoc::RCX;
|
|
|
|
|
2016-09-01 00:53:16 +02:00
|
|
|
constexpr std::array<HostLoc, 24> ABI_ALL_CALLER_SAVE = {
|
2016-08-24 21:07:08 +02:00
|
|
|
HostLoc::RCX,
|
|
|
|
HostLoc::RDX,
|
|
|
|
HostLoc::RDI,
|
|
|
|
HostLoc::RSI,
|
|
|
|
HostLoc::R8,
|
|
|
|
HostLoc::R9,
|
|
|
|
HostLoc::R10,
|
|
|
|
HostLoc::R11,
|
|
|
|
HostLoc::XMM0,
|
|
|
|
HostLoc::XMM1,
|
|
|
|
HostLoc::XMM2,
|
|
|
|
HostLoc::XMM3,
|
|
|
|
HostLoc::XMM4,
|
|
|
|
HostLoc::XMM5,
|
|
|
|
HostLoc::XMM6,
|
|
|
|
HostLoc::XMM7,
|
|
|
|
HostLoc::XMM8,
|
|
|
|
HostLoc::XMM9,
|
|
|
|
HostLoc::XMM10,
|
|
|
|
HostLoc::XMM11,
|
|
|
|
HostLoc::XMM12,
|
|
|
|
HostLoc::XMM13,
|
|
|
|
HostLoc::XMM14,
|
|
|
|
HostLoc::XMM15,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr std::array<HostLoc, 6> ABI_ALL_CALLEE_SAVE = {
|
|
|
|
HostLoc::RBX,
|
|
|
|
HostLoc::RBP,
|
|
|
|
HostLoc::R12,
|
|
|
|
HostLoc::R13,
|
|
|
|
HostLoc::R14,
|
|
|
|
HostLoc::R15,
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr size_t ABI_SHADOW_SPACE = 0; // bytes
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-09-01 00:53:16 +02:00
|
|
|
static_assert(ABI_ALL_CALLER_SAVE.size() + ABI_ALL_CALLEE_SAVE.size() == 30, "Invalid total number of registers");
|
2016-08-24 21:07:08 +02:00
|
|
|
|
2018-02-03 15:28:57 +01:00
|
|
|
void ABI_PushCalleeSaveRegistersAndAdjustStack(Xbyak::CodeGenerator& code, size_t frame_size = 0);
|
|
|
|
void ABI_PopCalleeSaveRegistersAndAdjustStack(Xbyak::CodeGenerator& code, size_t frame_size = 0);
|
|
|
|
void ABI_PushCallerSaveRegistersAndAdjustStack(Xbyak::CodeGenerator& code, size_t frame_size = 0);
|
|
|
|
void ABI_PopCallerSaveRegistersAndAdjustStack(Xbyak::CodeGenerator& code, size_t frame_size = 0);
|
2016-08-24 21:07:08 +02:00
|
|
|
|
2018-01-26 14:51:48 +01:00
|
|
|
} // namespace Dynarmic::BackendX64
|