9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] MIPS LE fp register ordering in MOVD
@ 2013-12-24 17:20 cherry
  2013-12-26 23:46 ` cherry
  0 siblings, 1 reply; 13+ messages in thread
From: cherry @ 2013-12-24 17:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 4062 bytes --]

Hello Fans,

It seems 0l/vl in little endian mode outputs wrong ordering of fp registers
in MOVD. For a double, which is stored in an even-odd pair of fp registers,
the least significant bits should be held in the even numbered register,
regardless of the endianess. When moving from/to memory, in LE mode the
first 4 bytes should go to even numbered registers, which is different from
BE mode.

A patch is submitted.

% patch/diff 0l-movd-fpreg-order
/sys/src/cmd/vl/asm.c
    asm.c.orig:1019,1026 -
/n/sources/patch/0l-movd-fpreg-order/asm.c:1019,1031
                  o1 = OP_IRR(opirr(ALAST), v>>16, REGZERO, REGTMP);
                  o2 = OP_IRR(opirr(AOR), v, REGTMP, REGTMP);
                  o3 = OP_RRR(oprrr(AADDU), r, REGTMP, REGTMP);
    -             o4 = OP_IRR(opirr(AMOVF+ALAST), 0, REGTMP, p->to.reg+1);
    -             o5 = OP_IRR(opirr(AMOVF+ALAST), 4, REGTMP, p->to.reg);
    +             if(little) {
    +                 o4 = OP_IRR(opirr(AMOVF+ALAST), 0, REGTMP, p->to.reg);
    +                 o5 = OP_IRR(opirr(AMOVF+ALAST), 4, REGTMP,
p->to.reg+1);
    +             } else {
    +                 o4 = OP_IRR(opirr(AMOVF+ALAST), 0, REGTMP,
p->to.reg+1);
    +                 o5 = OP_IRR(opirr(AMOVF+ALAST), 4, REGTMP, p->to.reg);
    +             }
                  break;
              case 16:
                  o1 = OP_IRR(opirr(ALAST), v>>16, REGZERO, REGTMP);
    asm.c.orig:1029,1036 -
/n/sources/patch/0l-movd-fpreg-order/asm.c:1034,1046
                  o4 = OP_IRR(opirr(AMOVF+ALAST), 0, REGTMP, p->to.reg);
                  break;
              case 8:
    -             o1 = OP_IRR(opirr(AMOVF+ALAST), v, r, p->to.reg+1);
    -             o2 = OP_IRR(opirr(AMOVF+ALAST), v+4, r, p->to.reg);
    +             if(little) {
    +                 o1 = OP_IRR(opirr(AMOVF+ALAST), v, r, p->to.reg);
    +                 o2 = OP_IRR(opirr(AMOVF+ALAST), v+4, r, p->to.reg+1);
    +             } else {
    +                 o1 = OP_IRR(opirr(AMOVF+ALAST), v, r, p->to.reg+1);
    +                 o2 = OP_IRR(opirr(AMOVF+ALAST), v+4, r, p->to.reg);
    +             }
                  break;
              case 4:
                  o1 = OP_IRR(opirr(AMOVF+ALAST), v, r, p->to.reg);
    asm.c.orig:1050,1057 -
/n/sources/patch/0l-movd-fpreg-order/asm.c:1060,1072
                  o1 = OP_IRR(opirr(ALAST), v>>16, REGZERO, REGTMP);
                  o2 = OP_IRR(opirr(AOR), v, REGTMP, REGTMP);
                  o3 = OP_RRR(oprrr(AADDU), r, REGTMP, REGTMP);
    -             o4 = OP_IRR(opirr(AMOVF), 0, REGTMP, p->from.reg+1);
    -             o5 = OP_IRR(opirr(AMOVF), 4, REGTMP, p->from.reg);
    +             if(little) {
    +                 o4 = OP_IRR(opirr(AMOVF), 0, REGTMP, p->from.reg);
    +                 o5 = OP_IRR(opirr(AMOVF), 4, REGTMP, p->from.reg+1);
    +             } else {
    +                 o4 = OP_IRR(opirr(AMOVF), 0, REGTMP, p->from.reg+1);
    +                 o5 = OP_IRR(opirr(AMOVF), 4, REGTMP, p->from.reg);
    +             }
                  break;
              case 16:
                  if(r == REGTMP)
    asm.c.orig:1062,1069 -
/n/sources/patch/0l-movd-fpreg-order/asm.c:1077,1089
                  o4 = OP_IRR(opirr(AMOVF), 0, REGTMP, p->from.reg);
                  break;
              case 8:
    -             o1 = OP_IRR(opirr(AMOVF), v, r, p->from.reg+1);
    -             o2 = OP_IRR(opirr(AMOVF), v+4, r, p->from.reg);
    +             if(little) {
    +                 o1 = OP_IRR(opirr(AMOVF), v, r, p->from.reg);
    +                 o2 = OP_IRR(opirr(AMOVF), v+4, r, p->from.reg+1);
    +             } else {
    +                 o1 = OP_IRR(opirr(AMOVF), v, r, p->from.reg+1);
    +                 o2 = OP_IRR(opirr(AMOVF), v+4, r, p->from.reg);
    +             }
                  break;
              case 4:
                  o1 = OP_IRR(opirr(AMOVF), v, r, p->from.reg);

Let me know if I missed anything.

Thanks and Merry Christmas.
- cherry

[-- Attachment #2: Type: text/html, Size: 4366 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-12-30  7:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-24 17:20 [9fans] MIPS LE fp register ordering in MOVD cherry
2013-12-26 23:46 ` cherry
2013-12-26 23:48   ` erik quanstrom
2013-12-27  0:25     ` cherry
2013-12-27  1:40       ` cinap_lenrek
2013-12-27  3:40         ` cherry
2013-12-30  7:12       ` Skip Tavakkolian
2013-12-27  3:41   ` cherry
2013-12-27  4:32     ` Bruce Ellis
2013-12-27  4:41       ` lucio
2013-12-27 22:32         ` Bruce Ellis
2013-12-28  1:22       ` cherry
2013-12-28  1:47         ` Bruce Ellis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).