updates vm_impls and core.h to work with new vm_base

This commit is contained in:
Eyck-Alexander Jentzsch 2024-12-28 08:24:09 +01:00
parent a6a6f51f0b
commit 1089800682
5 changed files with 110 additions and 105 deletions

View File

@ -189,7 +189,6 @@ struct tgc5c: public arch_if {
uint8_t* get_regs_base_ptr() override;
inline uint64_t get_icount() { return reg.icount; }
inline bool should_stop() { return interrupt_sim; }
@ -199,7 +198,6 @@ struct tgc5c: public arch_if {
virtual iss::sync_type needed_sync() const { return iss::NO_SYNC; }
inline uint32_t get_last_branch() { return reg.last_branch; }
#pragma pack(push, 1)

View File

@ -94,7 +94,7 @@ protected:
using this_class = vm_impl<ARCH>;
using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
continuation_e gen_single_inst_behavior(virt_addr_t&, unsigned int &, jit_holder&) override;
continuation_e gen_single_inst_behavior(virt_addr_t&, jit_holder&) override;
enum globals_e {TVAL = 0, GLOBALS_SIZE};
void gen_block_prologue(jit_holder& jh) override;
void gen_block_epilogue(jit_holder& jh) override;
@ -4780,7 +4780,7 @@ vm_impl<ARCH>::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id)
}()) {}
template <typename ARCH>
continuation_e vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt, jit_holder& jh) {
continuation_e vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, jit_holder& jh) {
enum {TRAP_ID=1<<16};
code_word_t instr = 0;
phys_addr_t paddr(pc);
@ -4792,7 +4792,6 @@ continuation_e vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned
return ILLEGAL_FETCH;
if (instr == 0x0000006f || (instr&0xffff)==0xa001)
return JUMP_TO_SELF;
++inst_cnt;
uint32_t inst_index = instr_decoder.decode_instr(instr);
compile_func f = nullptr;
if(inst_index < instr_descr.size())

View File

@ -275,9 +275,6 @@ template <typename CODE_WORD> void debug_fn(CODE_WORD insn) {
volatile CODE_WORD x = insn;
insn = 2 * x;
}
template <typename ARCH> vm_impl<ARCH>::vm_impl() { this(new ARCH()); }
// according to
// https://stackoverflow.com/questions/8871204/count-number-of-1s-in-binary-representation
#ifdef __GCC__

View File

@ -97,7 +97,7 @@ protected:
return super::gen_cond_assign(cond, this->gen_ext(trueVal, size), this->gen_ext(falseVal, size));
}
std::tuple<continuation_e, BasicBlock *> gen_single_inst_behavior(virt_addr_t &, unsigned int &, BasicBlock *) override;
std::tuple<continuation_e, BasicBlock *> gen_single_inst_behavior(virt_addr_t &, BasicBlock *) override;
void gen_leave_behavior(BasicBlock *leave_blk) override;
void gen_raise_trap(uint16_t trap_id, uint16_t cause);
@ -4937,7 +4937,7 @@ vm_impl<ARCH>::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id)
template <typename ARCH>
std::tuple<continuation_e, BasicBlock *>
vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt, BasicBlock *this_block) {
vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, BasicBlock *this_block) {
// we fetch at max 4 byte, alignment is 2
enum {TRAP_ID=1<<16};
code_word_t instr = 0;
@ -4949,9 +4949,10 @@ vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt,
auto res = this->core.read(paddr, 4, data);
if (res != iss::Ok)
return std::make_tuple(ILLEGAL_FETCH, nullptr);
if (instr == 0x0000006f || (instr&0xffff)==0xa001)
if (instr == 0x0000006f || (instr&0xffff)==0xa001){
this->builder.CreateBr(this->leave_blk);
return std::make_tuple(JUMP_TO_SELF, nullptr);
++inst_cnt;
}
uint32_t inst_index = instr_decoder.decode_instr(instr);
compile_func f = nullptr;
if(inst_index < instr_descr.size())
@ -5033,6 +5034,10 @@ void vm_impl<ARCH>::gen_instr_epilogue(BasicBlock *bb) {
auto* icount_val = this->builder.CreateAdd(
this->builder.CreateLoad(this->get_typeptr(arch::traits<ARCH>::ICOUNT), get_reg_ptr(arch::traits<ARCH>::ICOUNT)), this->gen_const(64U, 1));
this->builder.CreateStore(icount_val, get_reg_ptr(arch::traits<ARCH>::ICOUNT), false);
//increment cyclecount
auto* cycle_val = this->builder.CreateAdd(
this->builder.CreateLoad(this->get_typeptr(arch::traits<ARCH>::CYCLE), get_reg_ptr(arch::traits<ARCH>::CYCLE)), this->gen_const(64U, 1));
this->builder.CreateStore(cycle_val, get_reg_ptr(arch::traits<ARCH>::CYCLE), false);
}
} // namespace tgc5c

View File

@ -81,16 +81,18 @@ protected:
using vm_base<ARCH>::get_reg_ptr;
using this_class = vm_impl<ARCH>;
using compile_ret_t = std::tuple<continuation_e>;
using compile_ret_t = continuation_e;
using compile_func = compile_ret_t (this_class::*)(virt_addr_t &pc, code_word_t instr, tu_builder&);
inline const char *name(size_t index){return traits::reg_aliases.at(index);}
void add_prologue(tu_builder& tu) override;
void setup_module(std::string m) override {
super::setup_module(m);
}
compile_ret_t gen_single_inst_behavior(virt_addr_t &, unsigned int &, tu_builder&) override;
compile_ret_t gen_single_inst_behavior(virt_addr_t &,tu_builder&) override;
void gen_trap_behavior(tu_builder& tu) override;
@ -352,7 +354,7 @@ private:
tu.store(rd + traits::X0, tu.constant((uint32_t)((int32_t)imm),32));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,0);
@ -387,7 +389,7 @@ private:
tu.store(rd + traits::X0, tu.constant((uint32_t)(PC+(int32_t)imm),32));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,1);
@ -432,7 +434,7 @@ private:
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
}
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,2);
@ -489,7 +491,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,3);
@ -538,7 +540,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,4);
@ -587,7 +589,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,5);
@ -636,7 +638,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,6);
@ -685,7 +687,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,7);
@ -734,7 +736,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,8);
@ -783,7 +785,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,9);
@ -823,7 +825,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,10);
@ -863,7 +865,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,11);
@ -903,7 +905,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,12);
@ -943,7 +945,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,13);
@ -983,7 +985,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,14);
@ -1020,7 +1022,7 @@ private:
tu.constant((int16_t)sext<12>(imm),16))),32,false),32);
tu.write_mem(traits::MEM, store_address, tu.ext(tu.load(rs2 + traits::X0, 0),8,false));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,15);
@ -1057,7 +1059,7 @@ private:
tu.constant((int16_t)sext<12>(imm),16))),32,false),32);
tu.write_mem(traits::MEM, store_address, tu.ext(tu.load(rs2 + traits::X0, 0),16,false));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,16);
@ -1094,7 +1096,7 @@ private:
tu.constant((int16_t)sext<12>(imm),16))),32,false),32);
tu.write_mem(traits::MEM, store_address, tu.ext(tu.load(rs2 + traits::X0, 0),32,false));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,17);
@ -1132,7 +1134,7 @@ private:
tu.constant((int16_t)sext<12>(imm),16))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,18);
@ -1170,7 +1172,7 @@ private:
tu.constant((int16_t)sext<12>(imm),16))), tu.constant(1,8),tu.constant(0,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,19);
@ -1208,7 +1210,7 @@ private:
tu.constant((uint32_t)((int16_t)sext<12>(imm)),32))), tu.constant(1,8),tu.constant(0,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,20);
@ -1246,7 +1248,7 @@ private:
tu.constant((uint32_t)((int16_t)sext<12>(imm)),32)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,21);
@ -1284,7 +1286,7 @@ private:
tu.constant((uint32_t)((int16_t)sext<12>(imm)),32)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,22);
@ -1322,7 +1324,7 @@ private:
tu.constant((uint32_t)((int16_t)sext<12>(imm)),32)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,23);
@ -1360,7 +1362,7 @@ private:
tu.constant(shamt,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,24);
@ -1398,7 +1400,7 @@ private:
tu.constant(shamt,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,25);
@ -1436,7 +1438,7 @@ private:
tu.constant(shamt,8))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,26);
@ -1474,7 +1476,7 @@ private:
tu.load(rs2 + traits::X0, 0))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,27);
@ -1512,7 +1514,7 @@ private:
tu.load(rs2 + traits::X0, 0))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,28);
@ -1552,7 +1554,7 @@ private:
tu.constant((static_cast<uint32_t>(traits:: XLEN)-1),64)))));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,29);
@ -1590,7 +1592,7 @@ private:
tu.ext(tu.load(rs2 + traits::X0, 0),32,true)), tu.constant(1,8),tu.constant(0,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,30);
@ -1628,7 +1630,7 @@ private:
tu.load(rs2 + traits::X0, 0)), tu.constant(1,8),tu.constant(0,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,31);
@ -1666,7 +1668,7 @@ private:
tu.load(rs2 + traits::X0, 0)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,32);
@ -1706,7 +1708,7 @@ private:
tu.constant((static_cast<uint32_t>(traits:: XLEN)-1),64)))));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,33);
@ -1746,7 +1748,7 @@ private:
tu.constant((static_cast<uint32_t>(traits:: XLEN)-1),64))))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,34);
@ -1784,7 +1786,7 @@ private:
tu.load(rs2 + traits::X0, 0)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,35);
@ -1822,7 +1824,7 @@ private:
tu.load(rs2 + traits::X0, 0)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,36);
@ -1853,7 +1855,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
tu.write_mem(traits::FENCE, static_cast<uint32_t>(traits:: fence), tu.constant((uint8_t)pred<<4|succ,8));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,37);
@ -1879,7 +1881,7 @@ private:
this->gen_set_tval(tu, instr);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(NO_JUMP),32));
this->gen_raise_trap(tu, 0, 11);
auto returnValue = std::make_tuple(TRAP);
auto returnValue = TRAP;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,38);
@ -1905,7 +1907,7 @@ private:
this->gen_set_tval(tu, instr);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(NO_JUMP),32));
this->gen_raise_trap(tu, 0, 3);
auto returnValue = std::make_tuple(TRAP);
auto returnValue = TRAP;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,39);
@ -1931,7 +1933,7 @@ private:
this->gen_set_tval(tu, instr);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(NO_JUMP),32));
this->gen_leave_trap(tu, 3);
auto returnValue = std::make_tuple(TRAP);
auto returnValue = TRAP;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,40);
@ -1956,7 +1958,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
tu.callf("wait", tu.constant(1,8));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,41);
@ -1997,7 +1999,7 @@ private:
tu.write_mem(traits::CSR, csr, xrs1);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,42);
@ -2040,7 +2042,7 @@ private:
tu.store(rd + traits::X0, xrd);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,43);
@ -2083,7 +2085,7 @@ private:
tu.store(rd + traits::X0, xrd);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,44);
@ -2121,7 +2123,7 @@ private:
tu.store(rd + traits::X0, xrd);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,45);
@ -2163,7 +2165,7 @@ private:
tu.store(rd + traits::X0, xrd);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,46);
@ -2205,7 +2207,7 @@ private:
tu.store(rd + traits::X0, xrd);
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,47);
@ -2234,7 +2236,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
tu.write_mem(traits::FENCE, static_cast<uint32_t>(traits:: fencei), tu.constant(imm,16));
auto returnValue = std::make_tuple(FLUSH);
auto returnValue = FLUSH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,48);
@ -2273,7 +2275,7 @@ private:
tu.store(rd + traits::X0, tu.ext(res,32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,49);
@ -2314,7 +2316,7 @@ private:
tu.constant(static_cast<uint32_t>(traits:: XLEN),32))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,50);
@ -2355,7 +2357,7 @@ private:
tu.constant(static_cast<uint32_t>(traits:: XLEN),32))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,51);
@ -2396,7 +2398,7 @@ private:
tu.constant(static_cast<uint32_t>(traits:: XLEN),32))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,52);
@ -2460,7 +2462,7 @@ private:
tu.close_scope();
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,53);
@ -2510,7 +2512,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,54);
@ -2577,7 +2579,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,55);
@ -2627,7 +2629,7 @@ private:
}
tu.close_scope();
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,56);
@ -2662,7 +2664,7 @@ private:
else{
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,57);
@ -2694,7 +2696,7 @@ private:
tu.load(rs1+8 + traits::X0, 0),
tu.constant(uimm,8))),32,false),32);
tu.store(rd+8 + traits::X0, tu.ext(tu.ext(tu.read_mem(traits::MEM, offs, 32),32,true),32,false));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,58);
@ -2726,7 +2728,7 @@ private:
tu.load(rs1+8 + traits::X0, 0),
tu.constant(uimm,8))),32,false),32);
tu.write_mem(traits::MEM, offs, tu.ext(tu.load(rs2+8 + traits::X0, 0),32,false));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,59);
@ -2763,7 +2765,7 @@ private:
tu.constant((int8_t)sext<6>(imm),8))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,60);
@ -2788,7 +2790,7 @@ private:
gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope();
this->gen_set_tval(tu, instr);
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,61);
@ -2819,7 +2821,7 @@ private:
auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<12>(imm)),32);
tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,62);
@ -2854,7 +2856,7 @@ private:
tu.store(rd + traits::X0, tu.constant((uint32_t)((int8_t)sext<6>(imm)),32));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,63);
@ -2887,7 +2889,7 @@ private:
if(rd!=0) {
tu.store(rd + traits::X0, tu.constant((uint32_t)((int32_t)sext<18>(imm)),32));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,64);
@ -2921,7 +2923,7 @@ private:
else{
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,65);
@ -2947,7 +2949,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,66);
@ -2977,7 +2979,7 @@ private:
tu.store(rs1+8 + traits::X0, tu.lshr(
tu.load(rs1+8 + traits::X0, 0),
tu.constant(shamt,8)));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,67);
@ -3014,7 +3016,7 @@ private:
tu.constant(64,8))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,68);
@ -3044,7 +3046,7 @@ private:
tu.store(rs1+8 + traits::X0, tu.ext((tu.bitwise_and(
tu.load(rs1+8 + traits::X0, 0),
tu.constant((int8_t)sext<6>(imm),8))),32,false));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,69);
@ -3074,7 +3076,7 @@ private:
tu.store(rd+8 + traits::X0, tu.ext((tu.sub(
tu.load(rd+8 + traits::X0, 0),
tu.load(rs2+8 + traits::X0, 0))),32,false));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,70);
@ -3104,7 +3106,7 @@ private:
tu.store(rd+8 + traits::X0, tu.bitwise_xor(
tu.load(rd+8 + traits::X0, 0),
tu.load(rs2+8 + traits::X0, 0)));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,71);
@ -3134,7 +3136,7 @@ private:
tu.store(rd+8 + traits::X0, tu.bitwise_or(
tu.load(rd+8 + traits::X0, 0),
tu.load(rs2+8 + traits::X0, 0)));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,72);
@ -3164,7 +3166,7 @@ private:
tu.store(rd+8 + traits::X0, tu.bitwise_and(
tu.load(rd+8 + traits::X0, 0),
tu.load(rs2+8 + traits::X0, 0)));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,73);
@ -3194,7 +3196,7 @@ private:
auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<12>(imm)),32);
tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,74);
@ -3231,7 +3233,7 @@ private:
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
}
tu.close_scope();
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,75);
@ -3268,7 +3270,7 @@ private:
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
}
tu.close_scope();
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,76);
@ -3305,7 +3307,7 @@ private:
tu.constant(nzuimm,8)));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,77);
@ -3341,7 +3343,7 @@ private:
tu.constant(uimm,8))),32,false),32);
tu.store(rd + traits::X0, tu.ext(tu.ext(tu.read_mem(traits::MEM, offs, 32),32,true),32,false));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,78);
@ -3376,7 +3378,7 @@ private:
tu.store(rd + traits::X0, tu.load(rs2 + traits::X0, 0));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,79);
@ -3413,7 +3415,7 @@ private:
else{
this->gen_raise_trap(tu, 0, 2);
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,80);
@ -3438,7 +3440,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
this->gen_raise_trap(tu, 0, 2);
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,81);
@ -3475,7 +3477,7 @@ private:
tu.load(rs2 + traits::X0, 0))),32,false));
}
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,82);
@ -3515,7 +3517,7 @@ private:
tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(UNKNOWN_JUMP), 2));
}
auto returnValue = std::make_tuple(BRANCH);
auto returnValue = BRANCH;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,83);
@ -3540,7 +3542,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
this->gen_raise_trap(tu, 0, 3);
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,84);
@ -3576,7 +3578,7 @@ private:
tu.constant(uimm,8))),32,false),32);
tu.write_mem(traits::MEM, offs, tu.ext(tu.load(rs2 + traits::X0, 0),32,false));
}
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,85);
@ -3601,7 +3603,7 @@ private:
tu.open_scope();
this->gen_set_tval(tu, instr);
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION));
auto returnValue = std::make_tuple(CONT);
auto returnValue = CONT;
tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,86);
@ -3648,8 +3650,8 @@ vm_impl<ARCH>::vm_impl(ARCH &core, unsigned core_id, unsigned cluster_id)
}()) {}
template <typename ARCH>
std::tuple<continuation_e>
vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt, tu_builder& tu) {
continuation_e
vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, tu_builder& tu) {
// we fetch at max 4 byte, alignment is 2
enum {TRAP_ID=1<<16};
code_word_t instr = 0;
@ -3661,7 +3663,6 @@ vm_impl<ARCH>::gen_single_inst_behavior(virt_addr_t &pc, unsigned int &inst_cnt,
return ILLEGAL_FETCH;
if (instr == 0x0000006f || (instr&0xffff)==0xa001)
return JUMP_TO_SELF;
++inst_cnt;
uint32_t inst_index = instr_decoder.decode_instr(instr);
compile_func f = nullptr;
if(inst_index < instr_descr.size())
@ -3697,7 +3698,12 @@ template <typename ARCH> void vm_impl<ARCH>::gen_trap_behavior(tu_builder& tu) {
tu("return *next_pc;");
}
template <typename ARCH> void vm_impl<ARCH>::add_prologue(tu_builder& tu){
std::ostringstream os;
os << tu.add_reg_ptr("trap_state", arch::traits<ARCH>::TRAP_STATE, this->regs_base_ptr);
os << tu.add_reg_ptr("pending_trap", arch::traits<ARCH>::PENDING_TRAP, this->regs_base_ptr);
tu.add_prologue(os.str());
}
} // namespace tgc5c
template <>