1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-28 21:49:27 +00:00

Reduce branchiness.

This commit is contained in:
Thomas Harte 2024-03-13 11:02:52 -04:00
parent 6b18d775ab
commit 7aeea535a1

View File

@ -198,13 +198,10 @@ struct Interrupts {
(fiq_.request() ? InterruptRequests::FIQ : 0);
}
bool tick_timers() {
bool did_change_interrupts = false;
for(int c = 0; c < 4; c++) {
// Events happen only on a decrement to 0; a reload value of 0 effectively means 'don't count'.
template <int c>
bool tick_timer() {
if(!counters_[c].value && !counters_[c].reload) {
continue;
return false;
}
--counters_[c].value;
@ -212,14 +209,22 @@ struct Interrupts {
counters_[c].value = counters_[c].reload;
switch(c) {
case 0: did_change_interrupts |= irq_a_.apply(IRQA::Timer0); break;
case 1: did_change_interrupts |= irq_a_.apply(IRQA::Timer1); break;
case 0: return irq_a_.apply(IRQA::Timer0);
case 1: return irq_a_.apply(IRQA::Timer1);
default: break;
}
// TODO: events for timers 2 and 3. Also remove some branchyness.
}
// TODO: events for timers 2 and 3.
}
return false;
}
bool tick_timers() {
bool did_change_interrupts = false;
did_change_interrupts |= tick_timer<0>();
did_change_interrupts |= tick_timer<1>();
did_change_interrupts |= tick_timer<2>();
did_change_interrupts |= tick_timer<3>();
return did_change_interrupts;
}