allows usage of std::variants
This commit is contained in:
parent
4cfb15c7cd
commit
5b17599aa2
@ -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<ARCH>::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 <typename ARCH>
|
||||
@ -287,16 +292,16 @@ void vm_impl<ARCH>::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 <typename ARCH>
|
||||
void vm_impl<ARCH>::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 <typename ARCH>
|
||||
void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
|
||||
@ -308,14 +313,14 @@ void vm_impl<ARCH>::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<uint64_t, void*, uint64_t, uint64_t, uint64_t>());
|
||||
@ -324,11 +329,11 @@ void vm_impl<ARCH>::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<uint32_t>::max());
|
||||
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits<uint32_t>::max());
|
||||
cc.ret(jh.next_pc);
|
||||
}
|
||||
template <typename ARCH>
|
||||
@ -336,9 +341,9 @@ inline void vm_impl<ARCH>::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<uint32_t>::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<uint32_t>::max());
|
||||
}
|
||||
|
||||
} // namespace tgc5c
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user