integrates new tval changes into llvm
This commit is contained in:
@ -102,6 +102,8 @@ protected:
|
||||
void gen_raise_trap(uint16_t trap_id, uint16_t cause);
|
||||
void gen_leave_trap(unsigned lvl);
|
||||
void gen_wait(unsigned type);
|
||||
void set_tval(uint64_t new_tval);
|
||||
void set_tval(Value* new_tval);
|
||||
void gen_trap_behavior(BasicBlock *) override;
|
||||
void gen_instr_epilogue(BasicBlock *bb);
|
||||
|
||||
@ -168,6 +170,7 @@ private:
|
||||
auto cur_pc_val = this->gen_const(32,pc.val);
|
||||
pc=pc+ ${instr.length/8};
|
||||
this->gen_set_pc(pc, traits::NEXT_PC);
|
||||
this->set_tval(PC);
|
||||
|
||||
/*generate behavior*/
|
||||
<%instr.behavior.eachLine{%>${it}
|
||||
@ -326,6 +329,15 @@ void vm_impl<ARCH>::gen_wait(unsigned type) {
|
||||
this->builder.CreateCall(this->mod->getFunction("wait"), args);
|
||||
}
|
||||
|
||||
template <typename ARCH>
|
||||
inline void vm_impl<ARCH>::set_tval(uint64_t tval) {
|
||||
auto tmp_tval = this->gen_const(64, tval);
|
||||
this->set_tval(tmp_tval);
|
||||
}
|
||||
template <typename ARCH>
|
||||
inline void vm_impl<ARCH>::set_tval(Value* new_tval) {
|
||||
this->builder.CreateStore(new_tval, this->tval);
|
||||
}
|
||||
template <typename ARCH>
|
||||
void vm_impl<ARCH>::gen_trap_behavior(BasicBlock *trap_blk) {
|
||||
this->builder.SetInsertPoint(trap_blk);
|
||||
@ -334,7 +346,7 @@ void vm_impl<ARCH>::gen_trap_behavior(BasicBlock *trap_blk) {
|
||||
this->builder.CreateStore(this->gen_const(32U, std::numeric_limits<uint32_t>::max()),
|
||||
get_reg_ptr(traits::LAST_BRANCH), false);
|
||||
std::vector<Value *> args{this->core_ptr, this->adj_to64(trap_state_val),
|
||||
this->adj_to64(this->builder.CreateLoad(this->get_typeptr(traits::PC), get_reg_ptr(traits::PC), false))};
|
||||
this->adj_to64(this->builder.CreateLoad(this->builder.getInt64Ty(),this->tval))};
|
||||
this->builder.CreateCall(this->mod->getFunction("enter_trap"), args);
|
||||
auto *trap_addr_val = this->builder.CreateLoad(this->get_typeptr(traits::NEXT_PC), get_reg_ptr(traits::NEXT_PC), false);
|
||||
this->builder.CreateRet(trap_addr_val);
|
||||
|
Reference in New Issue
Block a user