added likely, unlikely attributes to switch case, could boost perfomance

This commit is contained in:
mariusmonton 2020-06-21 00:22:51 +02:00
parent 9feda996e6
commit 5b91897244
6 changed files with 14 additions and 14 deletions

View File

@ -44,7 +44,7 @@ op_A_Codes A_extension::decode() {
case A_AMOMAXU:
return OP_A_AMOMAXU;
break;
default:
[[unlikely]] default:
return OP_A_ERROR;
break;
@ -405,7 +405,7 @@ bool A_extension::process_instruction(Instruction &inst) {
case OP_A_AMOMAXU:
Exec_A_AMOMAXU();
break;
default:
[[unlikely]] default:
std::cout << "A instruction not implemented yet" << std::endl;
inst.dump();
NOP();

View File

@ -1316,7 +1316,7 @@ bool BASE_ISA::process_instruction(Instruction &inst) {
case OP_SFENCE:
Exec_SFENCE();
break;
default:
[[unlikely]] default:
std::cout << "Wrong instruction" << std::endl;
inst.dump();
NOP();

View File

@ -37,7 +37,7 @@ void BusCtrl::b_transport(tlm::tlm_generic_payload &trans,
case TRACE_MEMORY_ADDRESS / 4:
trace_socket->b_transport(trans, delay);
break;
default:
[[likely]] default:
memory_socket->b_transport(trans, delay);
break;
}

View File

@ -162,7 +162,7 @@ void CPU::CPU_thread(void) {
/* check what type of instruction is and execute it */
switch (inst->check_extension()) {
case BASE_EXTENSION:
[[likely]] case BASE_EXTENSION:
PC_not_affected = exec->process_instruction(*inst);
incPCby2 = false;
break;
@ -178,7 +178,7 @@ void CPU::CPU_thread(void) {
PC_not_affected = a_inst->process_instruction(*inst);
incPCby2 = false;
break;
default:
[[unlikely]] default:
std::cout << "Extension not implemented yet" << std::endl;
inst->dump();
exec->NOP();

View File

@ -33,7 +33,7 @@ op_C_Codes C_extension::decode() {
case C_FSW:
return OP_C_FSW;
break;
default:
[[unlikely]] default:
return OP_C_ERROR;
break;
}
@ -90,7 +90,7 @@ op_C_Codes C_extension::decode() {
case C_BNEZ:
return OP_C_BNEZ;
break;
default:
[[unlikely]] default:
return OP_C_ERROR;
break;
}
@ -131,13 +131,13 @@ op_C_Codes C_extension::decode() {
return OP_C_SWSP;
break;
case C_FWWSP:
default:
[[unlikely]] default:
return OP_C_ERROR;
break;
}
break;
default:
[[unlikely]] default:
return OP_C_ERROR;
break;
@ -745,7 +745,7 @@ bool C_extension::process_instruction(Instruction &inst) {
case OP_C_AND:
Exec_C_AND();
break;
default:
[[unlikely]] default:
std::cout << "C instruction not implemented yet" << std::endl;
inst.dump();
NOP();

View File

@ -35,7 +35,7 @@ op_M_Codes M_extension::decode() {
case M_REMU:
return OP_M_REMU;
break;
default:
[[unlikely]] default:
return OP_M_ERROR;
break;
}
@ -275,7 +275,7 @@ bool M_extension::process_instruction(Instruction &inst) {
case OP_M_REMU:
Exec_M_REMU();
break;
default:
[[unlikely]] default:
std::cout << "M instruction not implemented yet" << std::endl;
inst.dump();
//NOP(inst);