Add some performance hints to conditionals.

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon 2017-12-29 14:56:26 +00:00
parent 412a44fafd
commit 8e4030a5aa
2 changed files with 5 additions and 5 deletions

View File

@ -162,14 +162,14 @@ namespace EightBit {
} }
uint8_t AM_AbsoluteX() { uint8_t AM_AbsoluteX() {
if (Address_AbsoluteX()) if (UNLIKELY(Address_AbsoluteX()))
addCycle(); addCycle();
BUS().ADDRESS() = MEMPTR(); BUS().ADDRESS() = MEMPTR();
return getByte(); return getByte();
} }
uint8_t AM_AbsoluteY() { uint8_t AM_AbsoluteY() {
if (Address_AbsoluteY()) if (UNLIKELY(Address_AbsoluteY()))
addCycle(); addCycle();
BUS().ADDRESS() = MEMPTR(); BUS().ADDRESS() = MEMPTR();
return getByte(); return getByte();
@ -191,7 +191,7 @@ namespace EightBit {
} }
uint8_t AM_IndirectIndexedY() { uint8_t AM_IndirectIndexedY() {
if (Address_IndirectIndexedY()) if (UNLIKELY(Address_IndirectIndexedY()))
addCycle(); addCycle();
BUS().ADDRESS() = MEMPTR(); BUS().ADDRESS() = MEMPTR();
return getByte(); return getByte();

View File

@ -336,7 +336,7 @@ int EightBit::MOS6502::execute(uint8_t cell) {
__assume(0); __assume(0);
} }
if (cycles() == 0) if (UNLIKELY(cycles() == 0))
throw std::logic_error("Unhandled opcode"); throw std::logic_error("Unhandled opcode");
return cycles(); return cycles();
@ -480,7 +480,7 @@ void EightBit::MOS6502::ADC_d(uint8_t data) {
void EightBit::MOS6502::Branch(int8_t displacement) { void EightBit::MOS6502::Branch(int8_t displacement) {
const auto page = PC().high; const auto page = PC().high;
PC().word += displacement; PC().word += displacement;
if (PC().high != page) if (UNLIKELY(PC().high != page))
addCycle(); addCycle();
addCycle(); addCycle();
} }