Compare commits

..

No commits in common. "149b3136d26ef0edbb810b24977c274079d35363" and "63da7f8d57fab339530e2ac4c808ff71ff3c4941" have entirely different histories.

7 changed files with 945 additions and 932 deletions

View File

@ -79,15 +79,10 @@ public:
} }
protected: protected:
using super::mov;
using super::cmp;
using super::get_ptr_for; using super::get_ptr_for;
using super::get_reg; using super::get_reg;
using super::get_reg_Gp;
using super::get_reg_for; using super::get_reg_for;
using super::get_reg_for_Gp;
using super::load_reg_from_mem; using super::load_reg_from_mem;
using super::load_reg_from_mem_Gp;
using super::write_reg_to_mem; using super::write_reg_to_mem;
using super::gen_ext; using super::gen_ext;
using super::gen_read_mem; using super::gen_read_mem;
@ -95,7 +90,6 @@ protected:
using super::gen_wait; using super::gen_wait;
using super::gen_leave; using super::gen_leave;
using super::gen_operation; using super::gen_operation;
using super::gen_sync;
using this_class = vm_impl<ARCH>; using this_class = vm_impl<ARCH>;
using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&); using compile_func = continuation_e (this_class::*)(virt_addr_t&, code_word_t, jit_holder&);
@ -161,10 +155,10 @@ private:
} }
x86::Compiler& cc = jh.cc; x86::Compiler& cc = jh.cc;
cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str()); cc.comment(fmt::format("${instr.name}_{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, ${idx}); this->gen_sync(jh, PRE_SYNC, ${idx});
mov(cc, jh.pc, pc.val); cc.mov(jh.pc, pc.val);
pc = pc+${instr.length/8}; pc = pc+${instr.length/8};
mov(cc, jh.next_pc, pc.val); cc.mov(jh.next_pc, pc.val);
gen_instr_prologue(jh); gen_instr_prologue(jh);
cc.comment("//behavior:"); cc.comment("//behavior:");
@ -172,7 +166,7 @@ private:
<%instr.behavior.eachLine{%>${it} <%instr.behavior.eachLine{%>${it}
<%}%> <%}%>
gen_instr_epilogue(jh); gen_instr_epilogue(jh);
gen_sync(jh, POST_SYNC, ${idx}); this->gen_sync(jh, POST_SYNC, ${idx});
return returnValue; return returnValue;
} }
<%}%> <%}%>
@ -182,12 +176,12 @@ private:
continuation_e illegal_intruction(virt_addr_t &pc, code_word_t instr, jit_holder& jh ) { continuation_e illegal_intruction(virt_addr_t &pc, code_word_t instr, jit_holder& jh ) {
x86::Compiler& cc = jh.cc; x86::Compiler& cc = jh.cc;
cc.comment(fmt::format("illegal_intruction{:#x}:",pc.val).c_str()); cc.comment(fmt::format("illegal_intruction{:#x}:",pc.val).c_str());
gen_sync(jh, PRE_SYNC, instr_descr.size()); this->gen_sync(jh, PRE_SYNC, instr_descr.size());
pc = pc + ((instr & 3) == 3 ? 4 : 2); pc = pc + ((instr & 3) == 3 ? 4 : 2);
gen_instr_prologue(jh); gen_instr_prologue(jh);
cc.comment("//behavior:"); cc.comment("//behavior:");
gen_instr_epilogue(jh); gen_instr_epilogue(jh);
gen_sync(jh, POST_SYNC, instr_descr.size()); this->gen_sync(jh, POST_SYNC, instr_descr.size());
return BRANCH; return BRANCH;
} }
@ -283,9 +277,9 @@ void vm_impl<ARCH>::gen_instr_prologue(jit_holder& jh) {
cc.comment("//gen_instr_prologue"); cc.comment("//gen_instr_prologue");
cc.inc(get_ptr_for(jh, traits::ICOUNT)); cc.inc(get_ptr_for(jh, traits::ICOUNT));
x86_reg_t current_trap_state = get_reg_for(cc, traits::TRAP_STATE); x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
mov(cc, get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state); cc.mov(get_ptr_for(jh, traits::PENDING_TRAP), current_trap_state);
} }
template <typename ARCH> template <typename ARCH>
@ -293,16 +287,16 @@ void vm_impl<ARCH>::gen_instr_epilogue(jit_holder& jh) {
auto& cc = jh.cc; auto& cc = jh.cc;
cc.comment("//gen_instr_epilogue"); cc.comment("//gen_instr_epilogue");
x86_reg_t current_trap_state = get_reg_for(cc, traits::TRAP_STATE); x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
cmp(cc, current_trap_state, 0); cc.cmp(current_trap_state, 0);
cc.jne(jh.trap_entry); cc.jne(jh.trap_entry);
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_prologue(jit_holder& jh){
jh.pc = load_reg_from_mem_Gp(jh, traits::PC); jh.pc = load_reg_from_mem(jh, traits::PC);
jh.next_pc = load_reg_from_mem_Gp(jh, traits::NEXT_PC); jh.next_pc = load_reg_from_mem(jh, traits::NEXT_PC);
} }
template <typename ARCH> template <typename ARCH>
void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
@ -314,14 +308,14 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
this->write_back(jh); this->write_back(jh);
this->gen_sync(jh, POST_SYNC, -1); this->gen_sync(jh, POST_SYNC, -1);
x86::Gp current_trap_state = get_reg_for_Gp(cc, traits::TRAP_STATE); x86::Gp current_trap_state = get_reg_for(jh, traits::TRAP_STATE);
mov(cc, current_trap_state, get_ptr_for(jh, traits::TRAP_STATE)); cc.mov(current_trap_state, get_ptr_for(jh, traits::TRAP_STATE));
x86::Gp current_pc = get_reg_for_Gp(cc, traits::PC); x86::Gp current_pc = get_reg_for(jh, traits::PC);
mov(cc, current_pc, get_ptr_for(jh, traits::PC)); cc.mov(current_pc, get_ptr_for(jh, traits::PC));
x86::Gp instr = cc.newInt32("instr"); x86::Gp instr = cc.newInt32("instr");
mov(cc, instr, 0); // FIXME:this is not correct, should be instrId of trapping instr cc.mov(instr, 0); // FIXME:this is not correct
cc.comment("//enter trap call;"); cc.comment("//enter trap call;");
InvokeNode* call_enter_trap; InvokeNode* call_enter_trap;
cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>()); cc.invoke(&call_enter_trap, &enter_trap, FuncSignature::build<uint64_t, void*, uint64_t, uint64_t, uint64_t>());
@ -330,21 +324,21 @@ void vm_impl<ARCH>::gen_block_epilogue(jit_holder& jh){
call_enter_trap->setArg(2, current_pc); call_enter_trap->setArg(2, current_pc);
call_enter_trap->setArg(3, instr); call_enter_trap->setArg(3, instr);
x86_reg_t current_next_pc = get_reg_for(cc, traits::NEXT_PC); x86::Gp current_next_pc = get_reg_for(jh, traits::NEXT_PC);
mov(cc, current_next_pc, get_ptr_for(jh, traits::NEXT_PC)); cc.mov(current_next_pc, get_ptr_for(jh, traits::NEXT_PC));
mov(cc, jh.next_pc, current_next_pc); cc.mov(jh.next_pc, current_next_pc);
mov(cc, get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits<uint32_t>::max()); cc.mov(get_ptr_for(jh, traits::LAST_BRANCH), std::numeric_limits<uint32_t>::max());
cc.ret(jh.next_pc); cc.ret(jh.next_pc);
} }
template <typename ARCH> template <typename ARCH>
inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t cause) { inline void vm_impl<ARCH>::gen_raise(jit_holder& jh, uint16_t trap_id, uint16_t cause) {
auto& cc = jh.cc; auto& cc = jh.cc;
cc.comment("//gen_raise"); cc.comment("//gen_raise");
auto tmp1 = get_reg_for(cc, traits::TRAP_STATE); auto tmp1 = get_reg_for(jh, traits::TRAP_STATE);
mov(cc, tmp1, 0x80ULL << 24 | (cause << 16) | trap_id); cc.mov(tmp1, 0x80ULL << 24 | (cause << 16) | trap_id);
mov(cc, get_ptr_for(jh, traits::TRAP_STATE), tmp1); cc.mov(get_ptr_for(jh, traits::TRAP_STATE), tmp1);
mov(cc, jh.next_pc, std::numeric_limits<uint32_t>::max()); cc.mov(jh.next_pc, std::numeric_limits<uint32_t>::max());
} }
} // namespace tgc5c } // namespace tgc5c

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017-2024 MINRES Technologies GmbH * Copyright (C) 20217-2024 MINRES Technologies GmbH
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017-2024 MINRES Technologies GmbH * Copyright (C) 20217-2024 MINRES Technologies GmbH
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -2534,8 +2534,7 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
// execute instruction // execute instruction
{ {
if(rs1 && rs1 < traits::RFS) { if(rs1 && rs1 < traits::RFS) {
uint32_t addr_mask = (uint32_t)- 2; *NEXT_PC = *(X+(uint32_t)(rs1 ) % traits::RFS) & (uint32_t)(~ 1 );
*NEXT_PC = *(X+(uint32_t)(rs1 ) % traits::RFS) & addr_mask;
this->core.reg.last_branch = 1; this->core.reg.last_branch = 1;
} }
else { else {
@ -2601,10 +2600,9 @@ typename vm_base<ARCH>::virt_addr_t vm_impl<ARCH>::execute_inst(finish_cond_e co
raise(0, traits::RV_CAUSE_ILLEGAL_INSTRUCTION); raise(0, traits::RV_CAUSE_ILLEGAL_INSTRUCTION);
} }
else { else {
uint32_t addr_mask = (uint32_t)- 2;
uint32_t new_pc = *(X+rs1); uint32_t new_pc = *(X+rs1);
*(X+1) = (uint32_t)((uint64_t)(*PC ) + (uint64_t)(2 )); *(X+1) = (uint32_t)((uint64_t)(*PC ) + (uint64_t)(2 ));
*NEXT_PC = new_pc & addr_mask; *NEXT_PC = new_pc & (uint32_t)(~ 1 );
this->core.reg.last_branch = 1; this->core.reg.last_branch = 1;
} }
} }

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2017-2024 MINRES Technologies GmbH * Copyright (C) 2017, 2018 MINRES Technologies GmbH
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -352,7 +352,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -395,7 +395,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -438,7 +438,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ this->gen_raise_trap(0, 0); if(imm%static_cast<uint32_t>(traits::INSTR_ALIGNMENT)){ this->gen_raise_trap(0, 0);
@ -489,7 +489,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto addr_mask =this->gen_const(32,(uint32_t)- 2); auto addr_mask =this->gen_const(32,(uint32_t)- 2);
@ -563,7 +563,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -620,7 +620,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -677,7 +677,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -738,7 +738,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -799,7 +799,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -856,7 +856,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -913,7 +913,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto load_address =this->gen_ext( auto load_address =this->gen_ext(
@ -968,7 +968,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto load_address =this->gen_ext( auto load_address =this->gen_ext(
@ -1023,7 +1023,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto load_address =this->gen_ext( auto load_address =this->gen_ext(
@ -1078,7 +1078,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto load_address =this->gen_ext( auto load_address =this->gen_ext(
@ -1131,7 +1131,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto load_address =this->gen_ext( auto load_address =this->gen_ext(
@ -1184,7 +1184,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto store_address =this->gen_ext( auto store_address =this->gen_ext(
@ -1234,7 +1234,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto store_address =this->gen_ext( auto store_address =this->gen_ext(
@ -1284,7 +1284,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto store_address =this->gen_ext( auto store_address =this->gen_ext(
@ -1334,7 +1334,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1383,7 +1383,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1434,7 +1434,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1484,7 +1484,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1531,7 +1531,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1578,7 +1578,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1625,7 +1625,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1672,7 +1672,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1719,7 +1719,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1729,7 +1729,8 @@ private:
this->gen_ext( this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true), this->gen_reg_load(rs1+ traits::X0, 0), 32,true),
this->gen_ext(this->gen_const(8,shamt), 32,false)) this->gen_ext(this->gen_const(8,shamt), 32,false))
), 32,false), ),
32, true),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -1768,7 +1769,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1817,7 +1818,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1866,7 +1867,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1916,7 +1917,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1968,7 +1969,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2018,7 +2019,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2065,7 +2066,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2115,7 +2116,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2168,7 +2169,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2215,7 +2216,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2397,7 +2398,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrs1 =this->gen_reg_load(rs1+ traits::X0, 0); auto xrs1 =this->gen_reg_load(rs1+ traits::X0, 0);
@ -2450,7 +2451,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrd =this->gen_read_mem(traits::CSR, csr, 4); auto xrd =this->gen_read_mem(traits::CSR, csr, 4);
@ -2504,7 +2505,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrd =this->gen_read_mem(traits::CSR, csr, 4); auto xrd =this->gen_read_mem(traits::CSR, csr, 4);
@ -2558,7 +2559,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrd =this->gen_read_mem(traits::CSR, csr, 4); auto xrd =this->gen_read_mem(traits::CSR, csr, 4);
@ -2606,7 +2607,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrd =this->gen_read_mem(traits::CSR, csr, 4); auto xrd =this->gen_read_mem(traits::CSR, csr, 4);
@ -2659,7 +2660,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto xrd =this->gen_read_mem(traits::CSR, csr, 4); auto xrd =this->gen_read_mem(traits::CSR, csr, 4);
@ -2749,15 +2750,21 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto res =this->builder.CreateMul( auto res =this->gen_ext(
this->gen_ext(this->gen_ext( (this->builder.CreateMul(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true), 64,true), this->gen_ext(this->gen_ext(
this->gen_ext(this->gen_ext( this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true), 64,true)) this->gen_reg_load(rs1+ traits::X0, 0), 32,true),
; 64, true), 128,true),
this->gen_ext(this->gen_ext(
this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true),
64, true), 128,true))
),
64, true);
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
this->gen_ext( this->gen_ext(
@ -2801,15 +2808,21 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto res =this->builder.CreateMul( auto res =this->gen_ext(
this->gen_ext(this->gen_ext( (this->builder.CreateMul(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true), 64,true), this->gen_ext(this->gen_ext(
this->gen_ext(this->gen_ext( this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true), 64,true)) this->gen_reg_load(rs1+ traits::X0, 0), 32,true),
; 64, true), 128,true),
this->gen_ext(this->gen_ext(
this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true),
64, true), 128,true))
),
64, true);
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
this->gen_ext( this->gen_ext(
@ -2856,14 +2869,20 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto res =this->builder.CreateMul( auto res =this->gen_ext(
this->gen_ext(this->gen_ext( (this->builder.CreateMul(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true), 64,true), this->gen_ext(this->gen_ext(
this->gen_ext(this->gen_reg_load(rs2+ traits::X0, 0), 64,false)) this->gen_ext(
; this->gen_reg_load(rs1+ traits::X0, 0), 32,true),
64, true), 128,true),
this->gen_ext(this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0),
64, false), 128,false))
),
64, true);
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
this->gen_ext( this->gen_ext(
@ -2910,13 +2929,19 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto res =this->builder.CreateMul( auto res =this->gen_ext(
this->gen_ext(this->gen_reg_load(rs1+ traits::X0, 0), 64,false), (this->builder.CreateMul(
this->gen_ext(this->gen_reg_load(rs2+ traits::X0, 0), 64,false)) this->gen_ext(this->gen_ext(
; this->gen_reg_load(rs1+ traits::X0, 0),
64, false), 128,false),
this->gen_ext(this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0),
64, false), 128,false))
),
64, false);
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
this->gen_ext( this->gen_ext(
@ -2963,13 +2988,15 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto dividend =this->gen_ext( auto dividend =this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true); this->gen_reg_load(rs1+ traits::X0, 0),
32, false);
auto divisor =this->gen_ext( auto divisor =this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true); this->gen_reg_load(rs2+ traits::X0, 0),
32, false);
if(rd!=0){ auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); if(rd!=0){ auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge); auto bb_then = BasicBlock::Create(this->mod->getContext(), "bb_then", this->func, bb_merge);
auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge); auto bb_else = BasicBlock::Create(this->mod->getContext(), "bb_else", this->func, bb_merge);
@ -3060,7 +3087,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -3074,10 +3101,12 @@ private:
{ {
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
this->builder.CreateUDiv( this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0), (this->builder.CreateUDiv(
this->gen_reg_load(rs2+ traits::X0, 0)) this->gen_reg_load(rs1+ traits::X0, 0),
, this->gen_reg_load(rs2+ traits::X0, 0))
),
32, false),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -3128,7 +3157,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -3172,10 +3201,13 @@ private:
this->gen_ext( this->gen_ext(
(this->builder.CreateSRem( (this->builder.CreateSRem(
this->gen_ext( this->gen_ext(
this->gen_reg_load(rs1+ traits::X0, 0), 32,true), this->gen_reg_load(rs1+ traits::X0, 0),
32, false),
this->gen_ext( this->gen_ext(
this->gen_reg_load(rs2+ traits::X0, 0), 32,true)) this->gen_reg_load(rs2+ traits::X0, 0),
), 32,false), 32, false))
),
32, true),
get_reg_ptr(rd + traits::X0), false); get_reg_ptr(rd + traits::X0), false);
} }
} }
@ -3229,7 +3261,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)||rs1>=static_cast<uint32_t>(traits::RFS)||rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk); auto bb_merge = BasicBlock::Create(this->mod->getContext(), "bb_merge", this->func, this->leave_blk);
@ -3306,7 +3338,7 @@ private:
get_reg_ptr(rd+8 + traits::X0), false); get_reg_ptr(rd+8 + traits::X0), false);
} }
else{ else{
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
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);
@ -3434,7 +3466,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rs1!=0) { if(rs1!=0) {
@ -3544,7 +3576,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -3587,7 +3619,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(imm==0||rd>=static_cast<uint32_t>(traits::RFS)) { if(imm==0||rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
if(rd!=0) { if(rd!=0) {
this->builder.CreateStore( this->builder.CreateStore(
@ -3637,7 +3669,7 @@ private:
get_reg_ptr(2 + traits::X0), false); get_reg_ptr(2 + traits::X0), false);
} }
else{ else{
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
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);
@ -3663,7 +3695,7 @@ private:
this->gen_set_pc(pc, traits::NEXT_PC); this->gen_set_pc(pc, traits::NEXT_PC);
/*generate behavior*/ /*generate behavior*/
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
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);
@ -4122,7 +4154,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rs1!=0) { if(rs1!=0) {
@ -4168,7 +4200,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)||rd==0) { if(rd>=static_cast<uint32_t>(traits::RFS)||rd==0) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto offs =this->gen_ext( auto offs =this->gen_ext(
@ -4219,7 +4251,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -4260,10 +4292,9 @@ private:
this->gen_set_pc(pc, traits::NEXT_PC); this->gen_set_pc(pc, traits::NEXT_PC);
/*generate behavior*/ /*generate behavior*/
if(rs1&&rs1<static_cast<uint32_t>(traits::RFS)){ auto addr_mask =this->gen_const(32,(uint32_t)- 2); if(rs1&&rs1<static_cast<uint32_t>(traits::RFS)){ auto PC_val_v = this->builder.CreateAnd(
auto PC_val_v = this->builder.CreateAnd(
this->gen_reg_load(rs1%static_cast<uint32_t>(traits::RFS)+ traits::X0, 0), this->gen_reg_load(rs1%static_cast<uint32_t>(traits::RFS)+ traits::X0, 0),
addr_mask) this->gen_const(32,~ 1))
; ;
this->builder.CreateStore(PC_val_v, get_reg_ptr(traits::NEXT_PC), false); this->builder.CreateStore(PC_val_v, get_reg_ptr(traits::NEXT_PC), false);
this->builder.CreateStore(this->gen_const(32,2U), get_reg_ptr(traits::LAST_BRANCH), false); this->builder.CreateStore(this->gen_const(32,2U), get_reg_ptr(traits::LAST_BRANCH), false);
@ -4329,7 +4360,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rd>=static_cast<uint32_t>(traits::RFS)) { if(rd>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -4376,17 +4407,16 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs1>=static_cast<uint32_t>(traits::RFS)) { if(rs1>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto addr_mask =this->gen_const(32,(uint32_t)- 2);
auto new_pc =this->gen_reg_load(rs1+ traits::X0, 0); auto new_pc =this->gen_reg_load(rs1+ traits::X0, 0);
this->builder.CreateStore( this->builder.CreateStore(
this->gen_const(32,(uint32_t)(PC+2)), this->gen_const(32,(uint32_t)(PC+2)),
get_reg_ptr(1 + traits::X0), false); get_reg_ptr(1 + traits::X0), false);
auto PC_val_v = this->builder.CreateAnd( auto PC_val_v = this->builder.CreateAnd(
new_pc, new_pc,
addr_mask) this->gen_const(32,~ 1))
; ;
this->builder.CreateStore(PC_val_v, get_reg_ptr(traits::NEXT_PC), false); this->builder.CreateStore(PC_val_v, get_reg_ptr(traits::NEXT_PC), false);
this->builder.CreateStore(this->gen_const(32,2U), get_reg_ptr(traits::LAST_BRANCH), false); this->builder.CreateStore(this->gen_const(32,2U), get_reg_ptr(traits::LAST_BRANCH), false);
@ -4449,7 +4479,7 @@ private:
/*generate behavior*/ /*generate behavior*/
if(rs2>=static_cast<uint32_t>(traits::RFS)) { if(rs2>=static_cast<uint32_t>(traits::RFS)) {
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
} }
else{ else{
auto offs =this->gen_ext( auto offs =this->gen_ext(
@ -4487,7 +4517,7 @@ private:
this->gen_set_pc(pc, traits::NEXT_PC); this->gen_set_pc(pc, traits::NEXT_PC);
/*generate behavior*/ /*generate behavior*/
this->gen_raise_trap(0, static_cast<int32_t>(traits::RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(0, 2);
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);

View File

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (C) 2020-2024 MINRES Technologies GmbH * Copyright (C) 2020 MINRES Technologies GmbH
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -346,7 +346,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -381,7 +381,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -416,7 +416,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(imm%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_raise_trap(tu, 0, 0); if(imm%static_cast<uint32_t>(traits:: INSTR_ALIGNMENT)){ this->gen_raise_trap(tu, 0, 0);
@ -459,7 +459,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32); auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32);
@ -510,7 +510,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_EQ, tu.open_if(tu.icmp(ICmpInst::ICMP_EQ,
@ -553,7 +553,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
@ -596,7 +596,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_SLT, tu.open_if(tu.icmp(ICmpInst::ICMP_SLT,
@ -639,7 +639,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_SGE, tu.open_if(tu.icmp(ICmpInst::ICMP_SGE,
@ -682,7 +682,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_ULT, tu.open_if(tu.icmp(ICmpInst::ICMP_ULT,
@ -725,7 +725,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_UGE, tu.open_if(tu.icmp(ICmpInst::ICMP_UGE,
@ -768,7 +768,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto load_address = tu.assignment(tu.ext((tu.add( auto load_address = tu.assignment(tu.ext((tu.add(
@ -808,7 +808,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto load_address = tu.assignment(tu.ext((tu.add( auto load_address = tu.assignment(tu.ext((tu.add(
@ -848,7 +848,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto load_address = tu.assignment(tu.ext((tu.add( auto load_address = tu.assignment(tu.ext((tu.add(
@ -888,7 +888,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto load_address = tu.assignment(tu.ext((tu.add( auto load_address = tu.assignment(tu.ext((tu.add(
@ -928,7 +928,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto load_address = tu.assignment(tu.ext((tu.add( auto load_address = tu.assignment(tu.ext((tu.add(
@ -968,7 +968,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto store_address = tu.assignment(tu.ext((tu.add( auto store_address = tu.assignment(tu.ext((tu.add(
@ -1004,7 +1004,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto store_address = tu.assignment(tu.ext((tu.add( auto store_address = tu.assignment(tu.ext((tu.add(
@ -1040,7 +1040,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rs2>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto store_address = tu.assignment(tu.ext((tu.add( auto store_address = tu.assignment(tu.ext((tu.add(
@ -1076,7 +1076,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1114,7 +1114,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1152,7 +1152,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1190,7 +1190,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1228,7 +1228,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1266,7 +1266,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1304,7 +1304,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1342,7 +1342,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1380,7 +1380,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1418,7 +1418,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1456,7 +1456,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1494,7 +1494,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1534,7 +1534,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1572,7 +1572,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1610,7 +1610,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1648,7 +1648,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1688,7 +1688,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1728,7 +1728,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1766,7 +1766,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -1922,7 +1922,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32); auto xrs1 = tu.assignment(tu.load(rs1+ traits::X0, 0),32);
@ -1963,7 +1963,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
@ -2006,7 +2006,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
@ -2049,7 +2049,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
@ -2087,7 +2087,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
@ -2129,7 +2129,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32); auto xrd = tu.assignment(tu.read_mem(traits::CSR, csr, 32),32);
@ -2199,12 +2199,12 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto res = tu.assignment(tu.mul( auto res = tu.assignment(tu.ext((tu.mul(
tu.ext(tu.load(rs1+ traits::X0, 0),32,true), tu.ext(tu.ext(tu.load(rs1+ traits::X0, 0),32,true),64,true),
tu.ext(tu.load(rs2+ traits::X0, 0),32,true)),64); tu.ext(tu.ext(tu.load(rs2+ traits::X0, 0),32,true),64,true))),64,true),64);
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
tu.ext(res,32,false)); tu.ext(res,32,false));
@ -2238,12 +2238,12 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto res = tu.assignment(tu.mul( auto res = tu.assignment(tu.ext((tu.mul(
tu.ext(tu.load(rs1+ traits::X0, 0),32,true), tu.ext(tu.ext(tu.load(rs1+ traits::X0, 0),32,true),64,true),
tu.ext(tu.load(rs2+ traits::X0, 0),32,true)),64); tu.ext(tu.ext(tu.load(rs2+ traits::X0, 0),32,true),64,true))),64,true),64);
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
tu.ext((tu.ashr( tu.ext((tu.ashr(
@ -2279,12 +2279,12 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto res = tu.assignment(tu.mul( auto res = tu.assignment(tu.ext((tu.mul(
tu.ext(tu.load(rs1+ traits::X0, 0),32,true), tu.ext(tu.ext(tu.load(rs1+ traits::X0, 0),32,true),64,true),
tu.load(rs2+ traits::X0, 0)),64); tu.ext(tu.load(rs2+ traits::X0, 0),64,false))),64,true),64);
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
tu.ext((tu.ashr( tu.ext((tu.ashr(
@ -2320,12 +2320,12 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto res = tu.assignment(tu.mul( auto res = tu.assignment(tu.ext((tu.mul(
tu.load(rs1+ traits::X0, 0), tu.ext(tu.load(rs1+ traits::X0, 0),64,false),
tu.load(rs2+ traits::X0, 0)),64); tu.ext(tu.load(rs2+ traits::X0, 0),64,false))),64,false),64);
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
tu.ext((tu.lshr( tu.ext((tu.lshr(
@ -2361,7 +2361,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto dividend = tu.assignment(tu.ext(tu.load(rs1+ traits::X0, 0),32,true),32); auto dividend = tu.assignment(tu.ext(tu.load(rs1+ traits::X0, 0),32,true),32);
@ -2419,7 +2419,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
@ -2427,9 +2427,9 @@ private:
tu.constant(0,8))); tu.constant(0,8)));
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
tu.udiv( tu.ext((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))),32,false));
} }
tu.open_else(); tu.open_else();
if(rd!=0) { if(rd!=0) {
@ -2466,7 +2466,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
@ -2527,7 +2527,7 @@ private:
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)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) { if(rd>=static_cast<uint32_t>(traits:: RFS)||rs1>=static_cast<uint32_t>(traits:: RFS)||rs2>=static_cast<uint32_t>(traits:: RFS)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
tu.open_if(tu.icmp(ICmpInst::ICMP_NE, tu.open_if(tu.icmp(ICmpInst::ICMP_NE,
@ -2579,7 +2579,7 @@ private:
tu.constant(imm,16))),32,false)); tu.constant(imm,16))),32,false));
} }
else{ else{
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -2671,7 +2671,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rs1!=0) { if(rs1!=0) {
@ -2760,7 +2760,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -2795,7 +2795,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
if(rd!=0) { if(rd!=0) {
tu.store(rd + traits::X0, tu.store(rd + traits::X0,
@ -2833,7 +2833,7 @@ private:
tu.constant((int16_t)sext<10>(nzimm),16))),32,false)); tu.constant((int16_t)sext<10>(nzimm),16))),32,false));
} }
else{ else{
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
@ -2857,7 +2857,7 @@ private:
pc=pc+ 2; 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, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
tu.close_scope(); tu.close_scope();
@ -3197,7 +3197,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rs1!=0) { if(rs1!=0) {
@ -3234,7 +3234,7 @@ private:
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) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto offs = tu.assignment(tu.ext((tu.add( auto offs = tu.assignment(tu.ext((tu.add(
@ -3270,7 +3270,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -3303,10 +3303,9 @@ private:
pc=pc+ 2; 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)){ auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32); if(rs1&&rs1<static_cast<uint32_t>(traits:: RFS)){ auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(
auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(
tu.load(rs1%static_cast<uint32_t>(traits:: RFS)+ traits::X0, 0), tu.load(rs1%static_cast<uint32_t>(traits:: RFS)+ traits::X0, 0),
addr_mask),32); tu.constant(~ 1,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(2U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
@ -3362,7 +3361,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
if(rd!=0) { if(rd!=0) {
@ -3398,16 +3397,15 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto addr_mask = tu.assignment(tu.constant((uint32_t)- 2,32),32);
auto new_pc = tu.assignment(tu.load(rs1+ traits::X0, 0),32); auto new_pc = tu.assignment(tu.load(rs1+ traits::X0, 0),32);
tu.store(1 + traits::X0, tu.store(1 + traits::X0,
tu.constant((uint32_t)(PC+2),32)); tu.constant((uint32_t)(PC+2),32));
auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and( auto PC_val_v = tu.assignment("PC_val", tu.bitwise_and(
new_pc, new_pc,
addr_mask),32); tu.constant(~ 1,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(2U, 2)); tu.store(traits::LAST_BRANCH, tu.constant(2U, 2));
} }
@ -3460,7 +3458,7 @@ private:
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)) {
this->gen_raise_trap(tu, 0, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
} }
else{ else{
auto offs = tu.assignment(tu.ext((tu.add( auto offs = tu.assignment(tu.ext((tu.add(
@ -3489,7 +3487,7 @@ private:
pc=pc+ 2; 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, static_cast<int32_t>(traits:: RV_CAUSE_ILLEGAL_INSTRUCTION)); this->gen_raise_trap(tu, 0, 2);
auto returnValue = std::make_tuple(CONT); auto returnValue = std::make_tuple(CONT);
tu.close_scope(); tu.close_scope();