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/Core/MIPS/ARM64/Arm64IRRegCache.h
Views: 1401
// Copyright (c) 2023- PPSSPP 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 git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include "ppsspp_config.h"20// In other words, PPSSPP_ARCH(ARM64) || DISASM_ALL.21#if PPSSPP_ARCH(ARM64) || (PPSSPP_PLATFORM(WINDOWS) && !defined(__LIBRETRO__))2223#include "Common/Arm64Emitter.h"24#include "Core/MIPS/MIPS.h"25#include "Core/MIPS/IR/IRJit.h"26#include "Core/MIPS/IR/IRRegCache.h"2728namespace Arm64IRJitConstants {2930const Arm64Gen::ARM64Reg DOWNCOUNTREG = Arm64Gen::W25;31// Note: this is actually offset from the base.32const Arm64Gen::ARM64Reg JITBASEREG = Arm64Gen::X26;33const Arm64Gen::ARM64Reg CTXREG = Arm64Gen::X27;34const Arm64Gen::ARM64Reg MEMBASEREG = Arm64Gen::X28;35const Arm64Gen::ARM64Reg SCRATCH1_64 = Arm64Gen::X16;36const Arm64Gen::ARM64Reg SCRATCH2_64 = Arm64Gen::X17;37const Arm64Gen::ARM64Reg SCRATCH1 = Arm64Gen::W16;38const Arm64Gen::ARM64Reg SCRATCH2 = Arm64Gen::W17;39// TODO: How many do we actually need?40const Arm64Gen::ARM64Reg SCRATCHF1 = Arm64Gen::S0;41const Arm64Gen::ARM64Reg SCRATCHF2 = Arm64Gen::S1;42const Arm64Gen::ARM64Reg SCRATCHF3 = Arm64Gen::S2;43const Arm64Gen::ARM64Reg SCRATCHF4 = Arm64Gen::S3;4445} // namespace X64IRJitConstants4647class Arm64IRRegCache : public IRNativeRegCacheBase {48public:49Arm64IRRegCache(MIPSComp::JitOptions *jo);5051void Init(Arm64Gen::ARM64XEmitter *emitter, Arm64Gen::ARM64FloatEmitter *fp);5253// May fail and return INVALID_REG if it needs flushing.54Arm64Gen::ARM64Reg TryMapTempImm(IRReg reg);5556// Returns an arm64 register containing the requested MIPS register.57Arm64Gen::ARM64Reg MapGPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);58Arm64Gen::ARM64Reg MapGPR2(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);59Arm64Gen::ARM64Reg MapGPRAsPointer(IRReg reg);60Arm64Gen::ARM64Reg MapFPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);61Arm64Gen::ARM64Reg MapVec2(IRReg first, MIPSMap mapFlags = MIPSMap::INIT);62Arm64Gen::ARM64Reg MapVec4(IRReg first, MIPSMap mapFlags = MIPSMap::INIT);6364Arm64Gen::ARM64Reg MapWithFPRTemp(const IRInst &inst);6566void FlushBeforeCall();67void FlushAll(bool gprs = true, bool fprs = true) override;6869Arm64Gen::ARM64Reg GetAndLockTempGPR();70Arm64Gen::ARM64Reg GetAndLockTempFPR();7172Arm64Gen::ARM64Reg R(IRReg preg); // Returns a cached register, while checking that it's NOT mapped as a pointer73Arm64Gen::ARM64Reg R64(IRReg preg);74Arm64Gen::ARM64Reg RPtr(IRReg preg); // Returns a cached register, if it has been mapped as a pointer75Arm64Gen::ARM64Reg F(IRReg preg);76Arm64Gen::ARM64Reg FD(IRReg preg);77Arm64Gen::ARM64Reg FQ(IRReg preg);7879// These are called once on startup to generate functions, that you should then call.80void EmitLoadStaticRegisters();81void EmitSaveStaticRegisters();8283protected:84const StaticAllocation *GetStaticAllocations(int &count) const override;85const int *GetAllocationOrder(MIPSLoc type, MIPSMap flags, int &count, int &base) const override;86void AdjustNativeRegAsPtr(IRNativeReg nreg, bool state) override;8788bool IsNativeRegCompatible(IRNativeReg nreg, MIPSLoc type, MIPSMap flags, int lanes) override;89void LoadNativeReg(IRNativeReg nreg, IRReg first, int lanes) override;90void StoreNativeReg(IRNativeReg nreg, IRReg first, int lanes) override;91void SetNativeRegValue(IRNativeReg nreg, uint32_t imm) override;92void StoreRegValue(IRReg mreg, uint32_t imm) override;93bool TransferNativeReg(IRNativeReg nreg, IRNativeReg dest, MIPSLoc type, IRReg first, int lanes, MIPSMap flags) override;9495private:96bool TransferVecTo1(IRNativeReg nreg, IRNativeReg dest, IRReg first, int oldlanes);97bool Transfer1ToVec(IRNativeReg nreg, IRNativeReg dest, IRReg first, int lanes);9899IRNativeReg GPRToNativeReg(Arm64Gen::ARM64Reg r);100IRNativeReg VFPToNativeReg(Arm64Gen::ARM64Reg r);101Arm64Gen::ARM64Reg FromNativeReg(IRNativeReg r);102Arm64Gen::ARM64Reg FromNativeReg64(IRNativeReg r);103104Arm64Gen::ARM64XEmitter *emit_ = nullptr;105Arm64Gen::ARM64FloatEmitter *fp_ = nullptr;106107enum {108NUM_X_REGS = 32,109NUM_X_FREGS = 32,110};111};112113#endif114115116