flycast/core/hw/sh4/dyna/shil.cpp

132 lines
2.1 KiB
C++
Raw Normal View History

2014-12-17 11:10:18 +00:00
#include <sstream>
2013-12-19 17:10:14 +00:00
#include "types.h"
#include "hw/sh4/sh4_mem.h"
2019-06-04 19:27:45 +00:00
#include "ngen.h"
#include "hw/sh4/sh4_core.h"
#define SHIL_MODE 1
#include "shil_canonical.h"
#define SHIL_MODE 4
#include "shil_canonical.h"
//#define SHIL_MODE 2
//#include "shil_canonical.h"
#if FEAT_SHREC != DYNAREC_NONE
#define SHIL_MODE 3
#include "shil_canonical.h"
#endif
#include "ssa.h"
2013-12-19 17:10:14 +00:00
void AnalyseBlock(RuntimeBlockInfo* blk)
{
2019-06-10 11:57:10 +00:00
SSAOptimizer optim(blk);
optim.Optimize();
2013-12-19 17:10:14 +00:00
}
2020-03-29 17:29:14 +00:00
std::string name_reg(Sh4RegType reg)
2013-12-19 17:10:14 +00:00
{
2020-03-29 17:29:14 +00:00
std::stringstream ss;
2013-12-19 17:10:14 +00:00
2019-06-04 19:27:45 +00:00
if (reg >= reg_fr_0 && reg <= reg_xf_15)
ss << "f" << (reg - reg_fr_0);
else if (reg <= reg_r15)
2013-12-19 17:10:14 +00:00
ss << "r" << reg;
2019-06-04 19:27:45 +00:00
else if (reg <= reg_r7_Bank)
ss << "r" << (reg - reg_r0_Bank) << "b";
2013-12-19 17:10:14 +00:00
else
2019-06-04 19:27:45 +00:00
{
switch (reg)
{
case reg_sr_T:
ss << "sr.T";
break;
case reg_fpscr:
ss << "fpscr";
break;
case reg_sr_status:
ss << "sr";
break;
case reg_pc_dyn:
ss << "pc_dyn";
break;
case reg_macl:
ss << "macl";
break;
case reg_mach:
ss << "mach";
break;
case reg_pr:
ss << "pr";
break;
case reg_gbr:
ss << "gbr";
break;
case reg_nextpc:
ss << "pc";
break;
case reg_fpul:
ss << "fpul";
break;
case reg_old_fpscr:
ss << "old_fpscr";
break;
case reg_old_sr_status:
ss << "old_sr_status";
break;
case reg_ssr:
ss << "ssr";
break;
default:
ss << "s" << reg;
break;
}
}
2013-12-19 17:10:14 +00:00
return ss.str();
}
2019-06-04 19:27:45 +00:00
2020-03-29 17:29:14 +00:00
static std::string dissasm_param(const shil_param& prm, bool comma)
2013-12-19 17:10:14 +00:00
{
2020-03-29 17:29:14 +00:00
std::stringstream ss;
2013-12-19 17:10:14 +00:00
if (!prm.is_null() && comma)
ss << ", ";
if (prm.is_imm())
{
if (prm.is_imm_s8())
ss << (s32)prm._imm ;
else
2020-03-29 17:29:14 +00:00
ss << "0x" << std::hex << prm._imm;
2013-12-19 17:10:14 +00:00
}
else if (prm.is_reg())
{
2019-06-04 19:27:45 +00:00
ss << name_reg(prm._reg);
2013-12-19 17:10:14 +00:00
2019-06-04 19:27:45 +00:00
if (prm.count() > 1)
2013-12-19 17:10:14 +00:00
{
ss << "v" << prm.count();
}
2019-06-04 19:27:45 +00:00
ss << "." << prm.version[0];
2013-12-19 17:10:14 +00:00
}
return ss.str();
}
2020-03-29 17:29:14 +00:00
std::string shil_opcode::dissasm() const
2013-12-19 17:10:14 +00:00
{
2020-03-29 17:29:14 +00:00
std::stringstream ss;
2019-06-04 19:27:45 +00:00
ss << shilop_str[op] << " " << dissasm_param(rd,false) << dissasm_param(rd2,true) << " <- " << dissasm_param(rs1,false) << dissasm_param(rs2,true) << dissasm_param(rs3,true);
2013-12-19 17:10:14 +00:00
return ss.str();
}
const char* shil_opcode_name(int op)
{
return shilop_str[op];
2019-06-04 19:27:45 +00:00
}