Well, the register allocation situation is certainly better than N64, but still you've only got about 12 registers to work with (not counting stack, link, and global pointer). Take out another few for the cycle count, address generation, and memory map (although those are somewhat negotiable) and you're down to nine or so registers. SH2 has 22 registers, of which you could at most statically map 9.I didn't think it was, and you've probably seen where I've mentioned before that I think that SH2 recompilation to ARM may benefit more from a lot of the allocation registers being statically selected instead of dynamically if it doesn't cross blocks. At least I convinced notaz to do that.. would be interesting to see which works out as better I guess.
Yes. Detecting modifications works the same way as detecting self-modifying code, it checks for writes. I used 4K pages for trapping writes, mostly because I reused the code from mupen64plus. Saturn games have an annoying habit of writing data very close to code. The PSP port of yabause uses 256-byte pages for detecting writes, which still isn't small enough since some data is written less than 256 bytes from executable code. The way I ended up dealing with this was if a write hits a protected 4K page, it checks if the write actually hit any compiled code blocks before dropping them. Since this check takes extra time, if it happens more than 500 times then it drops the blocks anyway and un-writeprotects the page. The 500-times counter gets reset with each vblank. Also it keeps track of writes that were trapped, so if it has to recompile a block due to writes, then it won't treat values as constants if those locations have been written to recently.And from what I recall from drk||Raziel, SH code relies on a lot of constants loaded from PC-relative areas, particularly branch targets. And that it helps recompilation a lot if you can assume these are constants at compile-time, but then have to have some way of determining if they're modified (drk used MMU-assisted write protection w/OS signals for this).. are you currently doing anything like this?
The Saturn has a rather complex memory map. Basically I used a look up table, similar to the TLB emulation for N64. If the target address can be determined via constant propagation, then the LUT is bypassed.That and I guess the memory stuff would be pretty different from N64 and PS1 since the memory is no longer at 0x80000000.. I guess my question is if a majority of accesses still tend to go to only one of the RAM regions, since I'm sure that determines what solution you've used.