integrates new tval changes into asmjit

This commit is contained in:
Eyck-Alexander Jentzsch 2024-07-17 09:42:12 +02:00
parent d8c3d2e19c
commit 7a199e122d
2 changed files with 123 additions and 22 deletions

View File

@ -96,6 +96,7 @@ protected:
using super::gen_leave; using super::gen_leave;
using super::gen_operation; using super::gen_operation;
using super::gen_sync; using super::gen_sync;
using super::gen_set_tval;
using this_class = vm_impl<ARCH>; using this_class = vm_impl<ARCH>;
using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
@ -163,6 +164,7 @@ private:
cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, ${idx}); gen_sync(jh, PRE_SYNC, ${idx});
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+${instr.length/8}; pc = pc+${instr.length/8};
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -300,9 +302,9 @@ void vm_impl<ARCH>::gen_instr_epilogue(jit_holder& jh) {
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){
jh.pc = load_reg_from_mem_Gp(jh, traits::PC); jh.pc = load_reg_from_mem_Gp(jh, traits::PC);
jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC);
jh.tval = get_reg_Gp(jh.cc, 64, false);
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
@ -320,15 +322,13 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC); x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC);
mov(cc, current_pc, get_ptr_for(jh, traits::PC)); mov(cc, current_pc, get_ptr_for(jh, traits::PC));
x86::Gp instr = cc.newInt32("instr");
mov(cc, instr, 0); // FIXME:this is not correct, should be instrId of trapping instr
cc.comment("//enter trap call;"); cc.comment("//enter trap call;");
InvokeNode* call_enter_trap; InvokeNode* call_enter_trap;
cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>()); cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>());
call_enter_trap->setArg(0, jh.arch_if_ptr); call_enter_trap->setArg(0, jh.arch_if_ptr);
call_enter_trap->setArg(1, current_trap_state); call_enter_trap->setArg(1, current_trap_state);
call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(2, current_pc);
call_enter_trap->setArg(3, instr); call_enter_trap->setArg(3, jh.tval);
x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC); x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC);
mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC));

View File

@ -96,6 +96,7 @@ protected:
using super::gen_leave; using super::gen_leave;
using super::gen_operation; using super::gen_operation;
using super::gen_sync; using super::gen_sync;
using super::gen_set_tval;
using this_class = vm_impl<ARCH>; using this_class = vm_impl<ARCH>;
using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
@ -338,6 +339,7 @@ private:
cc.comment(fmt::format("LUI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LUI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 0); gen_sync(jh, PRE_SYNC, 0);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -384,6 +386,7 @@ private:
cc.comment(fmt::format("AUIPC_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("AUIPC_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 1); gen_sync(jh, PRE_SYNC, 1);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -430,6 +433,7 @@ private:
cc.comment(fmt::format("JAL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("JAL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 2); gen_sync(jh, PRE_SYNC, 2);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -440,7 +444,9 @@ private:
gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); gen_raise(jh, 0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION));
} }
else{ else{
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int32_t)sext<21>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
@ -448,7 +454,7 @@ private:
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
(uint32_t)(PC+4)); (uint32_t)(PC+4));
} }
auto PC_val_v = (uint32_t)(PC+(int32_t)sext<21>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -485,6 +491,7 @@ private:
cc.comment(fmt::format("JALR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("JALR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 3); gen_sync(jh, PRE_SYNC, 3);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -506,6 +513,7 @@ private:
auto label_else = cc.newLabel(); auto label_else = cc.newLabel();
cc.je(label_else); cc.je(label_else);
{ {
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
cc.jmp(label_merge); cc.jmp(label_merge);
@ -553,6 +561,7 @@ private:
cc.comment(fmt::format("BEQ_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BEQ_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 4); gen_sync(jh, PRE_SYNC, 4);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -568,11 +577,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -611,6 +622,7 @@ private:
cc.comment(fmt::format("BNE_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BNE_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 5); gen_sync(jh, PRE_SYNC, 5);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -626,11 +638,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -669,6 +683,7 @@ private:
cc.comment(fmt::format("BLT_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BLT_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 6); gen_sync(jh, PRE_SYNC, 6);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -686,11 +701,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -729,6 +746,7 @@ private:
cc.comment(fmt::format("BGE_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BGE_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 7); gen_sync(jh, PRE_SYNC, 7);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -746,11 +764,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -789,6 +809,7 @@ private:
cc.comment(fmt::format("BLTU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BLTU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 8); gen_sync(jh, PRE_SYNC, 8);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -804,11 +825,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -847,6 +870,7 @@ private:
cc.comment(fmt::format("BGEU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("BGEU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 9); gen_sync(jh, PRE_SYNC, 9);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -862,11 +886,13 @@ private:
,0); ,0);
cc.je(label_merge); cc.je(label_merge);
{ {
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){
gen_set_tval(jh, new_pc);
gen_raise(jh, 0, 0); gen_raise(jh, 0, 0);
} }
else{ else{
auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto PC_val_v = new_pc;
mov(cc, jh.next_pc, PC_val_v); mov(cc, jh.next_pc, PC_val_v);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U);
} }
@ -905,6 +931,7 @@ private:
cc.comment(fmt::format("LB_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LB_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 10); gen_sync(jh, PRE_SYNC, 10);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -958,6 +985,7 @@ private:
cc.comment(fmt::format("LH_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LH_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 11); gen_sync(jh, PRE_SYNC, 11);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1011,6 +1039,7 @@ private:
cc.comment(fmt::format("LW_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LW_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 12); gen_sync(jh, PRE_SYNC, 12);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1064,6 +1093,7 @@ private:
cc.comment(fmt::format("LBU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LBU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 13); gen_sync(jh, PRE_SYNC, 13);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1116,6 +1146,7 @@ private:
cc.comment(fmt::format("LHU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("LHU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 14); gen_sync(jh, PRE_SYNC, 14);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1168,6 +1199,7 @@ private:
cc.comment(fmt::format("SB_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SB_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 15); gen_sync(jh, PRE_SYNC, 15);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1216,6 +1248,7 @@ private:
cc.comment(fmt::format("SH_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SH_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 16); gen_sync(jh, PRE_SYNC, 16);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1264,6 +1297,7 @@ private:
cc.comment(fmt::format("SW_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SW_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 17); gen_sync(jh, PRE_SYNC, 17);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1312,6 +1346,7 @@ private:
cc.comment(fmt::format("ADDI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("ADDI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 18); gen_sync(jh, PRE_SYNC, 18);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1361,6 +1396,7 @@ private:
cc.comment(fmt::format("SLTI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLTI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 19); gen_sync(jh, PRE_SYNC, 19);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1423,6 +1459,7 @@ private:
cc.comment(fmt::format("SLTIU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLTIU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 20); gen_sync(jh, PRE_SYNC, 20);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1484,6 +1521,7 @@ private:
cc.comment(fmt::format("XORI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("XORI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 21); gen_sync(jh, PRE_SYNC, 21);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1532,6 +1570,7 @@ private:
cc.comment(fmt::format("ORI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("ORI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 22); gen_sync(jh, PRE_SYNC, 22);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1580,6 +1619,7 @@ private:
cc.comment(fmt::format("ANDI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("ANDI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 23); gen_sync(jh, PRE_SYNC, 23);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1628,6 +1668,7 @@ private:
cc.comment(fmt::format("SLLI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLLI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 24); gen_sync(jh, PRE_SYNC, 24);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1676,6 +1717,7 @@ private:
cc.comment(fmt::format("SRLI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SRLI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 25); gen_sync(jh, PRE_SYNC, 25);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1724,6 +1766,7 @@ private:
cc.comment(fmt::format("SRAI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SRAI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 26); gen_sync(jh, PRE_SYNC, 26);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1774,6 +1817,7 @@ private:
cc.comment(fmt::format("ADD_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("ADD_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 27); gen_sync(jh, PRE_SYNC, 27);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1823,6 +1867,7 @@ private:
cc.comment(fmt::format("SUB_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SUB_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 28); gen_sync(jh, PRE_SYNC, 28);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1872,6 +1917,7 @@ private:
cc.comment(fmt::format("SLL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 29); gen_sync(jh, PRE_SYNC, 29);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1921,6 +1967,7 @@ private:
cc.comment(fmt::format("SLT_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLT_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 30); gen_sync(jh, PRE_SYNC, 30);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -1984,6 +2031,7 @@ private:
cc.comment(fmt::format("SLTU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SLTU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 31); gen_sync(jh, PRE_SYNC, 31);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2045,6 +2093,7 @@ private:
cc.comment(fmt::format("XOR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("XOR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 32); gen_sync(jh, PRE_SYNC, 32);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2093,6 +2142,7 @@ private:
cc.comment(fmt::format("SRL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SRL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 33); gen_sync(jh, PRE_SYNC, 33);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2142,6 +2192,7 @@ private:
cc.comment(fmt::format("SRA_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("SRA_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 34); gen_sync(jh, PRE_SYNC, 34);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2193,6 +2244,7 @@ private:
cc.comment(fmt::format("OR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("OR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 35); gen_sync(jh, PRE_SYNC, 35);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2241,6 +2293,7 @@ private:
cc.comment(fmt::format("AND_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("AND_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 36); gen_sync(jh, PRE_SYNC, 36);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2291,6 +2344,7 @@ private:
cc.comment(fmt::format("FENCE_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("FENCE_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 37); gen_sync(jh, PRE_SYNC, 37);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2326,6 +2380,7 @@ private:
cc.comment(fmt::format("ECALL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("ECALL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 38); gen_sync(jh, PRE_SYNC, 38);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2361,6 +2416,7 @@ private:
cc.comment(fmt::format("EBREAK_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("EBREAK_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 39); gen_sync(jh, PRE_SYNC, 39);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2396,6 +2452,7 @@ private:
cc.comment(fmt::format("MRET_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("MRET_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 40); gen_sync(jh, PRE_SYNC, 40);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2431,6 +2488,7 @@ private:
cc.comment(fmt::format("WFI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("WFI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 41); gen_sync(jh, PRE_SYNC, 41);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2470,6 +2528,7 @@ private:
cc.comment(fmt::format("CSRRW_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRW_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 42); gen_sync(jh, PRE_SYNC, 42);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2523,6 +2582,7 @@ private:
cc.comment(fmt::format("CSRRS_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRS_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 43); gen_sync(jh, PRE_SYNC, 43);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2576,6 +2636,7 @@ private:
cc.comment(fmt::format("CSRRC_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRC_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 44); gen_sync(jh, PRE_SYNC, 44);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2629,6 +2690,7 @@ private:
cc.comment(fmt::format("CSRRWI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRWI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 45); gen_sync(jh, PRE_SYNC, 45);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2678,6 +2740,7 @@ private:
cc.comment(fmt::format("CSRRSI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRSI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 46); gen_sync(jh, PRE_SYNC, 46);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2730,6 +2793,7 @@ private:
cc.comment(fmt::format("CSRRCI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("CSRRCI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 47); gen_sync(jh, PRE_SYNC, 47);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2782,6 +2846,7 @@ private:
cc.comment(fmt::format("FENCE_I_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("FENCE_I_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 48); gen_sync(jh, PRE_SYNC, 48);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2821,6 +2886,7 @@ private:
cc.comment(fmt::format("MUL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("MUL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 49); gen_sync(jh, PRE_SYNC, 49);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2873,6 +2939,7 @@ private:
cc.comment(fmt::format("MULH_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("MULH_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 50); gen_sync(jh, PRE_SYNC, 50);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2926,6 +2993,7 @@ private:
cc.comment(fmt::format("MULHSU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("MULHSU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 51); gen_sync(jh, PRE_SYNC, 51);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -2978,6 +3046,7 @@ private:
cc.comment(fmt::format("MULHU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("MULHU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 52); gen_sync(jh, PRE_SYNC, 52);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3029,6 +3098,7 @@ private:
cc.comment(fmt::format("DIV_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("DIV_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 53); gen_sync(jh, PRE_SYNC, 53);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3113,6 +3183,7 @@ private:
cc.comment(fmt::format("DIVU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("DIVU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 54); gen_sync(jh, PRE_SYNC, 54);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3177,6 +3248,7 @@ private:
cc.comment(fmt::format("REM_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("REM_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 55); gen_sync(jh, PRE_SYNC, 55);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3265,6 +3337,7 @@ private:
cc.comment(fmt::format("REMU_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("REMU_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 56); gen_sync(jh, PRE_SYNC, 56);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+4; pc = pc+4;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3328,6 +3401,7 @@ private:
cc.comment(fmt::format("C__ADDI4SPN_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__ADDI4SPN_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 57); gen_sync(jh, PRE_SYNC, 57);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3375,6 +3449,7 @@ private:
cc.comment(fmt::format("C__LW_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__LW_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 58); gen_sync(jh, PRE_SYNC, 58);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3420,6 +3495,7 @@ private:
cc.comment(fmt::format("C__SW_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SW_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 59); gen_sync(jh, PRE_SYNC, 59);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3462,6 +3538,7 @@ private:
cc.comment(fmt::format("C__ADDI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__ADDI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 60); gen_sync(jh, PRE_SYNC, 60);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3508,6 +3585,7 @@ private:
cc.comment(fmt::format("C__NOP_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__NOP_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 61); gen_sync(jh, PRE_SYNC, 61);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3544,6 +3622,7 @@ private:
cc.comment(fmt::format("C__JAL_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__JAL_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 62); gen_sync(jh, PRE_SYNC, 62);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3586,6 +3665,7 @@ private:
cc.comment(fmt::format("C__LI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__LI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 63); gen_sync(jh, PRE_SYNC, 63);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3632,6 +3712,7 @@ private:
cc.comment(fmt::format("C__LUI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__LUI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 64); gen_sync(jh, PRE_SYNC, 64);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3675,6 +3756,7 @@ private:
cc.comment(fmt::format("C__ADDI16SP_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__ADDI16SP_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 65); gen_sync(jh, PRE_SYNC, 65);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3719,6 +3801,7 @@ private:
cc.comment(fmt::format("__reserved_clui_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("__reserved_clui_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 66); gen_sync(jh, PRE_SYNC, 66);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3757,6 +3840,7 @@ private:
cc.comment(fmt::format("C__SRLI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SRLI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 67); gen_sync(jh, PRE_SYNC, 67);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3797,6 +3881,7 @@ private:
cc.comment(fmt::format("C__SRAI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SRAI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 68); gen_sync(jh, PRE_SYNC, 68);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3850,6 +3935,7 @@ private:
cc.comment(fmt::format("C__ANDI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__ANDI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 69); gen_sync(jh, PRE_SYNC, 69);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3891,6 +3977,7 @@ private:
cc.comment(fmt::format("C__SUB_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SUB_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 70); gen_sync(jh, PRE_SYNC, 70);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3932,6 +4019,7 @@ private:
cc.comment(fmt::format("C__XOR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__XOR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 71); gen_sync(jh, PRE_SYNC, 71);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -3972,6 +4060,7 @@ private:
cc.comment(fmt::format("C__OR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__OR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 72); gen_sync(jh, PRE_SYNC, 72);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4012,6 +4101,7 @@ private:
cc.comment(fmt::format("C__AND_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__AND_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 73); gen_sync(jh, PRE_SYNC, 73);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4051,6 +4141,7 @@ private:
cc.comment(fmt::format("C__J_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__J_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 74); gen_sync(jh, PRE_SYNC, 74);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4091,6 +4182,7 @@ private:
cc.comment(fmt::format("C__BEQZ_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__BEQZ_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 75); gen_sync(jh, PRE_SYNC, 75);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4138,6 +4230,7 @@ private:
cc.comment(fmt::format("C__BNEZ_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__BNEZ_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 76); gen_sync(jh, PRE_SYNC, 76);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4185,6 +4278,7 @@ private:
cc.comment(fmt::format("C__SLLI_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SLLI_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 77); gen_sync(jh, PRE_SYNC, 77);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4232,6 +4326,7 @@ private:
cc.comment(fmt::format("C__LWSP_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__LWSP_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 78); gen_sync(jh, PRE_SYNC, 78);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4281,6 +4376,7 @@ private:
cc.comment(fmt::format("C__MV_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__MV_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 79); gen_sync(jh, PRE_SYNC, 79);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4326,6 +4422,7 @@ private:
cc.comment(fmt::format("C__JR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__JR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 80); gen_sync(jh, PRE_SYNC, 80);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4370,6 +4467,7 @@ private:
cc.comment(fmt::format("__reserved_cmv_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("__reserved_cmv_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 81); gen_sync(jh, PRE_SYNC, 81);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4408,6 +4506,7 @@ private:
cc.comment(fmt::format("C__ADD_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__ADD_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 82); gen_sync(jh, PRE_SYNC, 82);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4455,6 +4554,7 @@ private:
cc.comment(fmt::format("C__JALR_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__JALR_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 83); gen_sync(jh, PRE_SYNC, 83);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4502,6 +4602,7 @@ private:
cc.comment(fmt::format("C__EBREAK_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__EBREAK_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 84); gen_sync(jh, PRE_SYNC, 84);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4540,6 +4641,7 @@ private:
cc.comment(fmt::format("C__SWSP_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("C__SWSP_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 85); gen_sync(jh, PRE_SYNC, 85);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4584,6 +4686,7 @@ private:
cc.comment(fmt::format("DII_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("DII_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, 86); gen_sync(jh, PRE_SYNC, 86);
mov(cc, jh.pc, pc.val); mov(cc, jh.pc, pc.val);
gen_set_tval(jh, instr);
pc = pc+2; pc = pc+2;
mov(cc, jh.next_pc, pc.val); mov(cc, jh.next_pc, pc.val);
@ -4722,9 +4825,9 @@ void vm_impl<ARCH>::gen_instr_epilogue(jit_holder& jh) {
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){
jh.pc = load_reg_from_mem_Gp(jh, traits::PC); jh.pc = load_reg_from_mem_Gp(jh, traits::PC);
jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC);
jh.tval = get_reg_Gp(jh.cc, 64, false);
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
@ -4742,15 +4845,13 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC); x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC);
mov(cc, current_pc, get_ptr_for(jh, traits::PC)); mov(cc, current_pc, get_ptr_for(jh, traits::PC));
x86::Gp instr = cc.newInt32("instr");
mov(cc, instr, 0); // FIXME:this is not correct, should be instrId of trapping instr
cc.comment("//enter trap call;"); cc.comment("//enter trap call;");
InvokeNode* call_enter_trap; InvokeNode* call_enter_trap;
cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>()); cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>());
call_enter_trap->setArg(0, jh.arch_if_ptr); call_enter_trap->setArg(0, jh.arch_if_ptr);
call_enter_trap->setArg(1, current_trap_state); call_enter_trap->setArg(1, current_trap_state);
call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(2, current_pc);
call_enter_trap->setArg(3, instr); call_enter_trap->setArg(3, jh.tval);
x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC); x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC);
mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC));