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/Arm64IRJit.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 <string>24#include <vector>25#include "Common/Arm64Emitter.h"26#include "Core/MIPS/IR/IRJit.h"27#include "Core/MIPS/IR/IRNativeCommon.h"28#include "Core/MIPS/JitCommon/JitState.h"29#include "Core/MIPS/JitCommon/JitCommon.h"30#include "Core/MIPS/ARM64/Arm64IRRegCache.h"3132namespace MIPSComp {3334class Arm64JitBackend : public Arm64Gen::ARM64CodeBlock, public IRNativeBackend {35public:36Arm64JitBackend(JitOptions &jo, IRBlockCache &blocks);37~Arm64JitBackend();3839bool DescribeCodePtr(const u8 *ptr, std::string &name) const override;4041void GenerateFixedCode(MIPSState *mipsState) override;42bool CompileBlock(IRBlockCache *irBlockCache, int block_num, bool preload) override;43void ClearAllBlocks() override;44void InvalidateBlock(IRBlockCache *irBlockCache, int block_num) override;4546void UpdateFCR31(MIPSState *mipsState) override;4748protected:49const CodeBlockCommon &CodeBlock() const override {50return *this;51}5253private:54void RestoreRoundingMode(bool force = false);55void ApplyRoundingMode(bool force = false);56void UpdateRoundingMode(bool force = false);57void MovFromPC(Arm64Gen::ARM64Reg r);58void MovToPC(Arm64Gen::ARM64Reg r);59// Destroys SCRATCH2.60void WriteDebugPC(uint32_t pc);61void WriteDebugPC(Arm64Gen::ARM64Reg r);62// Destroys SCRATCH2.63void WriteDebugProfilerStatus(IRProfilerStatus status);6465void SaveStaticRegisters();66void LoadStaticRegisters();6768// Note: destroys SCRATCH1.69void FlushAll();7071void WriteConstExit(uint32_t pc);72void OverwriteExit(int srcOffset, int len, int block_num) override;7374void CompIR_Arith(IRInst inst) override;75void CompIR_Assign(IRInst inst) override;76void CompIR_Basic(IRInst inst) override;77void CompIR_Bits(IRInst inst) override;78void CompIR_Breakpoint(IRInst inst) override;79void CompIR_Compare(IRInst inst) override;80void CompIR_CondAssign(IRInst inst) override;81void CompIR_CondStore(IRInst inst) override;82void CompIR_Div(IRInst inst) override;83void CompIR_Exit(IRInst inst) override;84void CompIR_ExitIf(IRInst inst) override;85void CompIR_FArith(IRInst inst) override;86void CompIR_FAssign(IRInst inst) override;87void CompIR_FCompare(IRInst inst) override;88void CompIR_FCondAssign(IRInst inst) override;89void CompIR_FCvt(IRInst inst) override;90void CompIR_FLoad(IRInst inst) override;91void CompIR_FRound(IRInst inst) override;92void CompIR_FSat(IRInst inst) override;93void CompIR_FSpecial(IRInst inst) override;94void CompIR_FStore(IRInst inst) override;95void CompIR_Generic(IRInst inst) override;96void CompIR_HiLo(IRInst inst) override;97void CompIR_Interpret(IRInst inst) override;98void CompIR_Load(IRInst inst) override;99void CompIR_LoadShift(IRInst inst) override;100void CompIR_Logic(IRInst inst) override;101void CompIR_Mult(IRInst inst) override;102void CompIR_RoundingMode(IRInst inst) override;103void CompIR_Shift(IRInst inst) override;104void CompIR_Store(IRInst inst) override;105void CompIR_StoreShift(IRInst inst) override;106void CompIR_System(IRInst inst) override;107void CompIR_Transfer(IRInst inst) override;108void CompIR_VecArith(IRInst inst) override;109void CompIR_VecAssign(IRInst inst) override;110void CompIR_VecClamp(IRInst inst) override;111void CompIR_VecHoriz(IRInst inst) override;112void CompIR_VecLoad(IRInst inst) override;113void CompIR_VecPack(IRInst inst) override;114void CompIR_VecStore(IRInst inst) override;115void CompIR_ValidateAddress(IRInst inst) override;116117struct LoadStoreArg {118Arm64Gen::ARM64Reg base = Arm64Gen::INVALID_REG;119Arm64Gen::ARM64Reg regOffset = Arm64Gen::INVALID_REG;120int immOffset = 0;121bool useUnscaled = false;122bool useRegisterOffset = false;123bool signExtendRegOffset = false;124};125LoadStoreArg PrepareSrc1Address(IRInst inst);126127JitOptions &jo;128Arm64IRRegCache regs_;129Arm64Gen::ARM64FloatEmitter fp_;130131const u8 *outerLoop_ = nullptr;132const u8 *outerLoopPCInSCRATCH1_ = nullptr;133const u8 *dispatcherCheckCoreState_ = nullptr;134const u8 *dispatcherPCInSCRATCH1_ = nullptr;135const u8 *dispatcherNoCheck_ = nullptr;136const u8 *restoreRoundingMode_ = nullptr;137const u8 *applyRoundingMode_ = nullptr;138const u8 *updateRoundingMode_ = nullptr;139140const u8 *saveStaticRegisters_ = nullptr;141const u8 *loadStaticRegisters_ = nullptr;142143// Indexed by FPCR FZ:RN bits for convenience. Uses SCRATCH2.144const u8 *convertS0ToSCRATCH1_[8];145146// Note: mutable state used at runtime.147const u8 *currentRoundingFunc_ = nullptr;148149int jitStartOffset_ = 0;150int compilingBlockNum_ = -1;151int logBlocks_ = 0;152// Only useful in breakpoints, where it's set immediately prior.153uint32_t lastConstPC_ = 0;154};155156class Arm64IRJit : public IRNativeJit {157public:158Arm64IRJit(MIPSState *mipsState)159: IRNativeJit(mipsState), arm64Backend_(jo, blocks_) {160Init(arm64Backend_);161}162163private:164Arm64JitBackend arm64Backend_;165};166167} // namespace MIPSComp168169#endif170171172