liblink: place TEXT/GLOBL flags in p->from3 always

Before, amd64 and 386 stored the flags in p->from.scale
and arm and ppc64 stored the flags in p->reg.
Both caused special cases in printing and in handling of the
addresses.

To avoid possible conflicts with the real meaning of p->from
and to avoid storing a non-register value in a reg field,
use from3 to hold a TYPE_CONST value giving the flags.

There is still a special case for printing, because the flags
are specified without a $, and normally a TYPE_CONST prints
with a $. But that's much less special than what came before.

This allows us to remove the textflag and settextflag methods
from LinkArch. They are no longer architecture-specific.

Change-Id: I931da8e1ecd92e127cd9aa44ef5a73c42e730110
Reviewed-on: https://go-review.googlesource.com/3572
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Russ Cox 2015-01-29 14:58:54 -05:00
parent 72521319c7
commit 77a415e5a6
37 changed files with 1076 additions and 1085 deletions

View file

@ -210,7 +210,7 @@ struct Reloc
};
// TODO(rsc): Describe prog.
// TOOD(rsc): Make ARM scond == 0 mean C_SCOND_NONE.
// TODO(rsc): Describe TEXT/GLOBL flag in from3, DATA width in from3.
struct Prog
{
vlong pc;
@ -224,7 +224,7 @@ struct Prog
int16 reg; // arm, ppc64 only (e.g., ADD from, reg, to);
// starts at 0 for both GPRs and FPRs;
// also used for ADATA width on arm, ppc64
Addr from3; // ppc64 only (e.g., RLWM/FMADD from, reg, from3, to)
Addr from3; // addl source argument (e.g., RLWM/FMADD from, reg, from3, to)
Addr to;
// for 5g, 6g, 8g internal use
@ -245,8 +245,6 @@ struct Prog
char width; /* fake for DATA */
char mode; /* 16, 32, or 64 in 6l, 8l; internal use in 5g, 6g, 8g */
/*c2go uchar TEXTFLAG; */
};
// prevent incompatible type signatures between liblink and 8l on Plan 9
@ -604,8 +602,6 @@ struct LinkArch
int (*isdata)(Prog*);
Prog* (*prg)(void);
void (*progedit)(Link*, Prog*);
void (*settextflag)(Prog*, int);
int (*textflag)(Prog*);
int minlc;
int ptrsize;

View file

@ -127,6 +127,7 @@ EXTERN int32 thunk;
EXTERN Biobuf obuf;
EXTERN Link* ctxt;
EXTERN Biobuf bstdout;
EXTERN Prog* lastpc;
void* alloc(int32);
void* allocn(void*, int32, int32);

View file

@ -220,7 +220,11 @@ inst:
| LTYPEB name ',' con ',' '$' textsize
{
settext($2.sym);
outcode($1, Always, &$2, $4, &$7);
outcode($1, Always, &$2, 0, &$7);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
/*
* GLOBL
@ -233,7 +237,11 @@ inst:
| LGLOBL name ',' con ',' imm
{
settext($2.sym);
outcode($1, Always, &$2, $4, &$6);
outcode($1, Always, &$2, 0, &$6);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
/*
* DATA

View file

@ -497,8 +497,6 @@ static int bcode[] =
ANOP,
};
static Prog *lastpc;
void
outcode(int a, int scond, Addr *g1, int reg, Addr *g2)
{

View file

@ -577,17 +577,17 @@ static const yytype_uint16 yyrline[] =
0, 68, 68, 70, 69, 77, 76, 85, 90, 96,
97, 98, 104, 108, 112, 119, 126, 133, 137, 144,
151, 158, 165, 172, 181, 193, 197, 201, 208, 215,
220, 228, 233, 241, 248, 255, 262, 266, 270, 274,
281, 303, 311, 320, 327, 336, 347, 353, 356, 360,
365, 366, 369, 375, 386, 392, 398, 404, 411, 417,
422, 428, 431, 437, 445, 449, 458, 464, 465, 466,
467, 472, 478, 484, 490, 491, 494, 495, 503, 512,
513, 522, 523, 529, 532, 533, 534, 536, 544, 552,
561, 567, 573, 579, 587, 593, 601, 602, 606, 614,
615, 621, 622, 630, 631, 634, 640, 648, 656, 664,
674, 677, 681, 687, 688, 689, 692, 693, 697, 701,
705, 709, 715, 718, 724, 725, 729, 733, 737, 741,
745, 749, 753, 757, 761
220, 232, 237, 249, 256, 263, 270, 274, 278, 282,
289, 311, 319, 328, 335, 344, 355, 361, 364, 368,
373, 374, 377, 383, 394, 400, 406, 412, 419, 425,
430, 436, 439, 445, 453, 457, 466, 472, 473, 474,
475, 480, 486, 492, 498, 499, 502, 503, 511, 520,
521, 530, 531, 537, 540, 541, 542, 544, 552, 560,
569, 575, 581, 587, 595, 601, 609, 610, 614, 622,
623, 629, 630, 638, 639, 642, 648, 656, 664, 672,
682, 685, 689, 695, 696, 697, 700, 701, 705, 709,
713, 717, 723, 726, 732, 733, 737, 741, 745, 749,
753, 757, 761, 765, 769
};
#endif
@ -1941,12 +1941,16 @@ yyreduce:
#line 221 "a.y"
{
settext((yyvsp[(2) - (7)].addr).sym);
outcode((yyvsp[(1) - (7)].lval), Always, &(yyvsp[(2) - (7)].addr), (yyvsp[(4) - (7)].lval), &(yyvsp[(7) - (7)].addr));
outcode((yyvsp[(1) - (7)].lval), Always, &(yyvsp[(2) - (7)].addr), 0, &(yyvsp[(7) - (7)].addr));
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = (yyvsp[(4) - (7)].lval);
}
}
break;
case 31:
#line 229 "a.y"
#line 233 "a.y"
{
settext((yyvsp[(2) - (4)].addr).sym);
outcode((yyvsp[(1) - (4)].lval), Always, &(yyvsp[(2) - (4)].addr), 0, &(yyvsp[(4) - (4)].addr));
@ -1954,64 +1958,68 @@ yyreduce:
break;
case 32:
#line 234 "a.y"
#line 238 "a.y"
{
settext((yyvsp[(2) - (6)].addr).sym);
outcode((yyvsp[(1) - (6)].lval), Always, &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
outcode((yyvsp[(1) - (6)].lval), Always, &(yyvsp[(2) - (6)].addr), 0, &(yyvsp[(6) - (6)].addr));
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = (yyvsp[(4) - (6)].lval);
}
}
break;
case 33:
#line 242 "a.y"
#line 250 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), Always, &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 34:
#line 249 "a.y"
#line 257 "a.y"
{
outcode((yyvsp[(1) - (4)].lval), (yyvsp[(2) - (4)].lval), &(yyvsp[(3) - (4)].addr), 0, &nullgen);
}
break;
case 35:
#line 256 "a.y"
#line 264 "a.y"
{
outcode((yyvsp[(1) - (3)].lval), Always, &nullgen, 0, &(yyvsp[(3) - (3)].addr));
}
break;
case 36:
#line 263 "a.y"
#line 271 "a.y"
{
outcode((yyvsp[(1) - (5)].lval), (yyvsp[(2) - (5)].lval), &(yyvsp[(3) - (5)].addr), 0, &(yyvsp[(5) - (5)].addr));
}
break;
case 37:
#line 267 "a.y"
#line 275 "a.y"
{
outcode((yyvsp[(1) - (5)].lval), (yyvsp[(2) - (5)].lval), &(yyvsp[(3) - (5)].addr), 0, &(yyvsp[(5) - (5)].addr));
}
break;
case 38:
#line 271 "a.y"
#line 279 "a.y"
{
outcode((yyvsp[(1) - (7)].lval), (yyvsp[(2) - (7)].lval), &(yyvsp[(3) - (7)].addr), (yyvsp[(5) - (7)].lval), &(yyvsp[(7) - (7)].addr));
}
break;
case 39:
#line 275 "a.y"
#line 283 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), (yyvsp[(2) - (6)].lval), &(yyvsp[(3) - (6)].addr), (yyvsp[(5) - (6)].addr).reg, &nullgen);
}
break;
case 40:
#line 282 "a.y"
#line 290 "a.y"
{
Addr g;
@ -2033,14 +2041,14 @@ yyreduce:
break;
case 41:
#line 304 "a.y"
#line 312 "a.y"
{
outcode((yyvsp[(1) - (7)].lval), (yyvsp[(2) - (7)].lval), &(yyvsp[(3) - (7)].addr), (yyvsp[(5) - (7)].addr).reg, &(yyvsp[(7) - (7)].addr));
}
break;
case 42:
#line 312 "a.y"
#line 320 "a.y"
{
(yyvsp[(7) - (9)].addr).type = TYPE_REGREG2;
(yyvsp[(7) - (9)].addr).offset = (yyvsp[(9) - (9)].lval);
@ -2049,14 +2057,14 @@ yyreduce:
break;
case 43:
#line 321 "a.y"
#line 329 "a.y"
{
outcode((yyvsp[(1) - (2)].lval), Always, &(yyvsp[(2) - (2)].addr), 0, &nullgen);
}
break;
case 44:
#line 328 "a.y"
#line 336 "a.y"
{
if((yyvsp[(2) - (4)].addr).type != TYPE_CONST || (yyvsp[(4) - (4)].addr).type != TYPE_CONST)
yyerror("arguments to PCDATA must be integer constants");
@ -2065,7 +2073,7 @@ yyreduce:
break;
case 45:
#line 337 "a.y"
#line 345 "a.y"
{
if((yyvsp[(2) - (4)].addr).type != TYPE_CONST)
yyerror("index for FUNCDATA must be integer constant");
@ -2076,35 +2084,35 @@ yyreduce:
break;
case 46:
#line 348 "a.y"
#line 356 "a.y"
{
outcode((yyvsp[(1) - (2)].lval), Always, &nullgen, 0, &nullgen);
}
break;
case 47:
#line 353 "a.y"
#line 361 "a.y"
{
(yyval.lval) = Always;
}
break;
case 48:
#line 357 "a.y"
#line 365 "a.y"
{
(yyval.lval) = ((yyvsp[(1) - (2)].lval) & ~C_SCOND) | (yyvsp[(2) - (2)].lval);
}
break;
case 49:
#line 361 "a.y"
#line 369 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (2)].lval) | (yyvsp[(2) - (2)].lval);
}
break;
case 52:
#line 370 "a.y"
#line 378 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_BRANCH;
@ -2113,7 +2121,7 @@ yyreduce:
break;
case 53:
#line 376 "a.y"
#line 384 "a.y"
{
(yyvsp[(1) - (2)].sym) = labellookup((yyvsp[(1) - (2)].sym));
(yyval.addr) = nullgen;
@ -2125,7 +2133,7 @@ yyreduce:
break;
case 54:
#line 387 "a.y"
#line 395 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = (yyvsp[(1) - (1)].lval);
@ -2134,7 +2142,7 @@ yyreduce:
break;
case 55:
#line 393 "a.y"
#line 401 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = -(yyvsp[(2) - (2)].lval);
@ -2143,7 +2151,7 @@ yyreduce:
break;
case 56:
#line 399 "a.y"
#line 407 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = (yyvsp[(1) - (3)].lval);
@ -2152,7 +2160,7 @@ yyreduce:
break;
case 57:
#line 405 "a.y"
#line 413 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = -(yyvsp[(2) - (4)].lval);
@ -2161,7 +2169,7 @@ yyreduce:
break;
case 58:
#line 412 "a.y"
#line 420 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_CONST;
@ -2170,7 +2178,7 @@ yyreduce:
break;
case 59:
#line 418 "a.y"
#line 426 "a.y"
{
(yyval.addr) = (yyvsp[(2) - (2)].addr);
(yyval.addr).type = TYPE_CONST;
@ -2178,7 +2186,7 @@ yyreduce:
break;
case 60:
#line 423 "a.y"
#line 431 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SCONST;
@ -2187,7 +2195,7 @@ yyreduce:
break;
case 62:
#line 432 "a.y"
#line 440 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_FCONST;
@ -2196,7 +2204,7 @@ yyreduce:
break;
case 63:
#line 438 "a.y"
#line 446 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_FCONST;
@ -2205,14 +2213,14 @@ yyreduce:
break;
case 64:
#line 446 "a.y"
#line 454 "a.y"
{
(yyval.lval) = 1 << (yyvsp[(1) - (1)].lval);
}
break;
case 65:
#line 450 "a.y"
#line 458 "a.y"
{
int i;
(yyval.lval)=0;
@ -2224,14 +2232,14 @@ yyreduce:
break;
case 66:
#line 459 "a.y"
#line 467 "a.y"
{
(yyval.lval) = (1<<(yyvsp[(1) - (3)].lval)) | (yyvsp[(3) - (3)].lval);
}
break;
case 70:
#line 468 "a.y"
#line 476 "a.y"
{
(yyval.addr) = (yyvsp[(1) - (4)].addr);
(yyval.addr).reg = (yyvsp[(3) - (4)].lval);
@ -2239,7 +2247,7 @@ yyreduce:
break;
case 71:
#line 473 "a.y"
#line 481 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2248,7 +2256,7 @@ yyreduce:
break;
case 72:
#line 479 "a.y"
#line 487 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2257,7 +2265,7 @@ yyreduce:
break;
case 73:
#line 485 "a.y"
#line 493 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2266,7 +2274,7 @@ yyreduce:
break;
case 77:
#line 496 "a.y"
#line 504 "a.y"
{
(yyval.addr) = (yyvsp[(1) - (1)].addr);
if((yyvsp[(1) - (1)].addr).name != NAME_EXTERN && (yyvsp[(1) - (1)].addr).name != NAME_STATIC) {
@ -2275,7 +2283,7 @@ yyreduce:
break;
case 78:
#line 504 "a.y"
#line 512 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2285,7 +2293,7 @@ yyreduce:
break;
case 80:
#line 514 "a.y"
#line 522 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2295,7 +2303,7 @@ yyreduce:
break;
case 82:
#line 524 "a.y"
#line 532 "a.y"
{
(yyval.addr) = (yyvsp[(1) - (4)].addr);
(yyval.addr).type = TYPE_MEM;
@ -2304,7 +2312,7 @@ yyreduce:
break;
case 87:
#line 537 "a.y"
#line 545 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_CONST;
@ -2313,7 +2321,7 @@ yyreduce:
break;
case 88:
#line 545 "a.y"
#line 553 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2322,7 +2330,7 @@ yyreduce:
break;
case 89:
#line 553 "a.y"
#line 561 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REGREG;
@ -2332,7 +2340,7 @@ yyreduce:
break;
case 90:
#line 562 "a.y"
#line 570 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SHIFT;
@ -2341,7 +2349,7 @@ yyreduce:
break;
case 91:
#line 568 "a.y"
#line 576 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SHIFT;
@ -2350,7 +2358,7 @@ yyreduce:
break;
case 92:
#line 574 "a.y"
#line 582 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SHIFT;
@ -2359,7 +2367,7 @@ yyreduce:
break;
case 93:
#line 580 "a.y"
#line 588 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SHIFT;
@ -2368,7 +2376,7 @@ yyreduce:
break;
case 94:
#line 588 "a.y"
#line 596 "a.y"
{
if((yyval.lval) < REG_R0 || (yyval.lval) > REG_R15)
print("register value out of range in shift\n");
@ -2377,7 +2385,7 @@ yyreduce:
break;
case 95:
#line 594 "a.y"
#line 602 "a.y"
{
if((yyval.lval) < 0 || (yyval.lval) >= 32)
print("shift value out of range\n");
@ -2386,14 +2394,14 @@ yyreduce:
break;
case 97:
#line 603 "a.y"
#line 611 "a.y"
{
(yyval.lval) = REGPC;
}
break;
case 98:
#line 607 "a.y"
#line 615 "a.y"
{
if((yyvsp[(3) - (4)].lval) < 0 || (yyvsp[(3) - (4)].lval) >= NREG)
print("register value out of range in R(...)\n");
@ -2402,14 +2410,14 @@ yyreduce:
break;
case 100:
#line 616 "a.y"
#line 624 "a.y"
{
(yyval.lval) = REGSP;
}
break;
case 102:
#line 623 "a.y"
#line 631 "a.y"
{
if((yyvsp[(3) - (4)].lval) < 0 || (yyvsp[(3) - (4)].lval) >= NREG)
print("register value out of range in C(...)\n");
@ -2418,7 +2426,7 @@ yyreduce:
break;
case 105:
#line 635 "a.y"
#line 643 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2427,7 +2435,7 @@ yyreduce:
break;
case 106:
#line 641 "a.y"
#line 649 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2436,7 +2444,7 @@ yyreduce:
break;
case 107:
#line 649 "a.y"
#line 657 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2447,7 +2455,7 @@ yyreduce:
break;
case 108:
#line 657 "a.y"
#line 665 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2458,7 +2466,7 @@ yyreduce:
break;
case 109:
#line 665 "a.y"
#line 673 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -2469,140 +2477,140 @@ yyreduce:
break;
case 110:
#line 674 "a.y"
#line 682 "a.y"
{
(yyval.lval) = 0;
}
break;
case 111:
#line 678 "a.y"
#line 686 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (2)].lval);
}
break;
case 112:
#line 682 "a.y"
#line 690 "a.y"
{
(yyval.lval) = -(yyvsp[(2) - (2)].lval);
}
break;
case 117:
#line 694 "a.y"
#line 702 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (1)].sym)->value;
}
break;
case 118:
#line 698 "a.y"
#line 706 "a.y"
{
(yyval.lval) = -(yyvsp[(2) - (2)].lval);
}
break;
case 119:
#line 702 "a.y"
#line 710 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (2)].lval);
}
break;
case 120:
#line 706 "a.y"
#line 714 "a.y"
{
(yyval.lval) = ~(yyvsp[(2) - (2)].lval);
}
break;
case 121:
#line 710 "a.y"
#line 718 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (3)].lval);
}
break;
case 122:
#line 715 "a.y"
#line 723 "a.y"
{
(yyval.lval) = 0;
}
break;
case 123:
#line 719 "a.y"
#line 727 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (2)].lval);
}
break;
case 125:
#line 726 "a.y"
#line 734 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) + (yyvsp[(3) - (3)].lval);
}
break;
case 126:
#line 730 "a.y"
#line 738 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) - (yyvsp[(3) - (3)].lval);
}
break;
case 127:
#line 734 "a.y"
#line 742 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) * (yyvsp[(3) - (3)].lval);
}
break;
case 128:
#line 738 "a.y"
#line 746 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) / (yyvsp[(3) - (3)].lval);
}
break;
case 129:
#line 742 "a.y"
#line 750 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) % (yyvsp[(3) - (3)].lval);
}
break;
case 130:
#line 746 "a.y"
#line 754 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (4)].lval) << (yyvsp[(4) - (4)].lval);
}
break;
case 131:
#line 750 "a.y"
#line 758 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (4)].lval) >> (yyvsp[(4) - (4)].lval);
}
break;
case 132:
#line 754 "a.y"
#line 762 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) & (yyvsp[(3) - (3)].lval);
}
break;
case 133:
#line 758 "a.y"
#line 766 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) ^ (yyvsp[(3) - (3)].lval);
}
break;
case 134:
#line 762 "a.y"
#line 770 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) | (yyvsp[(3) - (3)].lval);
}
@ -2610,7 +2618,7 @@ yyreduce:
/* Line 1267 of yacc.c. */
#line 2614 "y.tab.c"
#line 2622 "y.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

View file

@ -9,8 +9,6 @@
#include "../gc/go.h"
#include "../5l/5.out.h"
#define TEXTFLAG reg
enum
{
REGALLOC_R0 = REG_R0,

View file

@ -200,9 +200,9 @@ ggloblnod(Node *nam)
p->to.type = TYPE_CONST;
p->to.offset = nam->type->width;
if(nam->readonly)
p->reg = RODATA;
p->from3.offset = RODATA;
if(nam->type != T && !haspointers(nam->type))
p->reg |= NOPTR;
p->from3.offset |= NOPTR;
}
void
@ -217,7 +217,7 @@ ggloblsym(Sym *s, int32 width, int8 flags)
p->to.type = TYPE_CONST;
p->to.name = NAME_NONE;
p->to.offset = width;
p->reg = flags;
p->from3.offset = flags;
}
void

View file

@ -139,6 +139,7 @@ EXTERN int32 thunk;
EXTERN Biobuf obuf;
EXTERN Link* ctxt;
EXTERN Biobuf bstdout;
EXTERN Prog* lastpc;
void* alloc(int32);
void* allocn(void*, int32, int32);

View file

@ -60,8 +60,8 @@
%type <lval> con expr pointer offset
%type <addr> mem imm reg nam rel rem rim rom omem nmem textsize
%type <addr2> nonnon nonrel nonrem rimnon rimrem remrim
%type <addr2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%type <addr2> spec10 spec11 spec12 spec13
%type <addr2> spec1 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%type <addr2> spec10 spec12 spec13
%%
prog:
| prog
@ -103,7 +103,7 @@ inst:
| LTYPE4 remrim { outcode($1, &$2); }
| LTYPER nonrel { outcode($1, &$2); }
| LTYPED spec1 { outcode($1, &$2); }
| LTYPET spec2 { outcode($1, &$2); }
| spec2
| LTYPEC spec3 { outcode($1, &$2); }
| LTYPEN spec4 { outcode($1, &$2); }
| LTYPES spec5 { outcode($1, &$2); }
@ -112,7 +112,7 @@ inst:
| LTYPEXC spec8 { outcode($1, &$2); }
| LTYPEX spec9 { outcode($1, &$2); }
| LTYPERT spec10 { outcode($1, &$2); }
| LTYPEG spec11 { outcode($1, &$2); }
| spec11
| LTYPEPC spec12 { outcode($1, &$2); }
| LTYPEF spec13 { outcode($1, &$2); }
@ -191,18 +191,47 @@ spec1: /* DATA */
}
spec2: /* TEXT */
mem ',' '$' textsize
LTYPET mem ',' '$' textsize
{
settext($1.sym);
$$.from = $1;
$$.to = $4;
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $5;
outcode(ATEXT, &a);
}
| mem ',' con ',' '$' textsize
| LTYPET mem ',' con ',' '$' textsize
{
settext($1.sym);
$$.from = $1;
$$.from.scale = $3;
$$.to = $6;
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $7;
outcode(ATEXT, &a);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
spec11: /* GLOBL */
LTYPEG mem ',' imm
{
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $4;
outcode(AGLOBL, &a);
}
| LTYPEG mem ',' con ',' imm
{
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $6;
outcode(AGLOBL, &a);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
spec3: /* JMP/CALL */
@ -297,19 +326,6 @@ spec10: /* RET/RETF */
$$.to = nullgen;
}
spec11: /* GLOBL */
mem ',' imm
{
$$.from = $1;
$$.to = $3;
}
| mem ',' con ',' imm
{
$$.from = $1;
$$.from.scale = $3;
$$.to = $5;
}
spec12: /* PCDATA */
rim ',' rim
{

View file

@ -1104,8 +1104,6 @@ cclean(void)
outcode(AEND, &g2);
}
static Prog *lastpc;
void
outcode(int a, Addr2 *g2)
{

File diff suppressed because it is too large Load diff

View file

@ -9,8 +9,6 @@
#include "../gc/go.h"
#include "../6l/6.out.h"
#define TEXTFLAG from.scale
EXTERN int32 dynloc;
EXTERN uchar reg[MAXREG];
EXTERN int32 pcloc; // instruction counter

View file

@ -198,9 +198,9 @@ ggloblnod(Node *nam)
p->to.type = TYPE_CONST;
p->to.offset = nam->type->width;
if(nam->readonly)
p->from.scale = RODATA;
p->from3.offset = RODATA;
if(nam->type != T && !haspointers(nam->type))
p->from.scale |= NOPTR;
p->from3.offset |= NOPTR;
}
void
@ -225,7 +225,7 @@ ggloblsym(Sym *s, int32 width, int8 flags)
p->from.sym = linksym(s);
p->to.type = TYPE_CONST;
p->to.offset = width;
p->from.scale = flags;
p->from3.offset = flags;
}
int

View file

@ -139,6 +139,7 @@ EXTERN int32 thunk;
EXTERN Biobuf obuf;
EXTERN Link* ctxt;
EXTERN Biobuf bstdout;
EXTERN Prog* lastpc;
void* alloc(int32);
void* allocn(void*, int32, int32);

View file

@ -59,7 +59,7 @@
%type <lval> con expr pointer offset
%type <addr> mem imm reg nam rel rem rim rom omem nmem textsize
%type <addr2> nonnon nonrel nonrem rimnon rimrem remrim
%type <addr2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 spec10 spec11 spec12
%type <addr2> spec1 spec3 spec4 spec5 spec6 spec7 spec9 spec10 spec11 spec12
%%
prog:
| prog
@ -101,13 +101,13 @@ inst:
| LTYPE4 remrim { outcode($1, &$2); }
| LTYPER nonrel { outcode($1, &$2); }
| LTYPED spec1 { outcode($1, &$2); }
| LTYPET spec2 { outcode($1, &$2); }
| spec2
| LTYPEC spec3 { outcode($1, &$2); }
| LTYPEN spec4 { outcode($1, &$2); }
| LTYPES spec5 { outcode($1, &$2); }
| LTYPEM spec6 { outcode($1, &$2); }
| LTYPEI spec7 { outcode($1, &$2); }
| LTYPEG spec8 { outcode($1, &$2); }
| spec8
| LTYPEXC spec9 { outcode($1, &$2); }
| LTYPEX spec10 { outcode($1, &$2); }
| LTYPEPC spec11 { outcode($1, &$2); }
@ -188,18 +188,47 @@ spec1: /* DATA */
}
spec2: /* TEXT */
mem ',' '$' textsize
LTYPET mem ',' '$' textsize
{
settext($1.sym);
$$.from = $1;
$$.to = $4;
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $5;
outcode(ATEXT, &a);
}
| mem ',' con ',' '$' textsize
| LTYPET mem ',' con ',' '$' textsize
{
settext($1.sym);
$$.from = $1;
$$.from.scale = $3;
$$.to = $6;
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $7;
outcode(ATEXT, &a);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
spec8: /* GLOBL */
LTYPEG mem ',' imm
{
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $4;
outcode(AGLOBL, &a);
}
| LTYPEG mem ',' con ',' imm
{
Addr2 a;
settext($2.sym);
a.from = $2;
a.to = $6;
outcode(AGLOBL, &a);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
spec3: /* JMP/CALL */
@ -271,19 +300,6 @@ spec7:
$$.to = $3;
}
spec8: /* GLOBL */
mem ',' imm
{
$$.from = $1;
$$.to = $3;
}
| mem ',' con ',' imm
{
$$.from = $1;
$$.from.scale = $3;
$$.to = $5;
}
spec9: /* CMPPS/CMPPD */
reg ',' rem ',' con
{

View file

@ -881,8 +881,6 @@ cclean(void)
outcode(AEND, &g2);
}
static Prog *lastpc;
void
outcode(int a, Addr2 *g2)
{

File diff suppressed because it is too large Load diff

View file

@ -9,8 +9,6 @@
#include "../gc/go.h"
#include "../8l/8.out.h"
#define TEXTFLAG from.scale
// foptoas flags
enum
{

View file

@ -200,9 +200,9 @@ ggloblnod(Node *nam)
p->to.type = TYPE_CONST;
p->to.offset = nam->type->width;
if(nam->readonly)
p->from.scale = RODATA;
p->from3.offset = RODATA;
if(nam->type != T && !haspointers(nam->type))
p->from.scale |= NOPTR;
p->from3.offset |= NOPTR;
}
void
@ -218,7 +218,7 @@ ggloblsym(Sym *s, int32 width, int8 flags)
p->to.type = TYPE_CONST;
p->to.index = REG_NONE;
p->to.offset = width;
p->from.scale = flags;
p->from3.offset = flags;
}
void

View file

@ -126,6 +126,7 @@ EXTERN int32 thunk;
EXTERN Biobuf obuf;
EXTERN Link* ctxt;
EXTERN Biobuf bstdout;
EXTERN Prog* lastpc;
void* alloc(int32);
void* allocn(void*, int32, int32);

View file

@ -621,7 +621,11 @@ inst:
| LTEXT name ',' con ',' '$' textsize
{
settext($2.sym);
outcode($1, &$2, $4, &$7);
outcode($1, &$2, 0, &$7);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
/*
* GLOBL
@ -634,7 +638,11 @@ inst:
| LGLOBL name ',' con ',' imm
{
settext($2.sym);
outcode($1, &$2, $4, &$6);
outcode($1, &$2, 0, &$6);
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = $4;
}
}
/*

View file

@ -650,8 +650,6 @@ cclean(void)
outcode(AEND, &nullgen, 0, &nullgen);
}
static Prog *lastpc;
void
outcode(int a, Addr *g1, int reg, Addr *g2)
{

View file

@ -648,14 +648,14 @@ static const yytype_uint16 yyrline[] =
428, 432, 436, 443, 447, 451, 455, 459, 463, 470,
474, 478, 482, 489, 493, 497, 501, 508, 512, 520,
524, 528, 532, 536, 540, 544, 551, 555, 559, 563,
567, 571, 578, 582, 589, 598, 609, 616, 621, 629,
634, 643, 647, 651, 658, 664, 670, 681, 689, 690,
693, 701, 709, 717, 725, 731, 739, 742, 750, 756,
764, 770, 778, 786, 807, 813, 819, 825, 833, 838,
846, 852, 859, 867, 868, 876, 883, 893, 894, 903,
911, 919, 928, 929, 932, 935, 939, 945, 946, 947,
950, 951, 955, 959, 963, 967, 973, 974, 978, 982,
986, 990, 994, 998, 1002, 1006, 1010
567, 571, 578, 582, 589, 598, 609, 616, 621, 633,
638, 651, 655, 659, 666, 672, 678, 689, 697, 698,
701, 709, 717, 725, 733, 739, 747, 750, 758, 764,
772, 778, 786, 794, 815, 821, 827, 833, 841, 846,
854, 860, 867, 875, 876, 884, 891, 901, 902, 911,
919, 927, 936, 937, 940, 943, 947, 953, 954, 955,
958, 959, 963, 967, 971, 975, 981, 982, 986, 990,
994, 998, 1002, 1006, 1010, 1014, 1018
};
#endif
@ -2737,12 +2737,16 @@ yyreduce:
#line 622 "a.y"
{
settext((yyvsp[(2) - (7)].addr).sym);
outcode((yyvsp[(1) - (7)].lval), &(yyvsp[(2) - (7)].addr), (yyvsp[(4) - (7)].lval), &(yyvsp[(7) - (7)].addr));
outcode((yyvsp[(1) - (7)].lval), &(yyvsp[(2) - (7)].addr), 0, &(yyvsp[(7) - (7)].addr));
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = (yyvsp[(4) - (7)].lval);
}
}
break;
case 119:
#line 630 "a.y"
#line 634 "a.y"
{
settext((yyvsp[(2) - (4)].addr).sym);
outcode((yyvsp[(1) - (4)].lval), &(yyvsp[(2) - (4)].addr), 0, &(yyvsp[(4) - (4)].addr));
@ -2750,43 +2754,47 @@ yyreduce:
break;
case 120:
#line 635 "a.y"
#line 639 "a.y"
{
settext((yyvsp[(2) - (6)].addr).sym);
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), 0, &(yyvsp[(6) - (6)].addr));
if(pass > 1) {
lastpc->from3.type = TYPE_CONST;
lastpc->from3.offset = (yyvsp[(4) - (6)].lval);
}
}
break;
case 121:
#line 644 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 122:
#line 648 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 123:
#line 652 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 122:
#line 656 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 123:
#line 660 "a.y"
{
outcode((yyvsp[(1) - (6)].lval), &(yyvsp[(2) - (6)].addr), (yyvsp[(4) - (6)].lval), &(yyvsp[(6) - (6)].addr));
}
break;
case 124:
#line 659 "a.y"
#line 667 "a.y"
{
outcode((yyvsp[(1) - (2)].lval), &nullgen, 0, &nullgen);
}
break;
case 125:
#line 665 "a.y"
#line 673 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_BRANCH;
@ -2795,7 +2803,7 @@ yyreduce:
break;
case 126:
#line 671 "a.y"
#line 679 "a.y"
{
(yyvsp[(1) - (2)].sym) = labellookup((yyvsp[(1) - (2)].sym));
(yyval.addr) = nullgen;
@ -2807,7 +2815,7 @@ yyreduce:
break;
case 127:
#line 682 "a.y"
#line 690 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2816,7 +2824,7 @@ yyreduce:
break;
case 130:
#line 694 "a.y"
#line 702 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2825,7 +2833,7 @@ yyreduce:
break;
case 131:
#line 702 "a.y"
#line 710 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2834,15 +2842,6 @@ yyreduce:
break;
case 132:
#line 710 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
(yyval.addr).reg = (yyvsp[(1) - (1)].lval);
}
break;
case 133:
#line 718 "a.y"
{
(yyval.addr) = nullgen;
@ -2851,7 +2850,7 @@ yyreduce:
}
break;
case 134:
case 133:
#line 726 "a.y"
{
(yyval.addr) = nullgen;
@ -2860,8 +2859,17 @@ yyreduce:
}
break;
case 134:
#line 734 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
(yyval.addr).reg = (yyvsp[(1) - (1)].lval);
}
break;
case 135:
#line 732 "a.y"
#line 740 "a.y"
{
if((yyvsp[(3) - (4)].lval) < 0 || (yyvsp[(3) - (4)].lval) >= 1024)
yyerror("SPR/DCR out of range");
@ -2872,15 +2880,6 @@ yyreduce:
break;
case 137:
#line 743 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
(yyval.addr).reg = (yyvsp[(1) - (1)].lval);
}
break;
case 138:
#line 751 "a.y"
{
(yyval.addr) = nullgen;
@ -2889,8 +2888,17 @@ yyreduce:
}
break;
case 138:
#line 759 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
(yyval.addr).reg = (yyvsp[(1) - (1)].lval);
}
break;
case 139:
#line 757 "a.y"
#line 765 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2899,7 +2907,7 @@ yyreduce:
break;
case 140:
#line 765 "a.y"
#line 773 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2908,7 +2916,7 @@ yyreduce:
break;
case 141:
#line 771 "a.y"
#line 779 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2917,7 +2925,7 @@ yyreduce:
break;
case 142:
#line 779 "a.y"
#line 787 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_REG;
@ -2926,7 +2934,7 @@ yyreduce:
break;
case 143:
#line 787 "a.y"
#line 795 "a.y"
{
int mb, me;
uint32 v;
@ -2948,7 +2956,7 @@ yyreduce:
break;
case 144:
#line 808 "a.y"
#line 816 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = (yyvsp[(1) - (1)].lval);
@ -2957,7 +2965,7 @@ yyreduce:
break;
case 145:
#line 814 "a.y"
#line 822 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = -(yyvsp[(2) - (2)].lval);
@ -2966,7 +2974,7 @@ yyreduce:
break;
case 146:
#line 820 "a.y"
#line 828 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = (yyvsp[(1) - (3)].lval);
@ -2975,7 +2983,7 @@ yyreduce:
break;
case 147:
#line 826 "a.y"
#line 834 "a.y"
{
(yyval.addr).type = TYPE_TEXTSIZE;
(yyval.addr).offset = -(yyvsp[(2) - (4)].lval);
@ -2984,7 +2992,7 @@ yyreduce:
break;
case 148:
#line 834 "a.y"
#line 842 "a.y"
{
(yyval.addr) = (yyvsp[(2) - (2)].addr);
(yyval.addr).type = TYPE_CONST;
@ -2992,7 +3000,7 @@ yyreduce:
break;
case 149:
#line 839 "a.y"
#line 847 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_SCONST;
@ -3001,7 +3009,7 @@ yyreduce:
break;
case 150:
#line 847 "a.y"
#line 855 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_FCONST;
@ -3010,7 +3018,7 @@ yyreduce:
break;
case 151:
#line 853 "a.y"
#line 861 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_FCONST;
@ -3019,7 +3027,7 @@ yyreduce:
break;
case 152:
#line 860 "a.y"
#line 868 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_CONST;
@ -3028,7 +3036,7 @@ yyreduce:
break;
case 154:
#line 869 "a.y"
#line 877 "a.y"
{
if((yyval.lval) < 0 || (yyval.lval) >= NREG)
print("register value out of range\n");
@ -3037,7 +3045,7 @@ yyreduce:
break;
case 155:
#line 877 "a.y"
#line 885 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3047,7 +3055,7 @@ yyreduce:
break;
case 156:
#line 884 "a.y"
#line 892 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3058,7 +3066,7 @@ yyreduce:
break;
case 158:
#line 895 "a.y"
#line 903 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3068,7 +3076,7 @@ yyreduce:
break;
case 159:
#line 904 "a.y"
#line 912 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3079,7 +3087,7 @@ yyreduce:
break;
case 160:
#line 912 "a.y"
#line 920 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3090,7 +3098,7 @@ yyreduce:
break;
case 161:
#line 920 "a.y"
#line 928 "a.y"
{
(yyval.addr) = nullgen;
(yyval.addr).type = TYPE_MEM;
@ -3101,126 +3109,126 @@ yyreduce:
break;
case 164:
#line 932 "a.y"
#line 940 "a.y"
{
(yyval.lval) = 0;
}
break;
case 165:
#line 936 "a.y"
#line 944 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (2)].lval);
}
break;
case 166:
#line 940 "a.y"
#line 948 "a.y"
{
(yyval.lval) = -(yyvsp[(2) - (2)].lval);
}
break;
case 171:
#line 952 "a.y"
#line 960 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (1)].sym)->value;
}
break;
case 172:
#line 956 "a.y"
#line 964 "a.y"
{
(yyval.lval) = -(yyvsp[(2) - (2)].lval);
}
break;
case 173:
#line 960 "a.y"
#line 968 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (2)].lval);
}
break;
case 174:
#line 964 "a.y"
#line 972 "a.y"
{
(yyval.lval) = ~(yyvsp[(2) - (2)].lval);
}
break;
case 175:
#line 968 "a.y"
#line 976 "a.y"
{
(yyval.lval) = (yyvsp[(2) - (3)].lval);
}
break;
case 177:
#line 975 "a.y"
#line 983 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) + (yyvsp[(3) - (3)].lval);
}
break;
case 178:
#line 979 "a.y"
#line 987 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) - (yyvsp[(3) - (3)].lval);
}
break;
case 179:
#line 983 "a.y"
#line 991 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) * (yyvsp[(3) - (3)].lval);
}
break;
case 180:
#line 987 "a.y"
#line 995 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) / (yyvsp[(3) - (3)].lval);
}
break;
case 181:
#line 991 "a.y"
#line 999 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) % (yyvsp[(3) - (3)].lval);
}
break;
case 182:
#line 995 "a.y"
#line 1003 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (4)].lval) << (yyvsp[(4) - (4)].lval);
}
break;
case 183:
#line 999 "a.y"
#line 1007 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (4)].lval) >> (yyvsp[(4) - (4)].lval);
}
break;
case 184:
#line 1003 "a.y"
#line 1011 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) & (yyvsp[(3) - (3)].lval);
}
break;
case 185:
#line 1007 "a.y"
#line 1015 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) ^ (yyvsp[(3) - (3)].lval);
}
break;
case 186:
#line 1011 "a.y"
#line 1019 "a.y"
{
(yyval.lval) = (yyvsp[(1) - (3)].lval) | (yyvsp[(3) - (3)].lval);
}
@ -3228,7 +3236,7 @@ yyreduce:
/* Line 1267 of yacc.c. */
#line 3232 "y.tab.c"
#line 3240 "y.tab.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);

View file

@ -12,8 +12,6 @@
// TODO(minux): Remove when no longer used.
#define noimpl sysfatal("%s not implemented (%s:%d).", __func__, __FILE__, __LINE__)
#define TEXTFLAG reg
EXTERN int32 dynloc;
EXTERN uchar reg[NREG+NFREG];
EXTERN int32 pcloc; // instruction counter

View file

@ -200,9 +200,9 @@ ggloblnod(Node *nam)
p->to.type = TYPE_CONST;
p->to.offset = nam->type->width;
if(nam->readonly)
p->reg = RODATA;
p->from3.offset = RODATA;
if(nam->type != T && !haspointers(nam->type))
p->reg |= NOPTR;
p->from3.offset |= NOPTR;
}
void
@ -228,7 +228,7 @@ ggloblsym(Sym *s, int32 width, int8 flags)
p->to.type = TYPE_CONST;
p->to.name = NAME_NONE;
p->to.offset = width;
p->reg = flags;
p->from3.offset = flags;
}
int

View file

@ -231,20 +231,20 @@ compile(Node *fn)
nodconst(&nod1, types[TINT32], 0);
ptxt = arch.gins(arch.ATEXT, isblank(curfn->nname) ? N : curfn->nname, &nod1);
if(fn->dupok)
arch.thelinkarch->settextflag(ptxt, arch.thelinkarch->textflag(ptxt) | DUPOK);
ptxt->from3.offset |= DUPOK;
if(fn->wrapper)
arch.thelinkarch->settextflag(ptxt, arch.thelinkarch->textflag(ptxt) | WRAPPER);
ptxt->from3.offset |= WRAPPER;
if(fn->needctxt)
arch.thelinkarch->settextflag(ptxt, arch.thelinkarch->textflag(ptxt) | NEEDCTXT);
ptxt->from3.offset |= NEEDCTXT;
if(fn->nosplit)
arch.thelinkarch->settextflag(ptxt, arch.thelinkarch->textflag(ptxt) | NOSPLIT);
ptxt->from3.offset |= NOSPLIT;
// Clumsy but important.
// See test/recover.go for test cases and src/reflect/value.go
// for the actual functions being considered.
if(myimportpath != nil && strcmp(myimportpath, "reflect") == 0) {
if(strcmp(curfn->nname->sym->name, "callReflect") == 0 || strcmp(curfn->nname->sym->name, "callMethod") == 0)
arch.thelinkarch->settextflag(ptxt, arch.thelinkarch->textflag(ptxt) | WRAPPER);
ptxt->from3.offset |= WRAPPER;
}
arch.afunclit(&ptxt->from, curfn->nname);

View file

@ -72,7 +72,6 @@ static Optab optab[] =
/* struct Optab:
OPCODE, from, prog->reg, to, type,size,param,flag */
{ ATEXT, C_ADDR, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_TEXTSIZE, 0, 0, 0 },
{ AADD, C_REG, C_REG, C_REG, 1, 4, 0 },
{ AADD, C_REG, C_NONE, C_REG, 1, 4, 0 },

View file

@ -60,13 +60,9 @@ struct Optab
static Optab optab[] = {
{ ATEXT, C_LEXT, C_NONE, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_REG, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_NONE, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_REG, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_NONE, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_NONE, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_LCON, C_TEXTSIZE, 0, 0, 0 },
/* move register */
{ AMOVD, C_REG, C_NONE, C_NONE, C_REG, 1, 4, 0 },

View file

@ -112,7 +112,7 @@ Pconv(Fmt *fp)
sprint(str, "%.5lld (%L) %A %D/%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else
if(p->as == ATEXT)
sprint(str, "%.5lld (%L) %A %D,%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
sprint(str, "%.5lld (%L) %A %D,%lld,%D", p->pc, p->lineno, a, &p->from, p->from3.offset, &p->to);
else
if(p->reg == 0)
sprint(str, "%.5lld (%L) %A%s %D,%D", p->pc, p->lineno, a, sc, &p->from, &p->to);

View file

@ -90,9 +90,9 @@ Pconv(Fmt *fp)
break;
case ATEXT:
if(p->from.scale) {
sprint(str, "%.5lld (%L) %A %D,%d,%D",
p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to);
if(p->from3.offset) {
sprint(str, "%.5lld (%L) %A %D,%lld,%D",
p->pc, p->lineno, p->as, &p->from, p->from3.offset, &p->to);
break;
}
sprint(str, "%.5lld (%L) %A %D,%D",

View file

@ -77,9 +77,9 @@ Pconv(Fmt *fp)
break;
case ATEXT:
if(p->from.scale) {
sprint(str, "%.5lld (%L) %A %D,%d,%D",
p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to);
if(p->from3.offset) {
sprint(str, "%.5lld (%L) %A %D,%lld,%D",
p->pc, p->lineno, p->as, &p->from, p->from3.offset, &p->to);
break;
}
sprint(str, "%.5lld (%L) %A %D,%D",

View file

@ -95,14 +95,9 @@ Pconv(Fmt *fp)
str[0] = 0;
if(a == ADATA || a == AINIT || a == ADYNT)
sprint(str, "%.5lld (%L) %A %D/%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else if(a == ATEXT) {
if(p->reg != 0)
sprint(str, "%.5lld (%L) %A %D,%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else
sprint(str, "%.5lld (%L) %A %D,%D", p->pc, p->lineno, a, &p->from, &p->to);
} else if(a == AGLOBL) {
if(p->reg != 0)
sprint(str, "%.5lld (%L) %A %D,%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else if(a == ATEXT || a == AGLOBL) {
if(p->from3.offset != 0)
sprint(str, "%.5lld (%L) %A %D,%lld,%D", p->pc, p->lineno, a, &p->from, p->from3.offset, &p->to);
else
sprint(str, "%.5lld (%L) %A %D,%D", p->pc, p->lineno, a, &p->from, &p->to);
} else {

View file

@ -58,18 +58,6 @@ datasize(Prog *p)
return p->reg;
}
static int
textflag(Prog *p)
{
return p->reg;
}
static void
settextflag(Prog *p, int f)
{
p->reg = f;
}
static void
progedit(Link *ctxt, Prog *p)
{
@ -268,7 +256,7 @@ preprocess(Link *ctxt, LSym *cursym)
cursym->args = p->to.u.argsize;
if(ctxt->debugzerostack) {
if(autoffset && !(p->reg&NOSPLIT)) {
if(autoffset && !(p->from3.offset&NOSPLIT)) {
// MOVW $4(R13), R1
p = appendp(ctxt, p);
p->as = AMOVW;
@ -421,8 +409,8 @@ preprocess(Link *ctxt, LSym *cursym)
break;
}
if(!(p->reg & NOSPLIT))
p = stacksplit(ctxt, p, autosize, !(cursym->text->reg&NEEDCTXT)); // emit split check
if(!(p->from3.offset & NOSPLIT))
p = stacksplit(ctxt, p, autosize, !(cursym->text->from3.offset&NEEDCTXT)); // emit split check
// MOVW.W R14,$-autosize(SP)
p = appendp(ctxt, p);
@ -435,7 +423,7 @@ preprocess(Link *ctxt, LSym *cursym)
p->to.reg = REGSP;
p->spadj = autosize;
if(cursym->text->reg & WRAPPER) {
if(cursym->text->from3.offset & WRAPPER) {
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
//
// MOVW g_panic(g), R1
@ -1048,8 +1036,6 @@ LinkArch linkarm = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 4,
.ptrsize = 4,

View file

@ -78,18 +78,6 @@ datasize(Prog *p)
return p->from.scale;
}
static int
textflag(Prog *p)
{
return p->from.scale;
}
static void
settextflag(Prog *p, int f)
{
p->from.scale = f;
}
static void nacladdr(Link*, Prog*, Addr*);
static int
@ -404,24 +392,24 @@ preprocess(Link *ctxt, LSym *cursym)
cursym->args = textarg;
cursym->locals = p->to.offset;
if(autoffset < StackSmall && !(p->from.scale & NOSPLIT)) {
if(autoffset < StackSmall && !(p->from3.offset & NOSPLIT)) {
for(q = p; q != nil; q = q->link) {
if(q->as == ACALL)
goto noleaf;
if((q->as == ADUFFCOPY || q->as == ADUFFZERO) && autoffset >= StackSmall - 8)
goto noleaf;
}
p->from.scale |= NOSPLIT;
p->from3.offset |= NOSPLIT;
noleaf:;
}
q = nil;
if(!(p->from.scale & NOSPLIT) || (p->from.scale & WRAPPER)) {
if(!(p->from3.offset & NOSPLIT) || (p->from3.offset & WRAPPER)) {
p = appendp(ctxt, p);
p = load_g_cx(ctxt, p); // load g into CX
}
if(!(cursym->text->from.scale & NOSPLIT))
p = stacksplit(ctxt, p, autoffset, textarg, !(cursym->text->from.scale&NEEDCTXT), &q); // emit split check
if(!(cursym->text->from3.offset & NOSPLIT))
p = stacksplit(ctxt, p, autoffset, textarg, !(cursym->text->from3.offset&NEEDCTXT), &q); // emit split check
if(autoffset) {
if(autoffset%ctxt->arch->regsize != 0)
@ -468,7 +456,7 @@ preprocess(Link *ctxt, LSym *cursym)
p->to.reg = REG_BP;
}
if(cursym->text->from.scale & WRAPPER) {
if(cursym->text->from3.offset & WRAPPER) {
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
//
// MOVQ g_panic(CX), BX
@ -564,7 +552,7 @@ preprocess(Link *ctxt, LSym *cursym)
p2->pcond = p;
}
if(ctxt->debugzerostack && autoffset && !(cursym->text->from.scale&NOSPLIT)) {
if(ctxt->debugzerostack && autoffset && !(cursym->text->from3.offset&NOSPLIT)) {
// 6l -Z means zero the stack frame on entry.
// This slows down function calls but can help avoid
// false positives in garbage collection.
@ -1093,8 +1081,6 @@ LinkArch linkamd64 = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 1,
.ptrsize = 8,
@ -1127,8 +1113,6 @@ LinkArch linkamd64p32 = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 1,
.ptrsize = 4,

View file

@ -68,18 +68,6 @@ datasize(Prog *p)
return p->from.scale;
}
static int
textflag(Prog *p)
{
return p->from.scale;
}
static void
settextflag(Prog *p, int f)
{
p->from.scale = f;
}
static int
canuselocaltls(Link *ctxt)
{
@ -302,12 +290,12 @@ preprocess(Link *ctxt, LSym *cursym)
q = nil;
if(!(p->from.scale & NOSPLIT) || (p->from.scale & WRAPPER)) {
if(!(p->from3.offset & NOSPLIT) || (p->from3.offset & WRAPPER)) {
p = appendp(ctxt, p);
p = load_g_cx(ctxt, p); // load g into CX
}
if(!(cursym->text->from.scale & NOSPLIT))
p = stacksplit(ctxt, p, autoffset, !(cursym->text->from.scale&NEEDCTXT), &q); // emit split check
if(!(cursym->text->from3.offset & NOSPLIT))
p = stacksplit(ctxt, p, autoffset, !(cursym->text->from3.offset&NEEDCTXT), &q); // emit split check
if(autoffset) {
p = appendp(ctxt, p);
@ -330,7 +318,7 @@ preprocess(Link *ctxt, LSym *cursym)
q->pcond = p;
deltasp = autoffset;
if(cursym->text->from.scale & WRAPPER) {
if(cursym->text->from3.offset & WRAPPER) {
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
//
// MOVL g_panic(CX), BX
@ -401,7 +389,7 @@ preprocess(Link *ctxt, LSym *cursym)
p2->pcond = p;
}
if(ctxt->debugzerostack && autoffset && !(cursym->text->from.scale&NOSPLIT)) {
if(ctxt->debugzerostack && autoffset && !(cursym->text->from3.offset&NOSPLIT)) {
// 8l -Z means zero the stack frame on entry.
// This slows down function calls but can help avoid
// false positives in garbage collection.
@ -894,8 +882,6 @@ LinkArch link386 = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 1,
.ptrsize = 4,

View file

@ -57,18 +57,6 @@ datasize(Prog *p)
return p->reg;
}
static int
textflag(Prog *p)
{
return p->reg;
}
static void
settextflag(Prog *p, int f)
{
p->reg = f;
}
static void
progedit(Link *ctxt, Prog *p)
{
@ -367,8 +355,8 @@ preprocess(Link *ctxt, LSym *cursym)
autosize += 4;
p->to.offset = autosize-8;
if(!(p->reg & NOSPLIT))
p = stacksplit(ctxt, p, autosize, !(cursym->text->reg&NEEDCTXT)); // emit split check
if(!(p->from3.offset & NOSPLIT))
p = stacksplit(ctxt, p, autosize, !(cursym->text->from3.offset&NEEDCTXT)); // emit split check
q = p;
if(autosize) {
@ -420,7 +408,7 @@ preprocess(Link *ctxt, LSym *cursym)
if(q->as == AMOVDU)
q->spadj = -aoffset;
if(cursym->text->reg & WRAPPER) {
if(cursym->text->from3.offset & WRAPPER) {
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
//
// MOVD g_panic(g), R3
@ -970,8 +958,6 @@ LinkArch linkppc64 = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 4,
.ptrsize = 8,
@ -1004,8 +990,6 @@ LinkArch linkppc64le = {
.isdata = isdata,
.prg = prg,
.progedit = progedit,
.settextflag = settextflag,
.textflag = textflag,
.minlc = 4,
.ptrsize = 8,

View file

@ -189,7 +189,7 @@ writeobj(Link *ctxt, Biobuf *b)
s->size = p->to.offset;
if(s->type == 0 || s->type == SXREF)
s->type = SBSS;
flag = ctxt->arch->textflag(p);
flag = p->from3.offset;
if(flag & DUPOK)
s->dupok = 1;
if(flag & RODATA)
@ -222,7 +222,7 @@ writeobj(Link *ctxt, Biobuf *b)
else
etext->next = s;
etext = s;
flag = ctxt->arch->textflag(p);
flag = p->from3.offset;
if(flag & DUPOK)
s->dupok = 1;
if(flag & NOSPLIT)