melonDS/src/ARMJIT_x64/ARMJIT_Compiler.h

100 lines
2.4 KiB
C
Raw Normal View History

#ifndef ARMJIT_COMPILER_H
#define ARMJIT_COMPILER_H
#include "../dolphin/x64Emitter.h"
#include "../ARMJIT.h"
2019-06-25 15:09:27 +00:00
#include "../ARMJIT_RegCache.h"
namespace ARMJIT
{
const Gen::X64Reg RCPU = Gen::RBP;
const Gen::X64Reg RCycles = Gen::R14;
const Gen::X64Reg RCPSR = Gen::R15;
const Gen::X64Reg RSCRATCH = Gen::EAX;
const Gen::X64Reg RSCRATCH2 = Gen::EDX;
const Gen::X64Reg RSCRATCH3 = Gen::ECX;
2019-06-25 15:09:27 +00:00
class Compiler;
typedef void (Compiler::*CompileFunc)();
class Compiler : public Gen::X64CodeBlock
{
public:
Compiler();
CompiledBlock CompileBlock(ARM* cpu, FetchedInstr instrs[], int instrsCount);
2019-06-25 15:09:27 +00:00
void LoadReg(int reg, Gen::X64Reg nativeReg);
void UnloadReg(int reg, Gen::X64Reg nativeReg);
private:
2019-06-25 15:09:27 +00:00
CompileFunc GetCompFunc(int kind);
void Comp_AddCycles_C();
void Comp_AddCycles_CI(u32 i);
enum
{
opSetsFlags = 1 << 0,
opSymmetric = 1 << 1,
opRetriveCV = 1 << 2,
opInvertCarry = 1 << 3,
opSyncCarry = 1 << 4,
opInvertOp2 = 1 << 5,
};
void A_Comp_Arith();
void A_Comp_MovOp();
void A_Comp_CmpOp();
2019-06-25 15:09:27 +00:00
void T_Comp_ShiftImm();
void T_Comp_AddSub_();
void T_Comp_ALU_Imm8();
void T_Comp_ALU();
void T_Comp_ALU_HiReg();
2019-06-25 15:09:27 +00:00
void Comp_ArithTriOp(void (Compiler::*op)(int, const Gen::OpArg&, const Gen::OpArg&),
Gen::OpArg rd, Gen::OpArg rn, Gen::OpArg op2, bool carryUsed, int opFlags);
void Comp_ArithTriOpReverse(void (Compiler::*op)(int, const Gen::OpArg&, const Gen::OpArg&),
Gen::OpArg rd, Gen::OpArg rn, Gen::OpArg op2, bool carryUsed, int opFlags);
void Comp_CmpOp(int op, Gen::OpArg rn, Gen::OpArg op2, bool carryUsed);
void Comp_RetriveFlags(bool sign, bool retriveCV, bool carryUsed);
Gen::OpArg Comp_RegShiftImm(int op, int amount, Gen::OpArg rm, bool S, bool& carryUsed);
Gen::OpArg Comp_RegShiftReg(int op, Gen::OpArg rs, Gen::OpArg rm, bool S, bool& carryUsed);
Gen::OpArg A_Comp_GetALUOp2(bool S, bool& carryUsed);
void LoadCPSR();
void SaveCPSR();
2019-06-25 15:09:27 +00:00
Gen::OpArg MapReg(int reg)
{
if (reg == 15 && RegCache.Mapping[reg] == Gen::INVALID_REG)
return Gen::Imm32(R15);
assert(RegCache.Mapping[reg] != Gen::INVALID_REG);
return Gen::R(RegCache.Mapping[reg]);
}
bool CPSRDirty = false;
FetchedInstr CurrentInstr;
2019-06-25 15:09:27 +00:00
RegCache<Compiler, Gen::X64Reg> RegCache;
bool Thumb;
u32 Num;
u32 R15;
u32 ConstantCycles;
};
}
#endif