[kaffe] Re: m68k jit3 (was: jit3 expert wanted!)
Kiyo Inaba
inaba at src.ricoh.co.jp
Fri Jul 23 23:58:08 PDT 2004
I am so glad that some other persons are interested in m68k instruction :-)
I think your question may be best answered by the source as usual,
but I will summarize this.
>In <200407230100.i6N10nE10980 at snoopy.src.ricoh.co.jp> Kiyo Inaba wrote:
>> I made a patch file to solve some problem on m68k jit3. In this patch
>> you can find two modifications. The first one is suggested by Helmer
>> not to emit code for spilling unneeded registers. The second one is
>> to comment out a function which emits unimplemented code. (Usually,
>> 68k machine instruction is so orthogonal, but cmpi inst can not accept
>> address registers...)
>
>to clarify for all, so that other... can think about it
>
>CMPI = Compare Immediate
>
>CMPI #<data>,<ea>
>
>but I don't understand your "address registers". Although the motorola
>manual says "only data addressing modes can be used" the explicative
>tables say:
>DN -> reg. number:Dn
>An -> N/A
>(An)
>(An)+
>and many others
>
>and so further on. In Motorola syntax no parentheses mean register
>direct access, parentheses mean indirect access (with possible increment
>etc)
Your interpretation is perfectly correct for this issue.
>What do you mean i s that you can't compare to An directly? that is, An.
>I never noticed this, but other instructions, like BTST or MULS have the
>same restriction.
Right, it's much better to see the inside of 'jit3-m68k.def'.
In that file, you can find
-----------------------------------------------------------------------
define_insn(cmp_ref_const, cmpr_xRC)
{
int v = const_int(2);
int r = rreg_ref(1);
if (v != 0) {
op_cmpil_ia(v, r);
}
else {
op_tst_a(r);
}
}
-----------------------------------------------------------------------
and the 'op_cmpil_ia' is defined as
-----------------------------------------------------------------------
static inline void
op_cmpil_ia(int imm, int src2)
{
debug(("cmpil #%d, %s\n", imm, regname(src2)));
assert_areg(src2);
WOUT(0x0C80 | (MODE_a << 3) | (src2 & 7));
LOUT(imm);
}
-----------------------------------------------------------------------
If you disassemble this, you can find '0x0C' as a CMPI inst. But as
you mentioned (and as I noticed) this instruction can not be used
with MODE_a (0b001). So I can say this inst generation is wrong.
As you suggest, the fix should use CMPA with immediate value, but
I select simpler way (just comment out this sequence), because
cmp_ref_const is not mandatory, and I don't want to spend long time
to make this part better.
# There are so many parts which need brushup in m68k/jit3.
-----------------------------------------------------------------------
>Beides, if kaffe generates this code wrong I wonder if and how it ever
>has worked...
-----------------------------------------------------------------------
The answer is simple. It has never been used till I started to make
jit3 work ;-) The same code fragment exists in jit but it looks that
cmp_ref_const itself has naver been invoked for jit. Later, I will
send patch for jit side also. This is a good example, we have to use
coverage analyzer to get better quality software.
While writing this response, I also notice current jit or jit3 code
for m68k does not use any size modifier. This is another issue what
we can improve.
Kiyo
P.S. The gdb disassemble it as 'cmpi ...' and according to my poor
memory, this instruction really exists for 68040 or newer
CPU.
More information about the kaffe
mailing list