]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/6l, cmd/8l, cmd/5l: add AUNDEF instruction
authorRuss Cox <rsc@golang.org>
Wed, 30 May 2012 20:47:56 +0000 (16:47 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 30 May 2012 20:47:56 +0000 (16:47 -0400)
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

14 files changed:
src/cmd/5a/lex.c
src/cmd/5l/5.out.h
src/cmd/5l/asm.c
src/cmd/5l/optab.c
src/cmd/5l/pass.c
src/cmd/5l/span.c
src/cmd/6a/lex.c
src/cmd/6l/6.out.h
src/cmd/6l/optab.c
src/cmd/6l/pass.c
src/cmd/8a/lex.c
src/cmd/8l/8.out.h
src/cmd/8l/optab.c
src/cmd/8l/pass.c

index 252a282a0513e52ac07bb5de5059b075cfa7ab43..e569fe62d3aaa617b5072cfd73aba3344d940e8b 100644 (file)
@@ -405,6 +405,7 @@ struct
        "MRC",          LTYPEJ, 1,
 
        "PLD",          LTYPEPLD, APLD,
+       "UNDEF",        LTYPEE, AUNDEF,
        0
 };
 
index 08a60d0642c12a25976df6d79832b4df6812f77e..3c726e924b3f413ac26eba2e43a45b1b98d515eb 100644 (file)
@@ -185,6 +185,8 @@ enum        as
        ASTREXD,
 
        APLD,
+       
+       AUNDEF,
 
        ALAST,
 };
index c8e50305c6153281dd727fc569f29d34a5e52674..22695b07165cfe2dc799a4d3300d6962f064c106 100644 (file)
@@ -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;
index 76f2d4dda54e1007bdbcc6a0278aa3e2e6cfc4c8..be25b6ed6116d226c2beed463b776313134a790a 100644 (file)
@@ -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 },
 };
index 34932fd4a0ad3d05789aa696fd65249b231b0b2a..50593ced972b6c1d44280afdb83754b17145f2f2 100644 (file)
@@ -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)
index 242ba1603d0f4d26d45b18d586ddee4c6ddc4627..acacb66bb06d14bbb69a7037ef2a348b629714ba 100644 (file)
@@ -847,6 +847,7 @@ buildop(void)
                case ASTREXD:
                case ATST:
                case APLD:
+               case AUNDEF:
                        break;
                }
        }
index 23f4637e106347d94d09a8a95dfb90ee964e08ab..6a1c652654cbfcf28fbb27a76b835126bd9b34a8 100644 (file)
@@ -1007,6 +1007,7 @@ struct
        "PREFETCHT1",           LTYPE2, APREFETCHT1,
        "PREFETCHT2",           LTYPE2, APREFETCHT2,
        "PREFETCHNTA",          LTYPE2, APREFETCHNTA,
+       "UNDEF",        LTYPE0, AUNDEF,
 
        0
 };
index 4271944ce4cc3b2c572972b69e64775ded253d82..cd861c038ea07698893d43a2eab368be60dc8bcf 100644 (file)
@@ -745,6 +745,8 @@ enum        as
        AMOVQL,
        ABSWAPL,
        ABSWAPQ,
+       
+       AUNDEF,
 
        ALAST
 };
index 717d083e99a0133113a369340b2ded5c2a7ddde8..0716fa4453fec5e72eb7944535df502ab53af242 100644 (file)
@@ -1294,6 +1294,8 @@ Optab optab[] =
        
        { AMOVQL,       yrl_ml, Px, 0x89 },
 
+       { AUNDEF,               ynone,  Px, 0x0f, 0x0b },
+
        { AEND },
        0
 };
index 758f61d651047822ff609c1bf519a5088002bad1..fc89fd8fc386a9536f2177e38f3e7962fd3ae77b 100644 (file)
@@ -79,6 +79,7 @@ nofollow(int a)
        case ARETFL:
        case ARETFQ:
        case ARETFW:
+       case AUNDEF:
                return 1;
        }
        return 0;
index d3a635cdcbd8e52d2430092c4003d95f6d2a36d9..4c3b0e6a32dd8cf382c76ec9cf6493b4f6ef20a2 100644 (file)
@@ -672,6 +672,7 @@ struct
        "PREFETCHT1",           LTYPE2, APREFETCHT1,
        "PREFETCHT2",           LTYPE2, APREFETCHT2,
        "PREFETCHNTA",          LTYPE2, APREFETCHNTA,
+       "UNDEF",        LTYPE0, AUNDEF,
 
        0
 };
index 8329f4a6da42161676cca62c3d8a5e534c915deb..924ba93901d1c8d4e6aeb502e63ef25da2b61f2d 100644 (file)
@@ -458,6 +458,8 @@ enum        as
        APREFETCHNTA,
        
        ABSWAPL,
+       
+       AUNDEF,
 
        ALAST
 };
index 81fe25d0429b38cc0a3e0fb79ff31e4c166569e5..7a588fca499089e2811874a1bd208dd986022a1a 100644 (file)
@@ -779,6 +779,8 @@ Optab optab[] =
        { APREFETCHNTA, yprefetch,      Pm,     0x18,(00) },
 
        { ABSWAPL,      ybswap, Pm,     0xc8 },
+       
+       { AUNDEF,               ynone,  Px,     0x0f, 0x0b },
 
        0
 };
index 9704e3530ed04aaa76059ef31da32315be4e6f0f..27d8d4ee2a48550bdee1be010b534c17fc31af17 100644 (file)
@@ -75,6 +75,7 @@ nofollow(int a)
        case ARET:
        case AIRETL:
        case AIRETW:
+       case AUNDEF:
                return 1;
        }
        return 0;