rtoumazet / saturnin

Saturnin is a Sega Saturn emulator
Apache License 2.0
2 stars 0 forks source link

Replace Register use by Bitfields #244

Closed rtoumazet closed 2 years ago

rtoumazet commented 2 years ago

Using microprofiler I noticed that bit manipulation seemed way too present in the report, so I did some benchmarking. Using Register and BitRange to extract 6 bits from a u32 is 150 times slower than direct bit extraction ...

I came across this blog post about BitFields, and this method is on par with direct bit extraction, if not a bit faster. There's a downside though : BitRanges in Saturnin are defined using the first and last bit of the range, and the extraction is done from there. For BitFields, it's using start bit and length to extract ... so all the declarations so far will have to be updated, but it's worth it.

rtoumazet commented 2 years ago

InterruptMaskRegister and InterruptStatusRegister aren't modified in scu_register.h because of Interrupts using BitRange ...