Compare commits

..

No commits in common. "ad604490738a9e5115804c3ab366b39c251f9137" and "1fb7e8fcea2639852c03d53eb32fce8803e9f68a" have entirely different histories.

5 changed files with 59 additions and 99 deletions

View File

@ -308,7 +308,6 @@ inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t
auto tmp1 = get_reg_for(cc, traits::TRAP_STATE); auto tmp1 = get_reg_for(cc, traits::TRAP_STATE);
mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id);
mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1);
cc.jmp(jh.trap_entry);
} }
template <typename ARCH> template <typename ARCH>
template <typename T, typename> template <typename T, typename>

View File

@ -279,7 +279,6 @@ template <typename ARCH>
void vm_impl<ARCH>::gen_raise_trap(uint16_t trap_id, uint16_t cause) { void vm_impl<ARCH>::gen_raise_trap(uint16_t trap_id, uint16_t cause) {
auto *TRAP_val = this->gen_const(32, 0x80 << 24 | (cause << 16) | trap_id); auto *TRAP_val = this->gen_const(32, 0x80 << 24 | (cause << 16) | trap_id);
this->builder.CreateStore(TRAP_val, get_reg_ptr(traits::TRAP_STATE), true); this->builder.CreateStore(TRAP_val, get_reg_ptr(traits::TRAP_STATE), true);
this->builder.CreateBr(this->trap_blk);
} }
template <typename ARCH> template <typename ARCH>

View File

@ -1421,23 +1421,25 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
auto label_then11 = cc.newLabel(); {
auto label_merge11 = cc.newLabel(); auto label_then = cc.newLabel();
auto tmp_reg11 = get_reg(cc, 8, false); auto label_merge = cc.newLabel();
auto tmp_reg = get_reg_for(cc, 1);
cmp(cc, gen_ext(cc, cmp(cc, gen_ext(cc,
load_reg_from_mem(jh, traits::X0 + rs1), 32, true), (int16_t)sext<12>(imm)); load_reg_from_mem(jh, traits::X0 + rs1), 32, true), (int16_t)sext<12>(imm));
cc.jl(label_then11); cc.jl(label_then);
mov(cc, tmp_reg11,0); mov(cc, tmp_reg,0);
cc.jmp(label_merge11); cc.jmp(label_merge);
cc.bind(label_then11); cc.bind(label_then);
mov(cc, tmp_reg11, 1); mov(cc, tmp_reg,1);
cc.bind(label_merge11); cc.bind(label_merge);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg11 gen_ext(cc, tmp_reg
, 32, false) , 32, false)
); );
} }
} }
}
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 19); gen_sync(jh, POST_SYNC, 19);
@ -1482,22 +1484,24 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
auto label_then12 = cc.newLabel(); {
auto label_merge12 = cc.newLabel(); auto label_then = cc.newLabel();
auto tmp_reg12 = get_reg(cc, 8, false); auto label_merge = cc.newLabel();
auto tmp_reg = get_reg_for(cc, 1);
cmp(cc, 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_then12); cc.jb(label_then);
mov(cc, tmp_reg12,0); mov(cc, tmp_reg,0);
cc.jmp(label_merge12); cc.jmp(label_merge);
cc.bind(label_then12); cc.bind(label_then);
mov(cc, tmp_reg12, 1); mov(cc, tmp_reg,1);
cc.bind(label_merge12); cc.bind(label_merge);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg12 gen_ext(cc, tmp_reg
, 32, false) , 32, false)
); );
} }
} }
}
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 20); gen_sync(jh, POST_SYNC, 20);
@ -1988,24 +1992,26 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
auto label_then13 = cc.newLabel(); {
auto label_merge13 = cc.newLabel(); auto label_then = cc.newLabel();
auto tmp_reg13 = get_reg(cc, 8, false); auto label_merge = cc.newLabel();
auto tmp_reg = get_reg_for(cc, 1);
cmp(cc, gen_ext(cc, cmp(cc, gen_ext(cc,
load_reg_from_mem(jh, traits::X0 + rs1), 32, true), gen_ext(cc, load_reg_from_mem(jh, traits::X0 + rs1), 32, true), gen_ext(cc,
load_reg_from_mem(jh, traits::X0 + rs2), 32, true)); load_reg_from_mem(jh, traits::X0 + rs2), 32, true));
cc.jl(label_then13); cc.jl(label_then);
mov(cc, tmp_reg13,0); mov(cc, tmp_reg,0);
cc.jmp(label_merge13); cc.jmp(label_merge);
cc.bind(label_then13); cc.bind(label_then);
mov(cc, tmp_reg13, 1); mov(cc, tmp_reg,1);
cc.bind(label_merge13); cc.bind(label_merge);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg13 gen_ext(cc, tmp_reg
, 32, false) , 32, false)
); );
} }
} }
}
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 30); gen_sync(jh, POST_SYNC, 30);
@ -2050,22 +2056,24 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
auto label_then14 = cc.newLabel(); {
auto label_merge14 = cc.newLabel(); auto label_then = cc.newLabel();
auto tmp_reg14 = get_reg(cc, 8, false); auto label_merge = cc.newLabel();
auto tmp_reg = get_reg_for(cc, 1);
cmp(cc, 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_then14); cc.jb(label_then);
mov(cc, tmp_reg14,0); mov(cc, tmp_reg,0);
cc.jmp(label_merge14); cc.jmp(label_merge);
cc.bind(label_then14); cc.bind(label_then);
mov(cc, tmp_reg14, 1); mov(cc, tmp_reg,1);
cc.bind(label_merge14); cc.bind(label_merge);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg14 gen_ext(cc, tmp_reg
, 32, false) , 32, false)
); );
} }
} }
}
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 31); gen_sync(jh, POST_SYNC, 31);
@ -2503,10 +2511,10 @@ private:
gen_instr_prologue(jh); gen_instr_prologue(jh);
cc.comment("//behavior:"); cc.comment("//behavior:");
/*generate behavior*/ /*generate behavior*/
InvokeNode* call_wait_15; InvokeNode* call_wait;
jh.cc.comment("//call_wait"); jh.cc.comment("//call_wait");
jh.cc.invoke(&call_wait_15, &wait, FuncSignature::build<void, int32_t>()); jh.cc.invoke(&call_wait, &wait, FuncSignature::build<void, int32_t>());
setArg(call_wait_15, 0, 1); setArg(call_wait, 0, 1);
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 41); gen_sync(jh, POST_SYNC, 41);
@ -4867,7 +4875,6 @@ inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t
auto tmp1 = get_reg_for(cc, traits::TRAP_STATE); auto tmp1 = get_reg_for(cc, traits::TRAP_STATE);
mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id);
mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1);
cc.jmp(jh.trap_entry);
} }
template <typename ARCH> template <typename ARCH>
template <typename T, typename> template <typename T, typename>

View File

@ -1490,7 +1490,7 @@ private:
), ),
this->gen_const(8,1), this->gen_const(8,1),
this->gen_const(8,0), this->gen_const(8,0),
8), 32), 1), 32),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -1543,7 +1543,7 @@ private:
), ),
this->gen_const(8,1), this->gen_const(8,1),
this->gen_const(8,0), this->gen_const(8,0),
8), 32), 1), 32),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -2057,7 +2057,7 @@ private:
, ,
this->gen_const(8,1), this->gen_const(8,1),
this->gen_const(8,0), this->gen_const(8,0),
8), 32), 1), 32),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -2110,7 +2110,7 @@ private:
, ,
this->gen_const(8,1), this->gen_const(8,1),
this->gen_const(8,0), this->gen_const(8,0),
8), 32), 1), 32),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -2553,10 +2553,10 @@ private:
this->gen_instr_prologue(); this->gen_instr_prologue();
/*generate behavior*/ /*generate behavior*/
std::vector<Value*> wait_231_args{ std::vector<Value*> wait_args{
this->gen_ext(this->gen_const(8,1), 32) this->gen_ext(this->gen_const(8,1), 32)
}; };
this->builder.CreateCall(this->mod->getFunction("wait"), wait_231_args); this->builder.CreateCall(this->mod->getFunction("wait"), wait_args);
bb = BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk); bb = BasicBlock::Create(this->mod->getContext(), "entry", this->func, this->leave_blk);
auto returnValue = std::make_tuple(CONT,bb); auto returnValue = std::make_tuple(CONT,bb);
@ -4972,7 +4972,6 @@ template <typename ARCH>
void vm_impl<ARCH>::gen_raise_trap(uint16_t trap_id, uint16_t cause) { void vm_impl<ARCH>::gen_raise_trap(uint16_t trap_id, uint16_t cause) {
auto *TRAP_val = this->gen_const(32, 0x80 << 24 | (cause << 16) | trap_id); auto *TRAP_val = this->gen_const(32, 0x80 << 24 | (cause << 16) | trap_id);
this->builder.CreateStore(TRAP_val, get_reg_ptr(traits::TRAP_STATE), true); this->builder.CreateStore(TRAP_val, get_reg_ptr(traits::TRAP_STATE), true);
this->builder.CreateBr(this->trap_blk);
} }
template <typename ARCH> template <typename ARCH>

View File

@ -474,19 +474,15 @@ private:
tu.open_if(tu.urem( tu.open_if(tu.urem(
new_pc, new_pc,
tu.constant(static_cast<uint32_t>(traits:: INSTR_ALIGNMENT),32))); tu.constant(static_cast<uint32_t>(traits:: INSTR_ALIGNMENT),32)));
{
this->gen_set_tval(tu, new_pc); this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
}
tu.open_else(); tu.open_else();
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.constant((uint32_t)(PC+4),32)); tu.store(rd + traits::X0, tu.constant((uint32_t)(PC+4),32));
} }
auto PC_val_v = tu.assignment("PC_val", new_pc,32); auto PC_val_v = tu.assignment("PC_val", new_pc,32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(UNKNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(UNKNOWN_JUMP), 2));
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -525,7 +521,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_EQ, tu.open_if(tu.icmp(ICmpInst::ICMP_EQ,
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -535,7 +530,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -574,7 +568,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -584,7 +577,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -623,7 +615,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_SLT, tu.open_if(tu.icmp(ICmpInst::ICMP_SLT,
tu.ext(tu.load(rs1 + traits::X0, 0),32,true), tu.ext(tu.load(rs1 + traits::X0, 0),32,true),
tu.ext(tu.load(rs2 + traits::X0, 0),32,true))); tu.ext(tu.load(rs2 + traits::X0, 0),32,true)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -633,7 +624,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -672,7 +662,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_SGE, tu.open_if(tu.icmp(ICmpInst::ICMP_SGE,
tu.ext(tu.load(rs1 + traits::X0, 0),32,true), tu.ext(tu.load(rs1 + traits::X0, 0),32,true),
tu.ext(tu.load(rs2 + traits::X0, 0),32,true))); tu.ext(tu.load(rs2 + traits::X0, 0),32,true)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -682,7 +671,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -721,7 +709,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_ULT, tu.open_if(tu.icmp(ICmpInst::ICMP_ULT,
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -731,7 +718,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -770,7 +756,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_UGE, tu.open_if(tu.icmp(ICmpInst::ICMP_UGE,
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
{
auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm)); auto new_pc = (uint32_t)(PC+(int16_t)sext<13>(imm));
if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc); if(new_pc%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_set_tval(tu, new_pc);
this->gen_raise_trap(tu, 0, 0); this->gen_raise_trap(tu, 0, 0);
@ -780,7 +765,6 @@ private:
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -2433,7 +2417,6 @@ private:
if(rd!=0){ tu.open_if(tu.icmp(ICmpInst::ICMP_NE, if(rd!=0){ tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
divisor, divisor,
tu.constant(0,8))); tu.constant(0,8)));
{
auto MMIN = ((uint32_t)1)<<(static_cast<uint32_t>(traits:: XLEN)-1); auto MMIN = ((uint32_t)1)<<(static_cast<uint32_t>(traits:: XLEN)-1);
tu.open_if(tu.logical_and( tu.open_if(tu.logical_and(
tu.icmp(ICmpInst::ICMP_EQ, tu.icmp(ICmpInst::ICMP_EQ,
@ -2442,21 +2425,14 @@ private:
tu.icmp(ICmpInst::ICMP_EQ, tu.icmp(ICmpInst::ICMP_EQ,
divisor, divisor,
tu.constant(- 1,8)))); tu.constant(- 1,8))));
{
tu.store(rd + traits::X0, tu.constant(MMIN,32)); tu.store(rd + traits::X0, tu.constant(MMIN,32));
}
tu.open_else(); tu.open_else();
{
tu.store(rd + traits::X0, tu.ext((tu.sdiv( tu.store(rd + traits::X0, tu.ext((tu.sdiv(
dividend, dividend,
divisor)),32,false)); divisor)),32,false));
}
tu.close_scope(); tu.close_scope();
}
tu.open_else(); tu.open_else();
{
tu.store(rd + traits::X0, tu.constant((uint32_t)- 1,32)); tu.store(rd + traits::X0, tu.constant((uint32_t)- 1,32));
}
tu.close_scope(); tu.close_scope();
} }
} }
@ -2495,19 +2471,15 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
tu.load(rs2 + traits::X0, 0), tu.load(rs2 + traits::X0, 0),
tu.constant(0,8))); tu.constant(0,8)));
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.udiv( tu.store(rd + traits::X0, tu.udiv(
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
} }
}
tu.open_else(); tu.open_else();
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.constant((uint32_t)- 1,32)); tu.store(rd + traits::X0, tu.constant((uint32_t)- 1,32));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -2545,7 +2517,6 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
tu.load(rs2 + traits::X0, 0), tu.load(rs2 + traits::X0, 0),
tu.constant(0,8))); tu.constant(0,8)));
{
auto MMIN = (uint32_t)1<<(static_cast<uint32_t>(traits:: XLEN)-1); auto MMIN = (uint32_t)1<<(static_cast<uint32_t>(traits:: XLEN)-1);
tu.open_if(tu.logical_and( tu.open_if(tu.logical_and(
tu.icmp(ICmpInst::ICMP_EQ, tu.icmp(ICmpInst::ICMP_EQ,
@ -2554,27 +2525,20 @@ private:
tu.icmp(ICmpInst::ICMP_EQ, tu.icmp(ICmpInst::ICMP_EQ,
tu.ext(tu.load(rs2 + traits::X0, 0),32,true), tu.ext(tu.load(rs2 + traits::X0, 0),32,true),
tu.constant(- 1,8)))); tu.constant(- 1,8))));
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.constant(0,8)); tu.store(rd + traits::X0, tu.constant(0,8));
} }
}
tu.open_else(); tu.open_else();
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.ext((tu.srem( tu.store(rd + traits::X0, tu.ext((tu.srem(
tu.ext(tu.load(rs1 + traits::X0, 0),32,true), tu.ext(tu.load(rs1 + traits::X0, 0),32,true),
tu.ext(tu.load(rs2 + traits::X0, 0),32,true))),32,false)); tu.ext(tu.load(rs2 + traits::X0, 0),32,true))),32,false));
} }
}
tu.close_scope(); tu.close_scope();
}
tu.open_else(); tu.open_else();
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.load(rs1 + traits::X0, 0)); tu.store(rd + traits::X0, tu.load(rs1 + traits::X0, 0));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -2612,19 +2576,15 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
tu.load(rs2 + traits::X0, 0), tu.load(rs2 + traits::X0, 0),
tu.constant(0,8))); tu.constant(0,8)));
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.urem( tu.store(rd + traits::X0, tu.urem(
tu.load(rs1 + traits::X0, 0), tu.load(rs1 + traits::X0, 0),
tu.load(rs2 + traits::X0, 0))); tu.load(rs2 + traits::X0, 0)));
} }
}
tu.open_else(); tu.open_else();
{
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.load(rs1 + traits::X0, 0)); tu.store(rd + traits::X0, tu.load(rs1 + traits::X0, 0));
} }
}
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -3225,11 +3185,9 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_EQ, tu.open_if(tu.icmp(ICmpInst::ICMP_EQ,
tu.load(rs1+8 + traits::X0, 0), tu.load(rs1+8 + traits::X0, 0),
tu.constant(0,8))); tu.constant(0,8)));
{
auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<9>(imm)),32); auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<9>(imm)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
}
tu.close_scope(); tu.close_scope();
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -3262,11 +3220,9 @@ private:
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
tu.load(rs1+8 + traits::X0, 0), tu.load(rs1+8 + traits::X0, 0),
tu.constant(0,8))); tu.constant(0,8)));
{
auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<9>(imm)),32); auto PC_val_v = tu.assignment("PC_val", (uint32_t)(PC+(int16_t)sext<9>(imm)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2)); tu.store(traits::LAST_BRANCH, tu.constant(static_cast<int>(KNOWN_JUMP), 2));
}
tu.close_scope(); tu.close_scope();
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);