From 5b17599aa2a7ec838187c340aad300ad86ca2c1a Mon Sep 17 00:00:00 2001 From: Eyck-Alexander Jentzsch Date: Wed, 3 Jul 2024 12:45:13 +0200 Subject: [PATCH] allows usage of std::variants --- gen_input/templates/asmjit/CORENAME.cpp.gtl | 51 +- src/vm/asmjit/vm_tgc5c.cpp | 641 ++++++++++---------- 2 files changed, 351 insertions(+), 341 deletions(-) diff --git a/gen_input/templates/asmjit/CORENAME.cpp.gtl b/gen_input/templates/asmjit/CORENAME.cpp.gtl index 17e5852..6a7a40e 100644 --- a/gen_input/templates/asmjit/CORENAME.cpp.gtl +++ b/gen_input/templates/asmjit/CORENAME.cpp.gtl @@ -79,10 +79,15 @@ public: } protected: + using super::mov; + using super::cmp; using super::get_ptr_for; -using super::get_reg; + using super::get_reg; + using super::get_reg_Gp; using super::get_reg_for; + using super::get_reg_for_Gp; using super::load_reg_from_mem; + using super::load_reg_from_mem_Gp; using super::write_reg_to_mem; using super::gen_ext; using super::gen_read_mem; @@ -156,9 +161,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, ${idx}); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+${instr.length/8}; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -277,9 +282,9 @@ void vm_impl::gen_instr_prologue(jit_holder& jh) { cc.comment("//gen_instr_prologue"); cc.inc(get_ptr_for(jh, traits::ICOUNT)); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - cc.mov(get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); + x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + mov(cc, get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); } template @@ -287,16 +292,16 @@ void vm_impl::gen_instr_epilogue(jit_holder& jh) { auto& cc = jh.cc; cc.comment("//gen_instr_epilogue"); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - cc.cmp(current_trap_state, 0); + x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + cmp(cc, current_trap_state, 0); cc.jne(jh.trap_entry); } template void vm_impl::gen_block_prologue(jit_holder& jh){ - jh.pc = load_reg_from_mem(jh, traits::PC); - jh.next_pc = load_reg_from_mem(jh, traits::NEXT_PC); + jh.pc = load_reg_from_mem_Gp(jh, traits::PC); + jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); } template void vm_impl::gen_block_epilogue(jit_holder& jh){ @@ -308,14 +313,14 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ this->write_back(jh); this->gen_sync(jh, POST_SYNC, -1); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + x86::Gp current_trap_state = get_reg_for_Gp(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - x86::Gp current_pc = get_reg_for(jh, traits::PC); - cc.mov(current_pc, get_ptr_for(jh, traits::PC)); + x86::Gp current_pc = get_reg_for_Gp(jh, traits::PC); + mov(cc, current_pc, get_ptr_for(jh, traits::PC)); x86::Gp instr = cc.newInt32("instr"); - cc.mov(instr, 0); // FIXME:this is not correct + mov(cc, instr, 0); // FIXME:this is not correct, should be instrId of trapping instr cc.comment("//enter trap call;"); InvokeNode* call_enter_trap; cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build()); @@ -324,11 +329,11 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(3, instr); - x86::Gp current_next_pc = get_reg_for(jh, traits::NEXT_PC); - cc.mov(current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); - cc.mov(jh.next_pc, current_next_pc); + x86_reg_t current_next_pc = get_reg_for(jh, traits::NEXT_PC); + mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); + mov(cc, jh.next_pc, current_next_pc); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits::max()); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits::max()); cc.ret(jh.next_pc); } template @@ -336,9 +341,9 @@ inline void vm_impl::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t auto& cc = jh.cc; cc.comment("//gen_raise"); auto tmp1 = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); - cc.mov(get_ptr_for(jh, traits::TRAP_STATE), tmp1); - cc.mov(jh.next_pc, std::numeric_limits::max()); + mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); + mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); + mov(cc, jh.next_pc, std::numeric_limits::max()); } } // namespace tgc5c diff --git a/src/vm/asmjit/vm_tgc5c.cpp b/src/vm/asmjit/vm_tgc5c.cpp index e30c907..4ba664e 100644 --- a/src/vm/asmjit/vm_tgc5c.cpp +++ b/src/vm/asmjit/vm_tgc5c.cpp @@ -79,10 +79,15 @@ public: } protected: + using super::mov; + using super::cmp; using super::get_ptr_for; -using super::get_reg; + using super::get_reg; + using super::get_reg_Gp; using super::get_reg_for; + using super::get_reg_for_Gp; using super::load_reg_from_mem; + using super::load_reg_from_mem_Gp; using super::write_reg_to_mem; using super::gen_ext; using super::gen_read_mem; @@ -331,9 +336,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LUI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 0); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -343,7 +348,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)((int32_t)imm)); } } @@ -377,9 +382,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("AUIPC_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 1); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -389,7 +394,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)(PC+(int32_t)imm)); } } @@ -423,9 +428,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("JAL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 2); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -439,12 +444,12 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)(PC+4)); } auto PC_val_v = (uint32_t)(PC+(int32_t)sext<21>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } auto returnValue = BRANCH; @@ -478,9 +483,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("JALR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 3); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -495,7 +500,7 @@ private: ), addr_mask) ), 32, true); auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, urem, new_pc, static_cast(traits::INSTR_ALIGNMENT)) + cmp(cc, gen_operation(jh, urem, new_pc, static_cast(traits::INSTR_ALIGNMENT)) ,0); auto label_else = cc.newLabel(); cc.je(label_else); @@ -506,12 +511,12 @@ private: cc.bind(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)(PC+4)); } auto PC_val_v = new_pc; - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } cc.bind(label_merge); } @@ -546,9 +551,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BEQ_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 4); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -558,7 +563,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) + cmp(cc, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ,0); cc.je(label_merge); { @@ -567,8 +572,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -604,9 +609,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BNE_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 5); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -616,7 +621,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) + cmp(cc, gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ,0); cc.je(label_merge); { @@ -625,8 +630,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -662,9 +667,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BLT_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 6); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -674,7 +679,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, lt, gen_ext(jh, + cmp(cc, gen_operation(jh, lt, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, false), gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs2), 32, false)) ,0); @@ -685,8 +690,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -722,9 +727,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BGE_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 7); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -734,7 +739,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, gte, gen_ext(jh, + cmp(cc, gen_operation(jh, gte, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, false), gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs2), 32, false)) ,0); @@ -745,8 +750,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -782,9 +787,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BLTU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 8); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -794,7 +799,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ltu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) + cmp(cc, gen_operation(jh, ltu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ,0); cc.je(label_merge); { @@ -803,8 +808,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -840,9 +845,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("BGEU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 9); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -852,7 +857,7 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, gteu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) + cmp(cc, gen_operation(jh, gteu, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ,0); cc.je(label_merge); { @@ -861,8 +866,8 @@ private: } else{ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<13>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } } cc.bind(label_merge); @@ -898,9 +903,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LB_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 10); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -915,7 +920,7 @@ private: auto res = gen_ext(jh, gen_read_mem(jh, traits::MEM, load_address, 1), 8, false); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, true)); } @@ -951,9 +956,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LH_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 11); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -968,7 +973,7 @@ private: auto res = gen_ext(jh, gen_read_mem(jh, traits::MEM, load_address, 2), 16, false); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, true)); } @@ -1004,9 +1009,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LW_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 12); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1021,7 +1026,7 @@ private: auto res = gen_ext(jh, gen_read_mem(jh, traits::MEM, load_address, 4), 32, false); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, true)); } @@ -1057,9 +1062,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LBU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 13); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1073,7 +1078,7 @@ private: ), 32, true); auto res = gen_read_mem(jh, traits::MEM, load_address, 1); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, false)); } @@ -1109,9 +1114,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("LHU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 14); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1125,7 +1130,7 @@ private: ), 32, true); auto res = gen_read_mem(jh, traits::MEM, load_address, 2); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, false)); } @@ -1161,9 +1166,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SB_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 15); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1209,9 +1214,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SH_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 16); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1257,9 +1262,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SW_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 17); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1305,9 +1310,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("ADDI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 18); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1317,7 +1322,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + rs1), (int16_t)sext<12>(imm)) ), 32, true)); @@ -1354,9 +1359,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLTI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 19); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1370,15 +1375,15 @@ private: auto label_then = cc.newLabel(); auto label_merge = cc.newLabel(); auto tmp_reg = get_reg_for(jh, 1); - cc.cmp(gen_ext(jh, + cmp(cc, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), (int16_t)sext<12>(imm)); cc.jl(label_then); - cc.mov(tmp_reg,0); + mov(cc, tmp_reg,0); cc.jmp(label_merge); cc.bind(label_then); - cc.mov(tmp_reg,1); + mov(cc, tmp_reg,1); cc.bind(label_merge); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, tmp_reg , 32, false) ); @@ -1416,9 +1421,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLTIU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 20); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1432,14 +1437,14 @@ private: auto label_then = cc.newLabel(); auto label_merge = cc.newLabel(); auto tmp_reg = get_reg_for(jh, 1); - cc.cmp(load_reg_from_mem(jh, traits::X0 + rs1), (uint32_t)((int16_t)sext<12>(imm))); + cmp(cc, load_reg_from_mem(jh, traits::X0 + rs1), (uint32_t)((int16_t)sext<12>(imm))); cc.jb(label_then); - cc.mov(tmp_reg,0); + mov(cc, tmp_reg,0); cc.jmp(label_merge); cc.bind(label_then); - cc.mov(tmp_reg,1); + mov(cc, tmp_reg,1); cc.bind(label_merge); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, tmp_reg , 32, false) ); @@ -1477,9 +1482,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("XORI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 21); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1489,7 +1494,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, bxor, load_reg_from_mem(jh, traits::X0 + rs1), (uint32_t)((int16_t)sext<12>(imm))) ); } @@ -1525,9 +1530,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("ORI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 22); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1537,7 +1542,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, bor, load_reg_from_mem(jh, traits::X0 + rs1), (uint32_t)((int16_t)sext<12>(imm))) ); } @@ -1573,9 +1578,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("ANDI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 23); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1585,7 +1590,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs1), (uint32_t)((int16_t)sext<12>(imm))) ); } @@ -1621,9 +1626,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLLI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 24); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1633,7 +1638,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, shl, load_reg_from_mem(jh, traits::X0 + rs1), shamt) ); } @@ -1669,9 +1674,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SRLI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 25); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1681,7 +1686,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, shr, load_reg_from_mem(jh, traits::X0 + rs1), shamt) ); } @@ -1717,9 +1722,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SRAI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 26); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1729,7 +1734,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, sar, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), shamt) @@ -1767,9 +1772,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("ADD_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 27); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1779,7 +1784,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ), 32, false)); @@ -1816,9 +1821,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SUB_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 28); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1828,7 +1833,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, sub, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ), 32, true)); @@ -1865,9 +1870,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 29); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1877,7 +1882,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, gen_operation(jh, shl, load_reg_from_mem(jh, traits::X0 + rs1), (gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs2), (static_cast(traits::XLEN)-1)) )) , 32, false)); @@ -1914,9 +1919,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLT_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 30); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1930,16 +1935,16 @@ private: auto label_then = cc.newLabel(); auto label_merge = cc.newLabel(); auto tmp_reg = get_reg_for(jh, 1); - cc.cmp(gen_ext(jh, + cmp(cc, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs2), 32, true)); cc.jl(label_then); - cc.mov(tmp_reg,0); + mov(cc, tmp_reg,0); cc.jmp(label_merge); cc.bind(label_then); - cc.mov(tmp_reg,1); + mov(cc, tmp_reg,1); cc.bind(label_merge); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, tmp_reg , 32, false) ); @@ -1977,9 +1982,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SLTU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 31); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -1993,14 +1998,14 @@ private: auto label_then = cc.newLabel(); auto label_merge = cc.newLabel(); auto tmp_reg = get_reg_for(jh, 1); - cc.cmp(load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)); + cmp(cc, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)); cc.jb(label_then); - cc.mov(tmp_reg,0); + mov(cc, tmp_reg,0); cc.jmp(label_merge); cc.bind(label_then); - cc.mov(tmp_reg,1); + mov(cc, tmp_reg,1); cc.bind(label_merge); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, tmp_reg , 32, false) ); @@ -2038,9 +2043,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("XOR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 32); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2050,7 +2055,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, bxor, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ); } @@ -2086,9 +2091,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SRL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 33); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2098,7 +2103,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, gen_operation(jh, shr, load_reg_from_mem(jh, traits::X0 + rs1), (gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs2), (static_cast(traits::XLEN)-1)) )) , 32, false)); @@ -2135,9 +2140,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("SRA_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 34); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2147,7 +2152,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_ext(jh, gen_operation(jh, sar, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), (gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs2), (static_cast(traits::XLEN)-1)) @@ -2186,9 +2191,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("OR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 35); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2198,7 +2203,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, bor, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ); } @@ -2234,9 +2239,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("AND_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 36); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2246,7 +2251,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ); } @@ -2284,9 +2289,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("FENCE_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 37); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2319,9 +2324,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("ECALL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 38); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2354,9 +2359,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("EBREAK_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 39); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2389,9 +2394,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("MRET_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 40); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2424,9 +2429,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("WFI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 41); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2463,9 +2468,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRW_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 42); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2478,7 +2483,7 @@ private: if(rd!=0){ auto xrd = gen_read_mem(jh, traits::CSR, csr, 4); gen_write_mem(jh, traits::CSR, csr, xrs1, 4); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } else{ @@ -2516,9 +2521,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRS_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 43); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2534,7 +2539,7 @@ private: , 4); } if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } } @@ -2569,9 +2574,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRC_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 44); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2587,7 +2592,7 @@ private: , 4); } if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } } @@ -2622,9 +2627,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRWI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 45); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2636,7 +2641,7 @@ private: auto xrd = gen_read_mem(jh, traits::CSR, csr, 4); gen_write_mem(jh, traits::CSR, csr, (uint32_t)zimm, 4); if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } } @@ -2671,9 +2676,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRSI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 46); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2688,7 +2693,7 @@ private: , 4); } if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } } @@ -2723,9 +2728,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("CSRRCI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 47); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2740,7 +2745,7 @@ private: , 4); } if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), xrd); } } @@ -2775,9 +2780,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("FENCE_I_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 48); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2814,9 +2819,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("MUL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 49); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2830,7 +2835,7 @@ private: load_reg_from_mem(jh, traits::X0 + rs2), 32, true)) ; if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, res, 32, true)); } @@ -2866,9 +2871,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("MULH_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 50); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2882,7 +2887,7 @@ private: load_reg_from_mem(jh, traits::X0 + rs2), 32, true)) ; if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, sar, res, static_cast(traits::XLEN)) ), 32, true)); @@ -2919,9 +2924,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("MULHSU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 51); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2934,7 +2939,7 @@ private: load_reg_from_mem(jh, traits::X0 + rs1), 32, true), load_reg_from_mem(jh, traits::X0 + rs2)) ; if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, sar, res, static_cast(traits::XLEN)) ), 32, true)); @@ -2971,9 +2976,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("MULHU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 52); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -2985,7 +2990,7 @@ private: auto res = gen_operation(jh, umul, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ; if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, shr, res, static_cast(traits::XLEN)) ), 32, false)); @@ -3022,9 +3027,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("DIV_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 53); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3039,27 +3044,27 @@ private: load_reg_from_mem(jh, traits::X0 + rs2), 32, true); if(rd!=0){ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, divisor, 0) + cmp(cc, gen_operation(jh, ne, divisor, 0) ,0); auto label_else = cc.newLabel(); cc.je(label_else); { auto MMIN = ((uint32_t)1)<<(static_cast(traits::XLEN)-1); auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, land, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) + cmp(cc, gen_operation(jh, land, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) , gen_operation(jh, eq, divisor, - 1) ) ,0); auto label_else = cc.newLabel(); cc.je(label_else); { - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), MMIN); } cc.jmp(label_merge); cc.bind(label_else); { - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, sdiv, dividend, divisor) ), 32, true)); @@ -3069,7 +3074,7 @@ private: cc.jmp(label_merge); cc.bind(label_else); { - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)- 1); } cc.bind(label_merge); @@ -3106,9 +3111,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("DIVU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 54); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3118,13 +3123,13 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) + cmp(cc, gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) ,0); auto label_else = cc.newLabel(); cc.je(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, udiv, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ); } @@ -3133,7 +3138,7 @@ private: cc.bind(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)- 1); } } @@ -3170,9 +3175,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("REM_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 55); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3182,14 +3187,14 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) + cmp(cc, gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) ,0); auto label_else = cc.newLabel(); cc.je(label_else); { auto MMIN = (uint32_t)1<<(static_cast(traits::XLEN)-1); auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, land, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) + cmp(cc, gen_operation(jh, land, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1), MMIN) , gen_operation(jh, eq, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs2), 32, false), - 1) ) @@ -3198,7 +3203,7 @@ private: cc.je(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, 0, 32, false) ); } @@ -3207,7 +3212,7 @@ private: cc.bind(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, srem, gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), gen_ext(jh, @@ -3221,7 +3226,7 @@ private: cc.bind(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), load_reg_from_mem(jh, traits::X0 + rs1)); } } @@ -3258,9 +3263,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("REMU_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 56); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+4; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3270,13 +3275,13 @@ private: } else{ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) + cmp(cc, gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs2), 0) ,0); auto label_else = cc.newLabel(); cc.je(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_operation(jh, urem, load_reg_from_mem(jh, traits::X0 + rs1), load_reg_from_mem(jh, traits::X0 + rs2)) ); } @@ -3285,7 +3290,7 @@ private: cc.bind(label_else); { if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), load_reg_from_mem(jh, traits::X0 + rs1)); } } @@ -3321,15 +3326,15 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__ADDI4SPN_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 57); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ if(imm){ - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + 2), imm) ), 32, false)); @@ -3368,9 +3373,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__LW_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 58); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3378,7 +3383,7 @@ private: auto offs = gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + rs1+8), uimm) ), 32, false); - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_ext(jh, gen_ext(jh, gen_read_mem(jh, traits::MEM, offs, 4), 32, false), 32, true)); @@ -3413,9 +3418,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SW_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 59); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3455,9 +3460,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__ADDI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 60); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3467,7 +3472,7 @@ private: } else{ if(rs1!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rs1), + mov(cc, get_ptr_for(jh, traits::X0+ rs1), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + rs1), (int8_t)sext<6>(imm)) ), 32, true)); @@ -3501,9 +3506,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__NOP_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 61); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3537,18 +3542,18 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__JAL_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 62); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ 1), + mov(cc, get_ptr_for(jh, traits::X0+ 1), (uint32_t)(PC+2)); auto PC_val_v = (uint32_t)(PC+(int16_t)sext<12>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); auto returnValue = BRANCH; gen_instr_epilogue(jh); @@ -3579,9 +3584,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__LI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 63); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3591,7 +3596,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)((int8_t)sext<6>(imm))); } } @@ -3625,9 +3630,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__LUI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 64); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3636,7 +3641,7 @@ private: gen_raise(jh, 0, static_cast(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); } if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), (uint32_t)((int32_t)sext<18>(imm))); } auto returnValue = CONT; @@ -3668,15 +3673,15 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__ADDI16SP_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 65); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ if(nzimm){ - cc.mov(get_ptr_for(jh, traits::X0+ 2), + mov(cc, get_ptr_for(jh, traits::X0+ 2), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + 2), (int16_t)sext<10>(nzimm)) ), 32, true)); @@ -3712,9 +3717,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("__reserved_clui_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 66); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -3750,14 +3755,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SRLI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 67); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rs1+8), + mov(cc, get_ptr_for(jh, traits::X0+ rs1+8), gen_operation(jh, shr, load_reg_from_mem(jh, traits::X0 + rs1+8), shamt) ); auto returnValue = CONT; @@ -3790,15 +3795,15 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SRAI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 68); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ if(shamt){ - cc.mov(get_ptr_for(jh, traits::X0+ rs1+8), + mov(cc, get_ptr_for(jh, traits::X0+ rs1+8), gen_ext(jh, (gen_operation(jh, sar, (gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1+8), 32, false)), shamt) @@ -3806,7 +3811,7 @@ private: } else{ if(static_cast(traits::XLEN)==128){ - cc.mov(get_ptr_for(jh, traits::X0+ rs1+8), + mov(cc, get_ptr_for(jh, traits::X0+ rs1+8), gen_ext(jh, (gen_operation(jh, sar, (gen_ext(jh, load_reg_from_mem(jh, traits::X0 + rs1+8), 32, false)), 64) @@ -3843,14 +3848,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__ANDI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 69); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rs1+8), + mov(cc, get_ptr_for(jh, traits::X0+ rs1+8), gen_ext(jh, (gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs1+8), (int8_t)sext<6>(imm)) ), 32, true)); @@ -3884,14 +3889,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SUB_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 70); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_ext(jh, (gen_operation(jh, sub, load_reg_from_mem(jh, traits::X0 + rd+8), load_reg_from_mem(jh, traits::X0 + rs2+8)) ), 32, true)); @@ -3925,14 +3930,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__XOR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 71); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_operation(jh, bxor, load_reg_from_mem(jh, traits::X0 + rd+8), load_reg_from_mem(jh, traits::X0 + rs2+8)) ); auto returnValue = CONT; @@ -3965,14 +3970,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__OR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 72); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_operation(jh, bor, load_reg_from_mem(jh, traits::X0 + rd+8), load_reg_from_mem(jh, traits::X0 + rs2+8)) ); auto returnValue = CONT; @@ -4005,14 +4010,14 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__AND_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 73); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ - cc.mov(get_ptr_for(jh, traits::X0+ rd+8), + mov(cc, get_ptr_for(jh, traits::X0+ rd+8), gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rd+8), load_reg_from_mem(jh, traits::X0 + rs2+8)) ); auto returnValue = CONT; @@ -4044,16 +4049,16 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__J_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 74); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ auto PC_val_v = (uint32_t)(PC+(int16_t)sext<12>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); auto returnValue = BRANCH; gen_instr_epilogue(jh); @@ -4084,21 +4089,21 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__BEQZ_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 75); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) + cmp(cc, gen_operation(jh, eq, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) ,0); cc.je(label_merge); { auto PC_val_v = (uint32_t)(PC+(int16_t)sext<9>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } cc.bind(label_merge); auto returnValue = BRANCH; @@ -4131,21 +4136,21 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__BNEZ_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 76); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); /*generate behavior*/ auto label_merge = cc.newLabel(); - cc.cmp(gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) + cmp(cc, gen_operation(jh, ne, load_reg_from_mem(jh, traits::X0 + rs1+8), 0) ,0); cc.je(label_merge); { auto PC_val_v = (uint32_t)(PC+(int16_t)sext<9>(imm)); - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } cc.bind(label_merge); auto returnValue = BRANCH; @@ -4178,9 +4183,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SLLI_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 77); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4190,7 +4195,7 @@ private: } else{ if(rs1!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rs1), + mov(cc, get_ptr_for(jh, traits::X0+ rs1), gen_operation(jh, shl, load_reg_from_mem(jh, traits::X0 + rs1), nzuimm) ); } @@ -4225,9 +4230,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__LWSP_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 78); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4239,7 +4244,7 @@ private: auto offs = gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + 2), uimm) ), 32, false); - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, gen_ext(jh, gen_read_mem(jh, traits::MEM, offs, 4), 32, false), 32, true)); @@ -4274,9 +4279,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__MV_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 79); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4286,7 +4291,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), load_reg_from_mem(jh, traits::X0 + rs2)); } } @@ -4319,9 +4324,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__JR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 80); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4329,8 +4334,8 @@ private: if(rs1&&rs1(traits::RFS)){ auto PC_val_v = gen_operation(jh, band, load_reg_from_mem(jh, traits::X0 + rs1%static_cast(traits::RFS)), ~ 1) ; - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } else{ gen_raise(jh, 0, 2); @@ -4362,9 +4367,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("__reserved_cmv_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 81); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4400,9 +4405,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__ADD_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 82); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4412,7 +4417,7 @@ private: } else{ if(rd!=0){ - cc.mov(get_ptr_for(jh, traits::X0+ rd), + mov(cc, get_ptr_for(jh, traits::X0+ rd), gen_ext(jh, (gen_operation(jh, add, load_reg_from_mem(jh, traits::X0 + rd), load_reg_from_mem(jh, traits::X0 + rs2)) ), 32, false)); @@ -4447,9 +4452,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__JALR_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 83); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4459,12 +4464,12 @@ private: } else{ auto new_pc = load_reg_from_mem(jh, traits::X0 + rs1); - cc.mov(get_ptr_for(jh, traits::X0+ 1), + mov(cc, get_ptr_for(jh, traits::X0+ 1), (uint32_t)(PC+2)); auto PC_val_v = gen_operation(jh, band, new_pc, ~ 1) ; - cc.mov(jh.next_pc, PC_val_v); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), 32U); + mov(cc, jh.next_pc, PC_val_v); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), 32U); } auto returnValue = BRANCH; @@ -4493,9 +4498,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__EBREAK_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 84); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4531,9 +4536,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("C__SWSP_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 85); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4575,9 +4580,9 @@ private: x86::Compiler& cc = jh.cc; cc.comment(fmt::format("DII_{:#x}:",pc.val).c_str()); this->gen_sync(jh, PRE_SYNC, 86); - cc.mov(jh.pc, pc.val); + mov(cc, jh.pc, pc.val); pc = pc+2; - cc.mov(jh.next_pc, pc.val); + mov(cc, jh.next_pc, pc.val); gen_instr_prologue(jh); cc.comment("//behavior:"); @@ -4697,9 +4702,9 @@ void vm_impl::gen_instr_prologue(jit_holder& jh) { cc.comment("//gen_instr_prologue"); cc.inc(get_ptr_for(jh, traits::ICOUNT)); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - cc.mov(get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); + x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + mov(cc, get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); } template @@ -4707,16 +4712,16 @@ void vm_impl::gen_instr_epilogue(jit_holder& jh) { auto& cc = jh.cc; cc.comment("//gen_instr_epilogue"); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - cc.cmp(current_trap_state, 0); + x86_reg_t current_trap_state = get_reg_for(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + cmp(cc, current_trap_state, 0); cc.jne(jh.trap_entry); } template void vm_impl::gen_block_prologue(jit_holder& jh){ - jh.pc = load_reg_from_mem(jh, traits::PC); - jh.next_pc = load_reg_from_mem(jh, traits::NEXT_PC); + jh.pc = load_reg_from_mem_Gp(jh, traits::PC); + jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); } template void vm_impl::gen_block_epilogue(jit_holder& jh){ @@ -4728,14 +4733,14 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ this->write_back(jh); this->gen_sync(jh, POST_SYNC, -1); - x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); + x86::Gp current_trap_state = get_reg_for_Gp(jh, traits::TRAP_STATE); + mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); - x86::Gp current_pc = get_reg_for(jh, traits::PC); - cc.mov(current_pc, get_ptr_for(jh, traits::PC)); + x86::Gp current_pc = get_reg_for_Gp(jh, traits::PC); + mov(cc, current_pc, get_ptr_for(jh, traits::PC)); x86::Gp instr = cc.newInt32("instr"); - cc.mov(instr, 0); // FIXME:this is not correct + mov(cc, instr, 0); // FIXME:this is not correct, should be instrId of trapping instr cc.comment("//enter trap call;"); InvokeNode* call_enter_trap; cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build()); @@ -4744,11 +4749,11 @@ void vm_impl::gen_block_epilogue(jit_holder& jh){ call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(3, instr); - x86::Gp current_next_pc = get_reg_for(jh, traits::NEXT_PC); - cc.mov(current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); - cc.mov(jh.next_pc, current_next_pc); + x86_reg_t current_next_pc = get_reg_for(jh, traits::NEXT_PC); + mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); + mov(cc, jh.next_pc, current_next_pc); - cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits::max()); + mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits::max()); cc.ret(jh.next_pc); } template @@ -4756,9 +4761,9 @@ inline void vm_impl::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t auto& cc = jh.cc; cc.comment("//gen_raise"); auto tmp1 = get_reg_for(jh, traits::TRAP_STATE); - cc.mov(tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); - cc.mov(get_ptr_for(jh, traits::TRAP_STATE), tmp1); - cc.mov(jh.next_pc, std::numeric_limits::max()); + mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); + mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); + mov(cc, jh.next_pc, std::numeric_limits::max()); } } // namespace tgc5c