]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5l: use BLX for BL (Rx).
authorShenghou Ma <minux.ma@gmail.com>
Mon, 10 Jun 2013 19:04:24 +0000 (03:04 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Mon, 10 Jun 2013 19:04:24 +0000 (03:04 +0800)
Fixes #5111.
Update #4718
This CL makes BL (Rx) to use BLX Rx instead of:
MOV LR, PC
MOV PC, Rx

R=cshapiro, rsc
CC=dave, gobot, golang-dev
https://golang.org/cl/9669045

src/cmd/5l/asm.c
src/cmd/5l/optab.c

index 808f1030d2ba25fa1b246fc8e3b2daf249172bef..4a772987048b3c762076cab2d1d245715d98ecdd 100644 (file)
@@ -858,17 +858,12 @@ if(debug['G']) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->name, p-
                o1 |= REGPC << 12;
                break;
 
-       case 7:         /* bl ,O(R) -> mov PC,link; add $O,R,PC */
+       case 7:         /* bl (R) -> blx R */
                aclass(&p->to);
-               o1 = oprrr(AADD, p->scond);
-               o1 |= immrot(0);
-               o1 |= REGPC << 16;
-               o1 |= REGLINK << 12;
-
-               o2 = oprrr(AADD, p->scond);
-               o2 |= immrot(instoffset);
-               o2 |= p->to.reg << 16;
-               o2 |= REGPC << 12;
+               if(instoffset != 0)
+                       diag("%P: doesn't support BL offset(REG) where offset != 0", p);
+               o1 = oprrr(ABL, p->scond);
+               o1 |= p->to.reg;
                break;
 
        case 8:         /* sll $c,[R],R -> mov (R<<$c),R */
@@ -1709,6 +1704,9 @@ oprrr(int a, int sc)
                return (o & (0xf<<28)) | (0x12 << 20) | (0xc<<4);
        case AMULAWB:
                return (o & (0xf<<28)) | (0x12 << 20) | (0x8<<4);
+
+       case ABL: // BLX REG
+               return (o & (0xf<<28)) | (0x12fff3 << 4);
        }
        diag("bad rrr %d", a);
        prasm(curp);
index 231071f20913f8290d4feb1f58448c385cc06f27..46982ad72791b0e4c22fef26bb70a6eeb83ea77e 100644 (file)
@@ -62,8 +62,8 @@ Optab optab[] =
        { ABEQ,         C_NONE, C_NONE, C_SBRA,          5, 4, 0 },
 
        { AB,           C_NONE, C_NONE, C_ROREG,         6, 4, 0,       LPOOL },
-       { ABL,          C_NONE, C_NONE, C_ROREG,         7, 8, 0 },
-       { ABL,          C_REG,  C_NONE, C_ROREG,         7, 8, 0 },
+       { ABL,          C_NONE, C_NONE, C_ROREG,         7, 4, 0 },
+       { ABL,          C_REG,  C_NONE, C_ROREG,         7, 4, 0 },
        { ABX,          C_NONE, C_NONE, C_ROREG,         75, 12, 0 },
        { ABXRET,       C_NONE, C_NONE, C_ROREG,         76, 4, 0 },