[Freemint-list] osbind.h registers

Miro Kropáček miro.kropacek at gmail.com
Tue Aug 29 01:29:26 MSD 2017


Hi,

I've been checking few disassembly outputs from gcc and noticed something
which I first attributed to bad/missing gcc optimisation and then realised
it's actually our (mint) fault.

For instance:

#define trap_14_wllwwwww(n, a, b, c, d, e, f, g)                        \
__extension__                                                           \
({                                                                      \
        register long retvalue __asm__("d0");                           \
        long  _a = (long) (a);                                          \
        long  _b = (long) (b);                                          \
        short _c = (short)(c);                                          \
        short _d = (short)(d);                                          \
        short _e = (short)(e);                                          \
        short _f = (short)(f);                                          \
        short _g = (short)(g);                                          \
                                                                        \
        __asm__ volatile                                                \
        (                                                               \
                "movw   %8,sp at -\n\t"                                    \
                "movw   %7,sp at -\n\t"                                    \
                "movw   %6,sp at -\n\t"                                    \
                "movw   %5,sp at -\n\t"                                    \
                "movw   %4,sp at -\n\t"                                    \
                "movl   %3,sp at -\n\t"                                    \
                "movl   %2,sp at -\n\t"                                    \
                "movw   %1,sp at -\n\t"                                    \
                "trap   #14\n\t"                                        \
                "lea    sp@(20),sp "                                    \
        : "=r"(retvalue)                        /* outputs */           \
        : "g"(n), "r"(_a), "r"(_b),                                     \
          "r"(_c), "r"(_d), "r"(_e), "r"(_f), "r"(_g) /* inputs  */     \
        : __CLOBBER_RETURN("d0") "d1", "d2", "a0", "a1", "a2", "memory"
            \
        );                                                              \
        retvalue;                                                       \
})

See all the declarations of _a, _b, ... _g? *All* of them are additional
moves and register allocations. So instead of having:

move.w #123,-(sp) ; opcode

we have

move.w #123,d4
move.w d4,-(sp)

which is just a waste of resources, esp. with such high number of
variables. Can you think of a reason why it's done like this not directly
used as asm template parameters?

-- 
MiKRO / Mystic Bytes
http://mikro.atari.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.atariforge.org/pipermail/freemint-list/attachments/20170829/5933eee6/attachment.html 


More information about the Freemint-list mailing list