CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/ABI.h
Views: 1401
// Copyright (C) 2003 Dolphin Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official SVN repository and contact information can be found at15// http://code.google.com/p/dolphin-emu/1617#pragma once1819#include "ppsspp_config.h"2021// x86/x64 ABI:s, and helpers to help follow them when JIT-ing code.22// All convensions return values in EAX (+ possibly EDX).2324// Linux 32-bit, Windows 32-bit (cdecl, System V):25// * Caller pushes left to right26// * Caller fixes stack after call27// * function subtract from stack for local storage only.28// Scratch: EAX ECX EDX29// Callee-save: EBX ESI EDI EBP30// Parameters: -3132// Windows 64-bit33// * 4-reg "fastcall" variant, very new-skool stack handling34// * Callee moves stack pointer, to make room for shadow regs for the biggest function _it itself calls_35// * Parameters passed in RCX, RDX, ... further parameters are MOVed into the allocated stack space.36// Scratch: RAX RCX RDX R8 R9 R10 R1137// Callee-save: RBX RSI RDI RBP R12 R13 R14 R1538// Parameters: RCX RDX R8 R9, further MOV-ed3940// Linux 64-bit41// * 6-reg "fastcall" variant, old skool stack handling (parameters are pushed)42// Scratch: RAX RCX RDX RSI RDI R8 R9 R10 R1143// Callee-save: RBX RBP R12 R13 R14 R1544// Parameters: RDI RSI RDX RCX R8 R94546#if PPSSPP_ARCH(X86) // 32 bit calling convention, shared by all4748// 32-bit don't pass parameters in regs, but these are convenient to have anyway when we have to49// choose regs to put stuff in.50#define ABI_PARAM1 RCX51#define ABI_PARAM2 RDX5253// There are no ABI_PARAM* here, since args are pushed.54// 32-bit bog standard cdecl, shared between linux and windows55// MacOSX 32-bit is same as System V with a few exceptions that we probably don't care much about.5657#elif PPSSPP_ARCH(AMD64) // 64 bit calling convention5859#ifdef _WIN32 // 64-bit Windows - the really exotic calling convention6061#define ABI_PARAM1 RCX62#define ABI_PARAM2 RDX63#define ABI_PARAM3 R864#define ABI_PARAM4 R96566#else //64-bit Unix (hopefully MacOSX too)6768#define ABI_PARAM1 RDI69#define ABI_PARAM2 RSI70#define ABI_PARAM3 RDX71#define ABI_PARAM4 RCX72#define ABI_PARAM5 R873#define ABI_PARAM6 R97475#endif // WIN327677#endif // X86787980