1
0
mirror of https://github.com/golang/go synced 2024-11-25 02:47:58 -07:00

6l, 8l: handle forward JCXZ

R=rsc
CC=golang-dev, vcc.163
https://golang.org/cl/4963044
This commit is contained in:
Jaroslavas Počepko 2011-08-26 17:20:19 -04:00 committed by Russ Cox
parent bd63409829
commit 26608d4fbb
2 changed files with 12 additions and 28 deletions

View File

@ -1439,10 +1439,11 @@ found:
case Zbr: case Zbr:
case Zjmp: case Zjmp:
case Zloop:
// TODO: jump across functions needs reloc // TODO: jump across functions needs reloc
q = p->pcond; q = p->pcond;
if(q == nil) { if(q == nil) {
diag("jmp/branch without target"); diag("jmp/branch/loop without target");
errorexit(); errorexit();
} }
if(q->as == ATEXT) { if(q->as == ATEXT) {
@ -1468,6 +1469,8 @@ found:
if(v >= -128) { if(v >= -128) {
*andptr++ = op; *andptr++ = op;
*andptr++ = v; *andptr++ = v;
} else if(t[2] == Zloop) {
diag("loop too far: %P", p);
} else { } else {
v -= 5-2; v -= 5-2;
if(t[2] == Zbr) { if(t[2] == Zbr) {
@ -1489,6 +1492,8 @@ found:
if(p->back & 2) { // short if(p->back & 2) { // short
*andptr++ = op; *andptr++ = op;
*andptr++ = 0; *andptr++ = 0;
} else if(t[2] == Zloop) {
diag("loop too far: %P", p);
} else { } else {
if(t[2] == Zbr) if(t[2] == Zbr)
*andptr++ = 0x0f; *andptr++ = 0x0f;
@ -1520,19 +1525,6 @@ found:
*/ */
break; break;
case Zloop:
q = p->pcond;
if(q == nil) {
diag("loop without target");
errorexit();
}
v = q->pc - p->pc - 2;
if(v < -128 && v > 127)
diag("loop too far: %P", p);
*andptr++ = op;
*andptr++ = v;
break;
case Zbyte: case Zbyte:
v = vaddr(&p->from, &rel); v = vaddr(&p->from, &rel);
if(rel.siz != 0) { if(rel.siz != 0) {

View File

@ -1056,9 +1056,10 @@ found:
case Zbr: case Zbr:
case Zjmp: case Zjmp:
case Zloop:
q = p->pcond; q = p->pcond;
if(q == nil) { if(q == nil) {
diag("jmp/branch without target"); diag("jmp/branch/loop without target");
errorexit(); errorexit();
} }
if(q->as == ATEXT) { if(q->as == ATEXT) {
@ -1086,6 +1087,8 @@ found:
if(v >= -128) { if(v >= -128) {
*andptr++ = op; *andptr++ = op;
*andptr++ = v; *andptr++ = v;
} else if(t[2] == Zloop) {
diag("loop too far: %P", p);
} else { } else {
v -= 5-2; v -= 5-2;
if(t[2] == Zbr) { if(t[2] == Zbr) {
@ -1107,6 +1110,8 @@ found:
if(p->back & 2) { // short if(p->back & 2) { // short
*andptr++ = op; *andptr++ = op;
*andptr++ = 0; *andptr++ = 0;
} else if(t[2] == Zloop) {
diag("loop too far: %P", p);
} else { } else {
if(t[2] == Zbr) if(t[2] == Zbr)
*andptr++ = 0x0f; *andptr++ = 0x0f;
@ -1132,19 +1137,6 @@ found:
put4(0); put4(0);
break; break;
case Zloop:
q = p->pcond;
if(q == nil) {
diag("loop without target");
errorexit();
}
v = q->pc - p->pc - 2;
if(v < -128 && v > 127)
diag("loop too far: %P", p);
*andptr++ = op;
*andptr++ = v;
break;
case Zbyte: case Zbyte:
v = vaddr(&p->from, &rel); v = vaddr(&p->from, &rel);
if(rel.siz != 0) { if(rel.siz != 0) {