Welcome, Guest. Please login or register.

Author Topic: 68k -> ??? JIT  (Read 2744 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: 68k -> ??? JIT
« on: October 23, 2014, 09:41:32 PM »
Quote from: bloodline;775506
Hmmm, doesn't x86-64 allow you to treat registers as halves, upper and lower, so any logic/arithmetic operations would be 32bit in the respective halves (with overflows etc)? Or am I confusing it with ordinary x86?

If I'm right, you could pack two 68k registers (perhaps just the 68k address registers) in a single x86-64 register and that would definitely confer a speed advantage.

Maybe this register sharing sounds good in theory but it's not so practical in practice. In general with both 68k and x86, there are no instructions to operate on the upper half of a register so this data has to be swapped to the lower half of the register, do an operation and then swap back to the upper half (approx. 3 instructions & 3 cycles). Maybe it wouldn't be so bad if the data in the upper half was less frequently used but accessing cache can sometimes be done in 1 cycle with 1 instruction. Samurai Crow has suggested somewhat similar techniques of register sharing for a 68k compiler. That is also limited but there are a few cases where it may be practical. A boolean variable can be used in the upper half of a different 16 or 8 bit variable in a register. Some newer processors like the 68060 can make some internal optimizations when operations the size of the register are used. In most cases it's just not practical to share registers like this.

Edit: Heiroglyph beat me to it ;)
« Last Edit: October 23, 2014, 09:47:04 PM by matthey »
 

Offline matthey

  • Hero Member
  • *****
  • Join Date: Aug 2007
  • Posts: 1294
    • Show all replies
Re: 68k -> ??? JIT
« Reply #1 on: October 24, 2014, 04:34:08 PM »
Quote from: SamuraiCrow;775569
Mike "Sidewinder" Ness uses LLVM in an emulator at his current job at Unisys.  He emulates a 36 bit mainframe on AMD64 instruction set.  That's right, 9 bit bytes.


Register sharing would work in some cases. If the hardware emulating has more general purpose registers than the hardware being emulated and fast bit extraction and/or shift/rotate/swap instructions, the data can be extracted.moved from one register to a temporary register where it is used from. This could be done with 1 instruction and 1 cycle on some hardware. I'm not sure AMD64/x86_64 (16 gp registers) could do this but ARMv8 (32 gp registers) and maybe PPC (32 gp registers) could. The 68k has bitfield instructions that can do this in 1 cycle but they are slow on the 68060 (but could be 1 cycle). The 68k wasn't quite orthogonal enough for me to emulate an x86_32 (8 gp registers) using the 8 68k data registers in DOSBox either. I tried to improve the orthogonality and added x86 equivalent instructions (good for 68k also) with a new ISA which would have helped but Gunnar rejected it for the new Phoenix/Apollo cores. He added more registers (unnecessary for x86_32 emulation but good for emulating RISC) but in a way that won't be very orthogonal.