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/MIPSCodeUtils.h
Views: 1401
// Copyright (c) 2012- 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 "Common/CommonTypes.h"20#include "Common/Data/Convert/SmallDataConvert.h"21#include "Core/MIPS/MIPS.h"2223// Invalid branch target address24#define INVALIDTARGET 0xFFFFFFFF2526#define MIPS_MAKE_B(offs) (0x10000000 | ((offs) & 0xFFFF))27#define MIPS_MAKE_J(addr) (0x08000000 | ((addr)>>2))28#define MIPS_MAKE_JAL(addr) (0x0C000000 | ((addr)>>2))29#define MIPS_MAKE_JR_RA() (0x03e00008)30#define MIPS_MAKE_NOP() (0)3132#define MIPS_MAKE_ADDIU(dreg, sreg, immval) ((9 << 26) | ((dreg) << 16) | ((sreg) << 21) | (immval))33#define MIPS_MAKE_LUI(reg, immval) (0x3c000000 | ((reg) << 16) | (immval))34#define MIPS_MAKE_ORI(rt, rs, immval) (0x34000000 | ((rs) << 21) | ((rt) << 16) | (immval))35#define MIPS_MAKE_LW(rt, rs, immval) (0x8c000000 | ((rs) << 21) | ((rt) << 16) | (immval))36#define MIPS_MAKE_SYSCALL(module, function) GetSyscallOp(module, GetNibByName(module, function))37#define MIPS_MAKE_BREAK(n) (((n) << 6) | 13) // ! :)3839#define MIPS_GET_OP(op) ((op>>26) & 0x3F)40#define MIPS_GET_FUNC(op) (op & 0x3F)41#define MIPS_GET_SA(op) ((op>>6) & 0x1F)4243#define MIPS_GET_RS(op) MIPSGPReg((op>>21) & 0x1F)44#define MIPS_GET_RT(op) MIPSGPReg((op>>16) & 0x1F)45#define MIPS_GET_RD(op) MIPSGPReg((op>>11) & 0x1F)4647#define MIPS_GET_FS(op) ((op>>11) & 0x1F)48#define MIPS_GET_FT(op) ((op>>16) & 0x1F)49#define MIPS_GET_FD(op) ((op>>6 ) & 0x1F)5051#define MIPS_GET_VD(op) (op & 0x7F)52#define MIPS_GET_VS(op) ((op>>8) & 0x7F)53#define MIPS_GET_VT(op) ((op>>16) & 0x7F)5455inline int32_t SignExtend8ToS32(MIPSOpcode op) {56return SignExtend8ToS32(op.encoding);57}5859inline uint32_t SignExtend8ToU32(MIPSOpcode op) {60return SignExtend8ToU32(op.encoding);61}6263inline int32_t SignExtend16ToS32(MIPSOpcode op) {64return SignExtend16ToS32(op.encoding);65}6667inline uint32_t SignExtend16ToU32(MIPSOpcode op) {68return SignExtend16ToU32(op.encoding);69}7071namespace MIPSCodeUtils72{73u32 GetCallTarget(u32 addr);74u32 GetBranchTarget(u32 addr);75// Ignores bltzal/etc. instructions that change RA.76u32 GetBranchTargetNoRA(u32 addr);77u32 GetBranchTargetNoRA(u32 addr, MIPSOpcode op);78u32 GetJumpTarget(u32 addr);79u32 GetSureBranchTarget(u32 addr);80bool IsVFPUBranch(MIPSOpcode op);81bool IsBranch(MIPSOpcode op);82}838485