]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/5l, cmd/6l, cmd/8l: accept PCDATA instruction in input
authorRuss Cox <rsc@golang.org>
Tue, 16 Jul 2013 20:23:11 +0000 (16:23 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 16 Jul 2013 20:23:11 +0000 (16:23 -0400)
The portable code in cmd/ld already knows how to process it,
we just have to ignore it during code generation.

R=ken2
CC=golang-dev
https://golang.org/cl/11363043

src/cmd/5l/noop.c
src/cmd/5l/optab.c
src/cmd/5l/span.c
src/cmd/6l/optab.c
src/cmd/6l/pass.c
src/cmd/8l/optab.c
src/cmd/8l/pass.c

index 88bff318d10cdb5eea707d8b8b935c45f0f9a228..e8d09160e6d07763230118270c1aa9c7452852a7 100644 (file)
@@ -58,6 +58,7 @@ noops(void)
 {
        Prog *p, *q, *q1, *q2;
        int o;
+       int32 arg;
        Prog *pmorestack;
        Sym *symmorestack;
 
@@ -272,7 +273,12 @@ noops(void)
                                        p->as = AMOVW;
                                        p->scond = C_SCOND_LS;
                                        p->from.type = D_CONST;
-                                       p->from.offset = (cursym->text->to.offset2 + 3) & ~3;
+                                       arg = cursym->text->to.offset2;
+                                       if(arg == 1) // special marker for known 0
+                                               arg = 0;
+                                       if(arg&3)
+                                               diag("misaligned argument size in stack split");
+                                       p->from.offset = arg;
                                        p->to.type = D_REG;
                                        p->to.reg = 2;
        
index 46982ad72791b0e4c22fef26bb70a6eeb83ea77e..91cadbdf4527c2c211e1faeb663b4d3b4333fbb2 100644 (file)
@@ -246,6 +246,8 @@ Optab       optab[] =
        { AMULAWT,      C_REG,  C_REG,  C_REGREG2,              99, 4, 0 },
 
        { AUSEFIELD,    C_ADDR, C_NONE, C_NONE,          0, 0, 0 },
+       { APCDATA,      C_LCON, C_NONE, C_LCON,         0, 0, 0 },
+       { AFUNCDATA,    C_LCON, C_NONE, C_ADDR, 0, 0, 0 },
 
        { AXXX,         C_NONE, C_NONE, C_NONE,          0, 4, 0 },
 };
index a5afa02e79a90172cd0161f276d255590223f7e2..96138b26632646564fd0133b1eacdaf7f5d8c023 100644 (file)
@@ -141,7 +141,7 @@ span(void)
                                if(checkpool(op, p->as == ACASE ? casesz(p) : m))
                                        c = p->pc = scan(op, p, c);
                        }
-                       if(m == 0) {
+                       if(m == 0 && (p->as != AFUNCDATA && p->as != APCDATA)) {
                                diag("zero-width instruction\n%P", p);
                                continue;
                        }
@@ -211,7 +211,7 @@ span(void)
                                }
  */
                                m = o->size;
-                               if(m == 0) {
+                               if(m == 0 && (p->as != AFUNCDATA && p->as != APCDATA)) {
                                        if(p->as == ATEXT) {
                                                autosize = p->to.offset + 4;
                                                if(p->from.sym != S)
@@ -890,6 +890,8 @@ buildop(void)
                case APLD:
                case AUNDEF:
                case ACLZ:
+               case AFUNCDATA:
+               case APCDATA:
                        break;
                }
        }
index 3aa177b270bb24c340c980ee3e177c72c1b6c234..c354967b982a61fa2b35a528e5de2631006d5810 100644 (file)
@@ -53,6 +53,16 @@ uchar        ynop[] =
        Yxr,    Ynone,  Zpseudo,1,
        0
 };
+uchar  yfuncdata[] =
+{
+       Yi32,   Ym,     Zpseudo,        0,
+       0
+};
+uchar  ypcdata[] = 
+{
+       Yi32,   Yi32,   Zpseudo,        0,
+       0
+};
 uchar  yxorb[] =
 {
        Yi32,   Yal,    Zib_,   1,
@@ -1342,8 +1352,8 @@ Optab optab[] =
        { APCLMULQDQ,   yxshuf, Pq, 0x3a,0x44,0 },
 
        { AUSEFIELD,    ynop,   Px, 0,0 },
-       { AFUNCDATA,    ynop,   Px, 0,0 },
-       { APCDATA,      ynop,   Px, 0,0 },
+       { AFUNCDATA,    yfuncdata,      Px, 0,0 },
+       { APCDATA,      ypcdata,        Px, 0,0 },
 
        { AEND },
        0
index 77defed3947fb4095a0171aac74c7ed3062e2274..644d898b9ca6734e7583bda90b4b6258cf5941ab 100644 (file)
@@ -589,7 +589,10 @@ dostkoff(void)
                        if(StackTop + textarg + PtrSize + autoffset + PtrSize + StackLimit >= StackMin)
                                moreconst1 = autoffset;
                        moreconst2 = textarg;
-
+                       if(moreconst2 == 1) // special marker
+                               moreconst2 = 0;
+                       if((moreconst2&7) != 0)
+                               diag("misaligned argument size in stack split");
                        // 4 varieties varieties (const1==0 cross const2==0)
                        // and 6 subvarieties of (const1==0 and const2!=0)
                        p = appendp(p);
index c08e1524a61778377042c829f6c4c5b721cbaba1..78fe45238e7b405e2ab5b8144259a164fcea5596 100644 (file)
@@ -49,6 +49,16 @@ uchar        ynop[] =
        Yrf,    Ynone,  Zpseudo,1,
        0
 };
+uchar  yfuncdata[] =
+{
+       Yi32,   Ym,     Zpseudo,        0,
+       0
+};
+uchar  ypcdata[] =
+{
+       Yi32,   Yi32,   Zpseudo,        0,
+       0,
+};
 uchar  yxorb[] =
 {
        Yi32,   Yal,    Zib_,   1,
@@ -1002,8 +1012,8 @@ Optab optab[] =
 
        { AUSEFIELD,    ynop,   Px, 0,0 },
        { ATYPE },
-       { AFUNCDATA,    ynop,   Px, 0,0 },
-       { APCDATA,      ynop,   Px, 0,0 },
+       { AFUNCDATA,    yfuncdata,      Px, 0,0 },
+       { APCDATA,      ypcdata,        Px, 0,0 },
 
        0
 };
index 2f6b96c61dbcf2fbc94acbb6058364e16ef30159..41e40b05b42a4c553c606236a016a7e213c5cb1a 100644 (file)
@@ -410,7 +410,7 @@ dostkoff(void)
 {
        Prog *p, *q, *q1;
        int32 autoffset, deltasp;
-       int a;
+       int a, arg;
        Prog *pmorestack;
        Sym *symmorestack;
        Sym *plan9_tos;
@@ -623,11 +623,16 @@ dostkoff(void)
                        if(StackTop + cursym->text->to.offset2 + PtrSize + autoffset + PtrSize + StackLimit >= StackMin)
                                p->from.offset = (autoffset+7) & ~7LL;
 
+                       arg = cursym->text->to.offset2;
+                       if(arg == 1) // special marker for known 0
+                               arg = 0;
+                       if(arg&3)
+                               diag("misaligned argument size in stack split");
                        p = appendp(p); // save arg size in AX
                        p->as = AMOVL;
                        p->to.type = D_AX;
                        p->from.type = D_CONST;
-                       p->from.offset = cursym->text->to.offset2;
+                       p->from.offset = arg;
 
                        p = appendp(p);
                        p->as = ACALL;