Commit f2bd3a97 authored by Russ Cox's avatar Russ Cox

cmd/6l, cmd/8l, cmd/5l: add AUNDEF instruction

On 6l and 8l, this is a real instruction, guaranteed to
cause an 'undefined instruction' exception.

On 5l, we simulate it as BL to address 0.

The plan is to use it as a signal to the linker that this
point in the instruction stream cannot be reached
(hence the changes to nofollow).  This will help the
compiler explain that panicindex and friends do not
return without having to put a list of these functions
in the linker.

R=ken2
CC=golang-dev
https://golang.org/cl/6255064
parent 8820ab5d
...@@ -405,6 +405,7 @@ struct ...@@ -405,6 +405,7 @@ struct
"MRC", LTYPEJ, 1, "MRC", LTYPEJ, 1,
"PLD", LTYPEPLD, APLD, "PLD", LTYPEPLD, APLD,
"UNDEF", LTYPEE, AUNDEF,
0 0
}; };
......
...@@ -185,6 +185,8 @@ enum as ...@@ -185,6 +185,8 @@ enum as
ASTREXD, ASTREXD,
APLD, APLD,
AUNDEF,
ALAST, ALAST,
}; };
......
...@@ -1791,6 +1791,15 @@ if(debug['G']) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->name, p- ...@@ -1791,6 +1791,15 @@ if(debug['G']) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->name, p-
o1 |= (-p->from.offset) & 0xfff; o1 |= (-p->from.offset) & 0xfff;
} else } else
o1 |= p->from.offset & 0xfff; o1 |= p->from.offset & 0xfff;
case 96: /* UNDEF */
// This is supposed to be something that stops execution.
// It's not supposed to be reached, ever, but if it is, we'd
// like to be able to tell how we got there. Assemble as
// BL $0
v = (0 - pc) - 8;
o1 = opbra(ABL, C_SCOND_NONE);
o1 |= (v >> 2) & 0xffffff;
break;
} }
out[0] = o1; out[0] = o1;
......
...@@ -233,6 +233,8 @@ Optab optab[] = ...@@ -233,6 +233,8 @@ Optab optab[] =
{ ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 }, { ASTREXD, C_SOREG,C_REG, C_REG, 92, 4, 0 },
{ APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 }, { APLD, C_SOREG,C_NONE, C_NONE, 95, 4, 0 },
{ AUNDEF, C_NONE, C_NONE, C_NONE, 96, 4, 0 },
{ AXXX, C_NONE, C_NONE, C_NONE, 0, 4, 0 }, { AXXX, C_NONE, C_NONE, C_NONE, 0, 4, 0 },
}; };
...@@ -119,7 +119,7 @@ loop: ...@@ -119,7 +119,7 @@ loop:
i--; i--;
continue; continue;
} }
if(a == AB || (a == ARET && q->scond == 14) || a == ARFE) if(a == AB || (a == ARET && q->scond == 14) || a == ARFE || a == AUNDEF)
goto copy; goto copy;
if(q->cond == P || (q->cond->mark&FOLL)) if(q->cond == P || (q->cond->mark&FOLL))
continue; continue;
...@@ -140,7 +140,7 @@ loop: ...@@ -140,7 +140,7 @@ loop:
} }
(*last)->link = r; (*last)->link = r;
*last = r; *last = r;
if(a == AB || (a == ARET && q->scond == 14) || a == ARFE) if(a == AB || (a == ARET && q->scond == 14) || a == ARFE || a == AUNDEF)
return; return;
r->as = ABNE; r->as = ABNE;
if(a == ABNE) if(a == ABNE)
...@@ -166,7 +166,7 @@ loop: ...@@ -166,7 +166,7 @@ loop:
p->mark |= FOLL; p->mark |= FOLL;
(*last)->link = p; (*last)->link = p;
*last = p; *last = p;
if(a == AB || (a == ARET && p->scond == 14) || a == ARFE){ if(a == AB || (a == ARET && p->scond == 14) || a == ARFE || a == AUNDEF){
return; return;
} }
if(p->cond != P) if(p->cond != P)
......
...@@ -847,6 +847,7 @@ buildop(void) ...@@ -847,6 +847,7 @@ buildop(void)
case ASTREXD: case ASTREXD:
case ATST: case ATST:
case APLD: case APLD:
case AUNDEF:
break; break;
} }
} }
......
...@@ -1007,6 +1007,7 @@ struct ...@@ -1007,6 +1007,7 @@ struct
"PREFETCHT1", LTYPE2, APREFETCHT1, "PREFETCHT1", LTYPE2, APREFETCHT1,
"PREFETCHT2", LTYPE2, APREFETCHT2, "PREFETCHT2", LTYPE2, APREFETCHT2,
"PREFETCHNTA", LTYPE2, APREFETCHNTA, "PREFETCHNTA", LTYPE2, APREFETCHNTA,
"UNDEF", LTYPE0, AUNDEF,
0 0
}; };
......
...@@ -745,6 +745,8 @@ enum as ...@@ -745,6 +745,8 @@ enum as
AMOVQL, AMOVQL,
ABSWAPL, ABSWAPL,
ABSWAPQ, ABSWAPQ,
AUNDEF,
ALAST ALAST
}; };
......
...@@ -1294,6 +1294,8 @@ Optab optab[] = ...@@ -1294,6 +1294,8 @@ Optab optab[] =
{ AMOVQL, yrl_ml, Px, 0x89 }, { AMOVQL, yrl_ml, Px, 0x89 },
{ AUNDEF, ynone, Px, 0x0f, 0x0b },
{ AEND }, { AEND },
0 0
}; };
......
...@@ -79,6 +79,7 @@ nofollow(int a) ...@@ -79,6 +79,7 @@ nofollow(int a)
case ARETFL: case ARETFL:
case ARETFQ: case ARETFQ:
case ARETFW: case ARETFW:
case AUNDEF:
return 1; return 1;
} }
return 0; return 0;
......
...@@ -672,6 +672,7 @@ struct ...@@ -672,6 +672,7 @@ struct
"PREFETCHT1", LTYPE2, APREFETCHT1, "PREFETCHT1", LTYPE2, APREFETCHT1,
"PREFETCHT2", LTYPE2, APREFETCHT2, "PREFETCHT2", LTYPE2, APREFETCHT2,
"PREFETCHNTA", LTYPE2, APREFETCHNTA, "PREFETCHNTA", LTYPE2, APREFETCHNTA,
"UNDEF", LTYPE0, AUNDEF,
0 0
}; };
......
...@@ -458,6 +458,8 @@ enum as ...@@ -458,6 +458,8 @@ enum as
APREFETCHNTA, APREFETCHNTA,
ABSWAPL, ABSWAPL,
AUNDEF,
ALAST ALAST
}; };
......
...@@ -779,6 +779,8 @@ Optab optab[] = ...@@ -779,6 +779,8 @@ Optab optab[] =
{ APREFETCHNTA, yprefetch, Pm, 0x18,(00) }, { APREFETCHNTA, yprefetch, Pm, 0x18,(00) },
{ ABSWAPL, ybswap, Pm, 0xc8 }, { ABSWAPL, ybswap, Pm, 0xc8 },
{ AUNDEF, ynone, Px, 0x0f, 0x0b },
0 0
}; };
...@@ -75,6 +75,7 @@ nofollow(int a) ...@@ -75,6 +75,7 @@ nofollow(int a)
case ARET: case ARET:
case AIRETL: case AIRETL:
case AIRETW: case AIRETW:
case AUNDEF:
return 1; return 1;
} }
return 0; return 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