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/x86/X64IRCompBranch.cpp
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#include "ppsspp_config.h"18#if PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)1920#include "Core/MIPS/x86/X64IRJit.h"21#include "Core/MIPS/x86/X64IRRegCache.h"2223// This file contains compilation for exits.24//25// All functions should have CONDITIONAL_DISABLE, so we can narrow things down to a file quickly.26// Currently known non working ones should have DISABLE. No flags because that's in IR already.2728// #define CONDITIONAL_DISABLE { CompIR_Generic(inst); return; }29#define CONDITIONAL_DISABLE {}30#define DISABLE { CompIR_Generic(inst); return; }31#define INVALIDOP { _assert_msg_(false, "Invalid IR inst %d", (int)inst.op); CompIR_Generic(inst); return; }3233namespace MIPSComp {3435using namespace Gen;36using namespace X64IRJitConstants;3738void X64JitBackend::CompIR_Exit(IRInst inst) {39CONDITIONAL_DISABLE;4041X64Reg exitReg = INVALID_REG;42switch (inst.op) {43case IROp::ExitToConst:44FlushAll();45WriteConstExit(inst.constant);46break;4748case IROp::ExitToReg:49exitReg = regs_.MapGPR(inst.src1);50FlushAll();51MOV(32, R(SCRATCH1), R(exitReg));52JMP(dispatcherPCInSCRATCH1_, true);53break;5455case IROp::ExitToPC:56FlushAll();57JMP(dispatcherCheckCoreState_, true);58break;5960default:61INVALIDOP;62break;63}64}6566void X64JitBackend::CompIR_ExitIf(IRInst inst) {67CONDITIONAL_DISABLE;6869X64Reg lhs = INVALID_REG;70X64Reg rhs = INVALID_REG;71FixupBranch fixup;72switch (inst.op) {73case IROp::ExitToConstIfEq:74case IROp::ExitToConstIfNeq:75regs_.Map(inst);76lhs = regs_.RX(inst.src1);77rhs = regs_.RX(inst.src2);78// This won't change those regs, intentionally. It might affect flags, though.79FlushAll();8081CMP(32, R(lhs), R(rhs));82switch (inst.op) {83case IROp::ExitToConstIfEq:84fixup = J_CC(CC_NE);85break;8687case IROp::ExitToConstIfNeq:88fixup = J_CC(CC_E);89break;9091default:92INVALIDOP;93break;94}9596WriteConstExit(inst.constant);97SetJumpTarget(fixup);98break;99100case IROp::ExitToConstIfGtZ:101case IROp::ExitToConstIfGeZ:102case IROp::ExitToConstIfLtZ:103case IROp::ExitToConstIfLeZ:104regs_.Map(inst);105lhs = regs_.RX(inst.src1);106FlushAll();107108CMP(32, R(lhs), Imm32(0));109switch (inst.op) {110case IROp::ExitToConstIfGtZ:111fixup = J_CC(CC_LE, lhs);112break;113114case IROp::ExitToConstIfGeZ:115fixup = J_CC(CC_L, lhs);116break;117118case IROp::ExitToConstIfLtZ:119fixup = J_CC(CC_GE, lhs);120break;121122case IROp::ExitToConstIfLeZ:123fixup = J_CC(CC_G, lhs);124break;125126default:127INVALIDOP;128break;129}130131WriteConstExit(inst.constant);132SetJumpTarget(fixup);133break;134135case IROp::ExitToConstIfFpTrue:136case IROp::ExitToConstIfFpFalse:137// Note: not used.138DISABLE;139break;140141default:142INVALIDOP;143break;144}145}146147} // namespace MIPSComp148149#endif150151152