Mill Computing, Inc. Forums The Mill Tools Compilers Loop compilation Reply To: Loop compilation

Witold Baryluk
Participant
Post count: 33

Hi Veedrac. This is really helpful! Thanks.

So, when we also include the ‘y’, and not use spiller it will be something like this?


L("init")
load(&A1, 0, 0, 4, 0) %A1, or(x, 0) %x, xor(0, 0) %i, load(&n, 0, 0, 4, 0) %nsubi, xor(0, 0) %tmp1, xor(0, 0) %tmp2, or(y, 0) %y;  % please ignore the exact order of ops here, load delays, or exceeding number of AGU and ALU FUs.

<stalling few cycles for loads of A1 and nsubi to finish>

eql(%nsubi);

brtr("epilog", %A1 %x %i %nsubi %tmp1 %tmp2 %y);   % %A1 and %nsubi are not needed, but whatever.

L("loop") %A1 %x %i %nsubi %tmp1 %tmp2 %y;
        load(%A1, 0, $i, 4, 4) %a,    % shouldn't be "load(%A1, 0, $i, 4, 5)"?
        mul(%x,  %i) %xi;

        nop; nop;

        mul(%xi, %i) %xii;

        nop; nop;

        mul(%a, %xi)  %tmp1inc,
        mul(%a, %xii) %tmp2inc;

        nop; nop;

        add1u(%i) %i_,
        sub1u(%nsubi) %nsubi_,
        eql(),
        add(%tmp1, %tmp1inc) %tmp1_,
        add(%tmp2, %tmp2inc) %tmp2_;
        brtr("loop", %A1 %x %i_ %nsubi_ %tmp1_ %tmp2_ %y);

L("epilog")
mul(%y, %tmp1) %tmp1y_;

nop; nop;

mul(%tmp1y_, %tmp2) %r_;

nop; nop;

ret(%r_);

(with mul with y done first, so it is closer on belt, which might be useful if the loop is even larger).

Is brtr("epilog", ...) even allowed like that? The entire thing is no longer EBB AFAIK, but I think hardware should be ok with this.

I am thinking to write a simulator / dynamic recompiler for Mill-like ISA to be simulated (for research mostly), with input machine code mostly written by hand at this time.