11 using namespace etiss;
35 cp.
code() = std::string(
"//ECALL\n");
39 cp.
code() +=
"{ // block\n";
41 cp.
code() +=
"} // block\n";
44 cp.
code() +=
"{ // block\n";
46 cp.
code() +=
"{ // procedure\n";
47 cp.
code() +=
"RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 8LL + ((RV32IMACFD*)cpu)->PRIV);\n";
49 cp.
code() +=
"} // procedure\n";
51 cp.
code() +=
"} // block\n";
54 cp.
code() +=
"cpu->instructionPointer = cpu->nextPc;\n";
61 cp.
code() = std::string(
"//ECALL\n");
64 cp.
code() +=
"return cpu->exception;\n";
79 ss <<
"ecall" <<
" # " << ba << (
" []");
105 cp.
code() = std::string(
"//MRET\n");
109 cp.
code() +=
"{ // block\n";
111 cp.
code() +=
"} // block\n";
114 cp.
code() +=
"{ // block\n";
115 cp.
code() +=
"if (((RV32IMACFD*)cpu)->PRIV < 3LL) { // conditional\n";
117 cp.
code() +=
"{ // procedure\n";
118 cp.
code() +=
"RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 2LL);\n";
120 cp.
code() +=
"} // procedure\n";
122 cp.
code() +=
"} // conditional\n";
123 cp.
code() +=
"cpu->nextPc = *((RV32IMACFD*)cpu)->CSR[833LL];\n";
124 cp.
code() +=
"etiss_uint32 s = RV32IMACFD_csr_read(cpu, system, plugin_pointers, 768LL);\n";
125 cp.
code() +=
"etiss_uint32 prev_prv = RV32IMACFD_get_field(s, 6144LL);\n";
126 cp.
code() +=
"if (prev_prv != 3LL) { // conditional\n";
127 cp.
code() +=
"s = RV32IMACFD_set_field(s, 131072LL, 0LL);\n";
128 cp.
code() +=
"} // conditional\n";
129 cp.
code() +=
"s = RV32IMACFD_set_field(s, 8LL, RV32IMACFD_get_field(s, 128LL));\n";
130 cp.
code() +=
"s = RV32IMACFD_set_field(s, 128LL, 1ULL);\n";
131 cp.
code() +=
"s = RV32IMACFD_set_field(s, 6144LL, (RV32IMACFD_extension_enabled(cpu, system, plugin_pointers, 85ULL)) ? (0LL) : (3LL));\n";
132 cp.
code() +=
"RV32IMACFD_csr_write(cpu, system, plugin_pointers, 768LL, s);\n";
133 cp.
code() +=
"((RV32IMACFD*)cpu)->PRIV = (prev_prv) & 0x7;\n";
134 cp.
code() +=
"} // block\n";
137 cp.
code() +=
"cpu->instructionPointer = cpu->nextPc;\n";
144 cp.
code() = std::string(
"//MRET\n");
147 cp.
code() +=
"return cpu->exception;\n";
160 std::stringstream ss;
162 ss <<
"mret" <<
" # " << ba << (
" []");
188 cp.
code() = std::string(
"//WFI\n");
192 cp.
code() +=
"{ // block\n";
194 cp.
code() +=
"} // block\n";
197 cp.
code() +=
"{ // block\n";
198 cp.
code() +=
"} // block\n";
201 cp.
code() +=
"cpu->instructionPointer = cpu->nextPc;\n";
208 cp.
code() = std::string(
"//WFI\n");
211 cp.
code() +=
"return cpu->exception;\n";
224 std::stringstream ss;
226 ss <<
"wfi" <<
" # " << ba << (
" []");
252 cp.
code() = std::string(
"//SRET\n");
256 cp.
code() +=
"{ // block\n";
258 cp.
code() +=
"} // block\n";
261 cp.
code() +=
"{ // block\n";
262 cp.
code() +=
"if (((RV32IMACFD*)cpu)->PRIV < ((RV32IMACFD_get_field(RV32IMACFD_csr_read(cpu, system, plugin_pointers, 768LL), 4194304LL)) ? (3LL) : (1LL))) { // conditional\n";
264 cp.
code() +=
"{ // procedure\n";
265 cp.
code() +=
"RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 2LL);\n";
267 cp.
code() +=
"} // procedure\n";
269 cp.
code() +=
"} // conditional\n";
270 cp.
code() +=
"cpu->nextPc = *((RV32IMACFD*)cpu)->CSR[321LL];\n";
271 cp.
code() +=
"etiss_uint32 s = RV32IMACFD_csr_read(cpu, system, plugin_pointers, 256LL);\n";
272 cp.
code() +=
"etiss_uint32 prev_prv = RV32IMACFD_get_field(s, 256LL);\n";
273 cp.
code() +=
"s = RV32IMACFD_set_field(s, 2LL, RV32IMACFD_get_field(s, 32LL));\n";
274 cp.
code() +=
"s = RV32IMACFD_set_field(s, 32LL, 1ULL);\n";
275 cp.
code() +=
"s = RV32IMACFD_set_field(s, 256LL, 0LL);\n";
276 cp.
code() +=
"RV32IMACFD_csr_write(cpu, system, plugin_pointers, 768LL, s);\n";
277 cp.
code() +=
"((RV32IMACFD*)cpu)->PRIV = (prev_prv) & 0x7;\n";
278 cp.
code() +=
"} // block\n";
281 cp.
code() +=
"cpu->instructionPointer = cpu->nextPc;\n";
288 cp.
code() = std::string(
"//SRET\n");
291 cp.
code() +=
"return cpu->exception;\n";
304 std::stringstream ss;
306 ss <<
"sret" <<
" # " << ba << (
" []");
etiss::instr::InstructionGroup ISA32_RV32IMACFD("ISA32_RV32IMACFD", 32)
static InstructionDefinition wfi_(ISA32_RV32IMACFD, "wfi",(uint32_t) 0x10500073,(uint32_t) 0xffffffff, [](BitArray &ba, etiss::CodeSet &cs, InstructionContext &ic) { { CodePart &cp=cs.append(CodePart::INITIALREQUIRED);cp.code()=std::string("//WFI\n");{ cp.code()+="{ // block\n";cp.code()+="cpu->nextPc = "+std::to_string(ic.current_address_+4)+"ULL;\n";cp.code()+="} // block\n";} { cp.code()+="{ // block\n";cp.code()+="} // block\n";} cp.code()+="instr_exit_"+std::to_string(ic.current_address_)+":\n";cp.code()+="cpu->instructionPointer = cpu->nextPc;\n";cp.getAffectedRegisters().add("instructionPointer", 32);} { CodePart &cp=cs.append(CodePart::APPENDEDRETURNINGREQUIRED);cp.code()=std::string("//WFI\n");cp.code()+="return cpu->exception;\n";} return true;}, 0, [](BitArray &ba, Instruction &instr) { std::stringstream ss;ss<< "wfi"<< " # "<< ba<<(" []");return ss.str();})
static InstructionDefinition ecall_(ISA32_RV32IMACFD, "ecall",(uint32_t) 0x000073,(uint32_t) 0xffffffff, [](BitArray &ba, etiss::CodeSet &cs, InstructionContext &ic) { { CodePart &cp=cs.append(CodePart::INITIALREQUIRED);cp.code()=std::string("//ECALL\n");{ cp.code()+="{ // block\n";cp.code()+="cpu->nextPc = "+std::to_string(ic.current_address_+4)+"ULL;\n";cp.code()+="} // block\n";} { cp.code()+="{ // block\n";{ cp.code()+="{ // procedure\n";cp.code()+="RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 8LL + ((RV32IMACFD*)cpu)->PRIV);\n";cp.code()+="goto instr_exit_"+std::to_string(ic.current_address_)+";\n";cp.code()+="} // procedure\n";} cp.code()+="} // block\n";} cp.code()+="instr_exit_"+std::to_string(ic.current_address_)+":\n";cp.code()+="cpu->instructionPointer = cpu->nextPc;\n";cp.getAffectedRegisters().add("instructionPointer", 32);} { CodePart &cp=cs.append(CodePart::APPENDEDRETURNINGREQUIRED);cp.code()=std::string("//ECALL\n");cp.code()+="return cpu->exception;\n";} return true;}, 0, [](BitArray &ba, Instruction &instr) { std::stringstream ss;ss<< "ecall"<< " # "<< ba<<(" []");return ss.str();})
static InstructionDefinition mret_(ISA32_RV32IMACFD, "mret",(uint32_t) 0x30200073,(uint32_t) 0xffffffff, [](BitArray &ba, etiss::CodeSet &cs, InstructionContext &ic) { { CodePart &cp=cs.append(CodePart::INITIALREQUIRED);cp.code()=std::string("//MRET\n");{ cp.code()+="{ // block\n";cp.code()+="cpu->nextPc = "+std::to_string(ic.current_address_+4)+"ULL;\n";cp.code()+="} // block\n";} { cp.code()+="{ // block\n";cp.code()+="if (((RV32IMACFD*)cpu)->PRIV < 3LL) { // conditional\n";{ cp.code()+="{ // procedure\n";cp.code()+="RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 2LL);\n";cp.code()+="goto instr_exit_"+std::to_string(ic.current_address_)+";\n";cp.code()+="} // procedure\n";} cp.code()+="} // conditional\n";cp.code()+="cpu->nextPc = *((RV32IMACFD*)cpu)->CSR[833LL];\n";cp.code()+="etiss_uint32 s = RV32IMACFD_csr_read(cpu, system, plugin_pointers, 768LL);\n";cp.code()+="etiss_uint32 prev_prv = RV32IMACFD_get_field(s, 6144LL);\n";cp.code()+="if (prev_prv != 3LL) { // conditional\n";cp.code()+="s = RV32IMACFD_set_field(s, 131072LL, 0LL);\n";cp.code()+="} // conditional\n";cp.code()+="s = RV32IMACFD_set_field(s, 8LL, RV32IMACFD_get_field(s, 128LL));\n";cp.code()+="s = RV32IMACFD_set_field(s, 128LL, 1ULL);\n";cp.code()+="s = RV32IMACFD_set_field(s, 6144LL, (RV32IMACFD_extension_enabled(cpu, system, plugin_pointers, 85ULL)) ? (0LL) : (3LL));\n";cp.code()+="RV32IMACFD_csr_write(cpu, system, plugin_pointers, 768LL, s);\n";cp.code()+="((RV32IMACFD*)cpu)->PRIV = (prev_prv) & 0x7;\n";cp.code()+="} // block\n";} cp.code()+="instr_exit_"+std::to_string(ic.current_address_)+":\n";cp.code()+="cpu->instructionPointer = cpu->nextPc;\n";cp.getAffectedRegisters().add("instructionPointer", 32);} { CodePart &cp=cs.append(CodePart::APPENDEDRETURNINGREQUIRED);cp.code()=std::string("//MRET\n");cp.code()+="return cpu->exception;\n";} return true;}, 0, [](BitArray &ba, Instruction &instr) { std::stringstream ss;ss<< "mret"<< " # "<< ba<<(" []");return ss.str();})
static InstructionDefinition sret_(ISA32_RV32IMACFD, "sret",(uint32_t) 0x10200073,(uint32_t) 0xffffffff, [](BitArray &ba, etiss::CodeSet &cs, InstructionContext &ic) { { CodePart &cp=cs.append(CodePart::INITIALREQUIRED);cp.code()=std::string("//SRET\n");{ cp.code()+="{ // block\n";cp.code()+="cpu->nextPc = "+std::to_string(ic.current_address_+4)+"ULL;\n";cp.code()+="} // block\n";} { cp.code()+="{ // block\n";cp.code()+="if (((RV32IMACFD*)cpu)->PRIV < ((RV32IMACFD_get_field(RV32IMACFD_csr_read(cpu, system, plugin_pointers, 768LL), 4194304LL)) ? (3LL) : (1LL))) { // conditional\n";{ cp.code()+="{ // procedure\n";cp.code()+="RV32IMACFD_raise(cpu, system, plugin_pointers, 0LL, 2LL);\n";cp.code()+="goto instr_exit_"+std::to_string(ic.current_address_)+";\n";cp.code()+="} // procedure\n";} cp.code()+="} // conditional\n";cp.code()+="cpu->nextPc = *((RV32IMACFD*)cpu)->CSR[321LL];\n";cp.code()+="etiss_uint32 s = RV32IMACFD_csr_read(cpu, system, plugin_pointers, 256LL);\n";cp.code()+="etiss_uint32 prev_prv = RV32IMACFD_get_field(s, 256LL);\n";cp.code()+="s = RV32IMACFD_set_field(s, 2LL, RV32IMACFD_get_field(s, 32LL));\n";cp.code()+="s = RV32IMACFD_set_field(s, 32LL, 1ULL);\n";cp.code()+="s = RV32IMACFD_set_field(s, 256LL, 0LL);\n";cp.code()+="RV32IMACFD_csr_write(cpu, system, plugin_pointers, 768LL, s);\n";cp.code()+="((RV32IMACFD*)cpu)->PRIV = (prev_prv) & 0x7;\n";cp.code()+="} // block\n";} cp.code()+="instr_exit_"+std::to_string(ic.current_address_)+":\n";cp.code()+="cpu->instructionPointer = cpu->nextPc;\n";cp.getAffectedRegisters().add("instructionPointer", 32);} { CodePart &cp=cs.append(CodePart::APPENDEDRETURNINGREQUIRED);cp.code()=std::string("//SRET\n");cp.code()+="return cpu->exception;\n";} return true;}, 0, [](BitArray &ba, Instruction &instr) { std::stringstream ss;ss<< "sret"<< " # "<< ba<<(" []");return ss.str();})
static __inline__ uint32_t
Contains a small code snipped.
@ APPENDEDRETURNINGREQUIRED
RegisterSet & getAffectedRegisters()
void append(const CodePart &part, CodePart::TYPE type)
void add(const RegisterPart &rp)
add a registerPart to the set or just its relevant bits if a register with the same name is already p...
this class contains parameters that persist in between instruction lookpus/translation within a trans...
uint64_t current_address_
start address of current instruction
holds information and translation callbacks for an instruction.
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.