adds fix for compressed instructions and reads

This commit is contained in:
Eyck-Alexander Jentzsch 2023-06-05 17:57:38 +02:00
parent 2281ec4144
commit 15cd36dcd4
2 changed files with 108 additions and 108 deletions

View File

@ -207,7 +207,7 @@ private:
${it}<%}%> ${it}<%}%>
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ ${instr.length/8};
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope();<%instr.behavior.eachLine{%> tu.open_scope();<%instr.behavior.eachLine{%>
${it}<%}%> ${it}<%}%>

View File

@ -462,7 +462,7 @@ private:
} }
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int32_t)sext<21>(imm),32)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int32_t)sext<21>(imm),32)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -503,7 +503,7 @@ private:
} }
auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(new_pc,tu.constant(~ 0x1,8)),32); auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(new_pc,tu.constant(~ 0x1,8)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
tu.close_scope(); tu.close_scope();
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
@ -541,7 +541,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -580,7 +580,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -619,7 +619,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -658,7 +658,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -697,7 +697,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -736,7 +736,7 @@ private:
else{ else{
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<13>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
tu.close_scope(); tu.close_scope();
} }
@ -1776,7 +1776,7 @@ private:
} }
else{ else{
auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32); auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32);
if(rd!= 0){ auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); if(rd!= 0){ auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
tu.write_mem(traits::MEM, csr, xrs1); tu.write_mem(traits::MEM, csr, xrs1);
tu.store(rd + traits::X0,xrd); tu.store(rd + traits::X0,xrd);
} }
@ -1813,7 +1813,7 @@ private:
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32); auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32);
if(rs1!= 0) { if(rs1!= 0) {
tu.write_mem(traits::MEM, csr, tu.bitwise_or(xrd,xrs1)); tu.write_mem(traits::MEM, csr, tu.bitwise_or(xrd,xrs1));
@ -1851,7 +1851,7 @@ private:
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32); auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32);
if(rs1!= 0) { if(rs1!= 0) {
tu.write_mem(traits::MEM, csr, tu.bitwise_and(xrd,tu.logical_neg(xrs1))); tu.write_mem(traits::MEM, csr, tu.bitwise_and(xrd,tu.logical_neg(xrs1)));
@ -1889,7 +1889,7 @@ private:
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
tu.write_mem(traits::MEM, csr, tu.constant((uint32_t)zimm,32)); tu.write_mem(traits::MEM, csr, tu.constant((uint32_t)zimm,32));
if(rd!= 0) { if(rd!= 0) {
tu.store(rd + traits::X0,xrd); tu.store(rd + traits::X0,xrd);
@ -1924,7 +1924,7 @@ private:
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
if(zimm!= 0) { if(zimm!= 0) {
tu.write_mem(traits::MEM, csr, tu.bitwise_or(xrd,tu.constant((uint32_t)zimm,32))); tu.write_mem(traits::MEM, csr, tu.bitwise_or(xrd,tu.constant((uint32_t)zimm,32)));
} }
@ -1961,7 +1961,7 @@ private:
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::MEM, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
if(zimm!= 0) { if(zimm!= 0) {
tu.write_mem(traits::MEM, csr, tu.bitwise_and(xrd,tu.constant(~ ((uint32_t)zimm),32))); tu.write_mem(traits::MEM, csr, tu.bitwise_and(xrd,tu.constant(~ ((uint32_t)zimm),32)));
} }
@ -2319,7 +2319,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(imm) { if(imm) {
@ -2350,7 +2350,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
auto load_address = tu.assignment(tu.add(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(uimm,8)),32); auto load_address = tu.assignment(tu.add(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(uimm,8)),32);
@ -2377,7 +2377,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
auto load_address = tu.assignment(tu.add(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(uimm,8)),32); auto load_address = tu.assignment(tu.add(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(uimm,8)),32);
@ -2403,7 +2403,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs1>=static_cast<uint32_t>(traits:: RFS)) {
@ -2431,7 +2431,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "cnop"); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "cnop");
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -2454,13 +2454,13 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(1 + traits::X0,tu.add(tu.ext(cur_pc_val,32,false),tu.constant( 2,32))); tu.store(1 + traits::X0,tu.add(tu.ext(cur_pc_val,32,false),tu.constant( 2,32)));
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<12>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<12>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
tu.close_scope(); tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,62); vm_base<ARCH>::gen_sync(tu, POST_SYNC,62);
@ -2482,7 +2482,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rd>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)) {
@ -2514,7 +2514,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(imm== 0||rd>=static_cast<uint32_t>(traits:: RFS)) { if(imm== 0||rd>=static_cast<uint32_t>(traits:: RFS)) {
@ -2543,7 +2543,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(nzimm) { if(nzimm) {
@ -2569,7 +2569,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "__reserved_clui"); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "__reserved_clui");
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
@ -2594,7 +2594,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rs1+ 8 + traits::X0,tu.lshr(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(shamt,8))); tu.store(rs1+ 8 + traits::X0,tu.lshr(tu.load(rs1+ 8+ traits::X0, 0),tu.constant(shamt,8)));
@ -2619,7 +2619,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(shamt){ tu.store(rs1+ 8 + traits::X0,tu.lshr((tu.ext(tu.load(rs1+ 8+ traits::X0, 0),32,false)),tu.constant(shamt,8))); if(shamt){ tu.store(rs1+ 8 + traits::X0,tu.lshr((tu.ext(tu.load(rs1+ 8+ traits::X0, 0),32,false)),tu.constant(shamt,8)));
@ -2649,7 +2649,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rs1+ 8 + traits::X0,tu.bitwise_and(tu.load(rs1+ 8+ traits::X0, 0),tu.constant((int8_t)sext<6>(imm),8))); tu.store(rs1+ 8 + traits::X0,tu.bitwise_and(tu.load(rs1+ 8+ traits::X0, 0),tu.constant((int8_t)sext<6>(imm),8)));
@ -2674,7 +2674,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rd+ 8 + traits::X0,tu.sub(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0))); tu.store(rd+ 8 + traits::X0,tu.sub(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0)));
@ -2699,7 +2699,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rd+ 8 + traits::X0,tu.bitwise_xor(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0))); tu.store(rd+ 8 + traits::X0,tu.bitwise_xor(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0)));
@ -2724,7 +2724,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rd+ 8 + traits::X0,tu.bitwise_or(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0))); tu.store(rd+ 8 + traits::X0,tu.bitwise_or(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0)));
@ -2749,7 +2749,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.store(rd+ 8 + traits::X0,tu.bitwise_and(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0))); tu.store(rd+ 8 + traits::X0,tu.bitwise_and(tu.load(rd+ 8+ traits::X0, 0),tu.load(rs2+ 8+ traits::X0, 0)));
@ -2773,12 +2773,12 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<12>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<12>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
tu.close_scope(); tu.close_scope();
vm_base<ARCH>::gen_sync(tu, POST_SYNC,74); vm_base<ARCH>::gen_sync(tu, POST_SYNC,74);
@ -2800,13 +2800,13 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.open_if(tu.icmp(ICmpInst::ICMP_EQ,tu.load(rs1+ 8+ traits::X0, 0),tu.constant( 0,32))); tu.open_if(tu.icmp(ICmpInst::ICMP_EQ,tu.load(rs1+ 8+ traits::X0, 0),tu.constant( 0,32)));
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<9>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<9>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
tu.close_scope(); tu.close_scope();
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
tu.close_scope(); tu.close_scope();
@ -2829,13 +2829,13 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
tu.open_if(tu.icmp(ICmpInst::ICMP_NE,tu.load(rs1+ 8+ traits::X0, 0),tu.constant( 0,32))); tu.open_if(tu.icmp(ICmpInst::ICMP_NE,tu.load(rs1+ 8+ traits::X0, 0),tu.constant( 0,32)));
auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<9>(imm),16)),32); auto PC_val_v = tu.assignment("PC_val", tu.add(tu.ext(cur_pc_val,32,false),tu.constant((int16_t)sext<9>(imm),16)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
tu.close_scope(); tu.close_scope();
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
tu.close_scope(); tu.close_scope();
@ -2858,7 +2858,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs1>=static_cast<uint32_t>(traits:: RFS)) {
@ -2890,7 +2890,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rd>=static_cast<uint32_t>(traits:: RFS)||rd== 0) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rd== 0) {
@ -2921,7 +2921,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rd>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)) {
@ -2952,13 +2952,13 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rs1&&rs1<static_cast<uint32_t>(traits:: RFS)) { if(rs1&&rs1<static_cast<uint32_t>(traits:: RFS)) {
auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(tu.load(rs1%static_cast<uint32_t>(traits:: RFS)+ traits::X0, 0),tu.constant(~ 0x1,8)),32); auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(tu.load(rs1%static_cast<uint32_t>(traits:: RFS)+ traits::X0, 0),tu.constant(~ 0x1,8)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
else{ else{
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
@ -2979,7 +2979,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "__reserved_cmv"); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "__reserved_cmv");
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);
@ -3004,7 +3004,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rd>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)) {
@ -3035,7 +3035,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs1>=static_cast<uint32_t>(traits:: RFS)) {
@ -3046,7 +3046,7 @@ private:
tu.store(1 + traits::X0,tu.add(tu.ext(cur_pc_val,32,false),tu.constant( 2,32))); tu.store(1 + traits::X0,tu.add(tu.ext(cur_pc_val,32,false),tu.constant( 2,32)));
auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(new_pc,tu.constant(~ 0x1,8)),32); auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(new_pc,tu.constant(~ 0x1,8)),32);
tu.store(traits::NEXT_PC, PC_val_v); tu.store(traits::NEXT_PC, PC_val_v);
tu.store(traits::LAST_BRANCH, tu.constant(3U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
auto returnValue = std::make_tuple(BRANCH); auto returnValue = std::make_tuple(BRANCH);
tu.close_scope(); tu.close_scope();
@ -3064,7 +3064,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "cebreak"); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "cebreak");
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
this->gen_raise_trap(tu, 0, 3); this->gen_raise_trap(tu, 0, 3);
@ -3089,7 +3089,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, mnemonic);
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
if(rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)) {
@ -3115,7 +3115,7 @@ private:
tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "dii"); tu("print_disass(core_ptr, {:#x}, \"{}\");", pc.val, "dii");
} }
auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]); auto cur_pc_val = tu.constant(pc.val, traits::reg_bit_widths[traits::PC]);
pc=pc+4; pc=pc+ 2;
gen_set_pc(tu, pc, traits::NEXT_PC); gen_set_pc(tu, pc, traits::NEXT_PC);
tu.open_scope(); tu.open_scope();
this->gen_raise_trap(tu, 0, 2); this->gen_raise_trap(tu, 0, 2);