Commit 35e1deae authored by Shenghou Ma's avatar Shenghou Ma

cmd/5l: use BLX for BL (Rx).

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
parent fd419263
......@@ -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);
......
......@@ -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 },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment