diff options
| author | Russ Cox <rsc@golang.org> | 2012-05-30 16:47:56 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-05-30 16:47:56 -0400 |
| commit | f2bd3a977d105f8a4ee3f4c86fe8daf52f629495 (patch) | |
| tree | 921e6cab9c4fd97d7106ebf07e8fbe7422d7797c /src/cmd/5l | |
| parent | 8820ab5da9da5528e256d3a519723fdf44ddc75f (diff) | |
| download | go-f2bd3a977d105f8a4ee3f4c86fe8daf52f629495.tar.xz | |
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
Diffstat (limited to 'src/cmd/5l')
| -rw-r--r-- | src/cmd/5l/5.out.h | 2 | ||||
| -rw-r--r-- | src/cmd/5l/asm.c | 9 | ||||
| -rw-r--r-- | src/cmd/5l/optab.c | 2 | ||||
| -rw-r--r-- | src/cmd/5l/pass.c | 6 | ||||
| -rw-r--r-- | src/cmd/5l/span.c | 1 |
5 files changed, 17 insertions, 3 deletions
diff --git a/src/cmd/5l/5.out.h b/src/cmd/5l/5.out.h index 08a60d0642..3c726e924b 100644 --- a/src/cmd/5l/5.out.h +++ b/src/cmd/5l/5.out.h @@ -185,6 +185,8 @@ enum as ASTREXD, APLD, + + AUNDEF, ALAST, }; diff --git a/src/cmd/5l/asm.c b/src/cmd/5l/asm.c index c8e50305c6..22695b0716 100644 --- a/src/cmd/5l/asm.c +++ b/src/cmd/5l/asm.c @@ -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; } else 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; diff --git a/src/cmd/5l/optab.c b/src/cmd/5l/optab.c index 76f2d4dda5..be25b6ed61 100644 --- a/src/cmd/5l/optab.c +++ b/src/cmd/5l/optab.c @@ -233,6 +233,8 @@ Optab optab[] = { ASTREXD, C_SOREG,C_REG, C_REG, 92, 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 }, }; diff --git a/src/cmd/5l/pass.c b/src/cmd/5l/pass.c index 34932fd4a0..50593ced97 100644 --- a/src/cmd/5l/pass.c +++ b/src/cmd/5l/pass.c @@ -119,7 +119,7 @@ loop: i--; 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; if(q->cond == P || (q->cond->mark&FOLL)) continue; @@ -140,7 +140,7 @@ loop: } (*last)->link = 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; r->as = ABNE; if(a == ABNE) @@ -166,7 +166,7 @@ loop: p->mark |= FOLL; (*last)->link = 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; } if(p->cond != P) diff --git a/src/cmd/5l/span.c b/src/cmd/5l/span.c index 242ba1603d..acacb66bb0 100644 --- a/src/cmd/5l/span.c +++ b/src/cmd/5l/span.c @@ -847,6 +847,7 @@ buildop(void) case ASTREXD: case ATST: case APLD: + case AUNDEF: break; } } |
