updates generated cores

This commit is contained in:
Eyck-Alexander Jentzsch 2024-09-27 20:04:58 +02:00
parent b45b3589fa
commit ad60449073
3 changed files with 97 additions and 59 deletions

View File

@ -1421,23 +1421,21 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
{ auto label_then11 = cc.newLabel();
auto label_then = cc.newLabel(); auto label_merge11 = cc.newLabel();
auto label_merge = cc.newLabel(); auto tmp_reg11 = get_reg(cc, 8, false);
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_then); cc.jl(label_then11);
mov(cc, tmp_reg,0); mov(cc, tmp_reg11,0);
cc.jmp(label_merge); cc.jmp(label_merge11);
cc.bind(label_then); cc.bind(label_then11);
mov(cc, tmp_reg,1); mov(cc, tmp_reg11, 1);
cc.bind(label_merge); cc.bind(label_merge11);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg gen_ext(cc, tmp_reg11
, 32, false) , 32, false)
); );
}
} }
} }
auto returnValue = CONT; auto returnValue = CONT;
@ -1484,22 +1482,20 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
{ auto label_then12 = cc.newLabel();
auto label_then = cc.newLabel(); auto label_merge12 = cc.newLabel();
auto label_merge = cc.newLabel(); auto tmp_reg12 = get_reg(cc, 8, false);
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_then); cc.jb(label_then12);
mov(cc, tmp_reg,0); mov(cc, tmp_reg12,0);
cc.jmp(label_merge); cc.jmp(label_merge12);
cc.bind(label_then); cc.bind(label_then12);
mov(cc, tmp_reg,1); mov(cc, tmp_reg12, 1);
cc.bind(label_merge); cc.bind(label_merge12);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg gen_ext(cc, tmp_reg12
, 32, false) , 32, false)
); );
}
} }
} }
auto returnValue = CONT; auto returnValue = CONT;
@ -1992,24 +1988,22 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
{ auto label_then13 = cc.newLabel();
auto label_then = cc.newLabel(); auto label_merge13 = cc.newLabel();
auto label_merge = cc.newLabel(); auto tmp_reg13 = get_reg(cc, 8, false);
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_then); cc.jl(label_then13);
mov(cc, tmp_reg,0); mov(cc, tmp_reg13,0);
cc.jmp(label_merge); cc.jmp(label_merge13);
cc.bind(label_then); cc.bind(label_then13);
mov(cc, tmp_reg,1); mov(cc, tmp_reg13, 1);
cc.bind(label_merge); cc.bind(label_merge13);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg gen_ext(cc, tmp_reg13
, 32, false) , 32, false)
); );
}
} }
} }
auto returnValue = CONT; auto returnValue = CONT;
@ -2056,22 +2050,20 @@ private:
} }
else{ else{
if(rd!=0){ if(rd!=0){
{ auto label_then14 = cc.newLabel();
auto label_then = cc.newLabel(); auto label_merge14 = cc.newLabel();
auto label_merge = cc.newLabel(); auto tmp_reg14 = get_reg(cc, 8, false);
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_then); cc.jb(label_then14);
mov(cc, tmp_reg,0); mov(cc, tmp_reg14,0);
cc.jmp(label_merge); cc.jmp(label_merge14);
cc.bind(label_then); cc.bind(label_then14);
mov(cc, tmp_reg,1); mov(cc, tmp_reg14, 1);
cc.bind(label_merge); cc.bind(label_merge14);
mov(cc, get_ptr_for(jh, traits::X0+ rd), mov(cc, get_ptr_for(jh, traits::X0+ rd),
gen_ext(cc, tmp_reg gen_ext(cc, tmp_reg14
, 32, false) , 32, false)
); );
}
} }
} }
auto returnValue = CONT; auto returnValue = CONT;
@ -2511,10 +2503,10 @@ private:
gen_instr_prologue(jh); gen_instr_prologue(jh);
cc.comment("//behavior:"); cc.comment("//behavior:");
/*generate behavior*/ /*generate behavior*/
InvokeNode* call_wait; InvokeNode* call_wait_15;
jh.cc.comment("//call_wait"); jh.cc.comment("//call_wait");
jh.cc.invoke(&call_wait, &wait, FuncSignature::build<void, int32_t>()); jh.cc.invoke(&call_wait_15, &wait, FuncSignature::build<void, int32_t>());
setArg(call_wait, 0, 1); setArg(call_wait_15, 0, 1);
auto returnValue = CONT; auto returnValue = CONT;
gen_sync(jh, POST_SYNC, 41); gen_sync(jh, POST_SYNC, 41);
@ -4875,6 +4867,7 @@ 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),
1), 32), 8), 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),
1), 32), 8), 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),
1), 32), 8), 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),
1), 32), 8), 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_args{ std::vector<Value*> wait_231_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_args); this->builder.CreateCall(this->mod->getFunction("wait"), wait_231_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);
@ -4897,7 +4897,7 @@ private:
}; };
this->builder.CreateCall(this->mod->getFunction("print_disass"), args); this->builder.CreateCall(this->mod->getFunction("print_disass"), args);
} }
this->gen_sync(iss::PRE_SYNC, instr_descr.size()); this->gen_sync(iss::PRE_SYNC, instr_descr.size());
this->builder.CreateStore(this->builder.CreateLoad(this->get_typeptr(traits::NEXT_PC), get_reg_ptr(traits::NEXT_PC), true), this->builder.CreateStore(this->builder.CreateLoad(this->get_typeptr(traits::NEXT_PC), get_reg_ptr(traits::NEXT_PC), true),
get_reg_ptr(traits::PC), true); get_reg_ptr(traits::PC), true);
this->builder.CreateStore( this->builder.CreateStore(
@ -4972,6 +4972,7 @@ 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>
@ -5074,4 +5075,4 @@ volatile std::array<bool, 2> dummy = {
}; };
} }
} }
// clang-format on // clang-format on

View File

@ -474,15 +474,19 @@ 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);
@ -521,6 +525,7 @@ 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);
@ -530,6 +535,7 @@ 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);
@ -568,6 +574,7 @@ 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);
@ -577,6 +584,7 @@ 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);
@ -615,6 +623,7 @@ 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);
@ -624,6 +633,7 @@ 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);
@ -662,6 +672,7 @@ 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);
@ -671,6 +682,7 @@ 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);
@ -709,6 +721,7 @@ 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);
@ -718,6 +731,7 @@ 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);
@ -756,6 +770,7 @@ 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);
@ -765,6 +780,7 @@ 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);
@ -2417,6 +2433,7 @@ 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,
@ -2425,14 +2442,21 @@ 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();
} }
} }
@ -2471,15 +2495,19 @@ 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);
@ -2517,6 +2545,7 @@ 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,
@ -2525,20 +2554,27 @@ 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);
@ -2576,15 +2612,19 @@ 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);
@ -3185,9 +3225,11 @@ 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);
@ -3220,9 +3262,11 @@ 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);