1
0
mirror of https://github.com/golang/go synced 2024-11-18 16:44:43 -07:00

liblink: use same TEXT $frame-arg encoding for all architectures

Change-Id: I3417a8c5ddd7f405939edc9fdef086e4741495a1
Reviewed-on: https://go-review.googlesource.com/3571
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Russ Cox 2015-01-29 12:26:21 -05:00
parent a293c7e68f
commit 72521319c7
25 changed files with 2114 additions and 2063 deletions

View File

@ -62,7 +62,7 @@
%token <sym> LNAME LLAB LVAR %token <sym> LNAME LLAB LVAR
%type <lval> con expr oexpr pointer offset sreg spreg creg %type <lval> con expr oexpr pointer offset sreg spreg creg
%type <lval> rcon cond reglist %type <lval> rcon cond reglist
%type <addr> gen rel reg regreg freg shift fcon frcon %type <addr> gen rel reg regreg freg shift fcon frcon textsize
%type <addr> imm ximm name oreg ireg nireg ioreg imsr %type <addr> imm ximm name oreg ireg nireg ioreg imsr
%% %%
prog: prog:
@ -212,26 +212,15 @@ inst:
/* /*
* TEXT * TEXT
*/ */
| LTYPEB name ',' imm | LTYPEB name ',' '$' textsize
{ {
settext($2.sym); settext($2.sym);
$4.type = TYPE_TEXTSIZE; outcode($1, Always, &$2, 0, &$5);
$4.u.argsize = ArgsSizeUnknown;
outcode($1, Always, &$2, 0, &$4);
} }
| LTYPEB name ',' con ',' imm | LTYPEB name ',' con ',' '$' textsize
{ {
settext($2.sym); settext($2.sym);
$6.type = TYPE_TEXTSIZE; outcode($1, Always, &$2, $4, &$7);
$6.u.argsize = ArgsSizeUnknown;
outcode($1, Always, &$2, $4, &$6);
}
| LTYPEB name ',' con ',' imm '-' con
{
settext($2.sym);
$6.type = TYPE_TEXTSIZE;
$6.u.argsize = $8;
outcode($1, Always, &$2, $4, &$6);
} }
/* /*
* GLOBL * GLOBL
@ -393,6 +382,32 @@ rel:
$$.offset = $1->value + $2; $$.offset = $1->value + $2;
} }
textsize:
LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = $1;
$$.u.argsize = ArgsSizeUnknown;
}
| '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = -$2;
$$.u.argsize = ArgsSizeUnknown;
}
| LCONST '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = $1;
$$.u.argsize = $3;
}
| '-' LCONST '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = -$2;
$$.u.argsize = $4;
}
ximm: '$' con ximm: '$' con
{ {
$$ = nullgen; $$ = nullgen;

File diff suppressed because it is too large Load Diff

View File

@ -21,12 +21,10 @@ defframe(Prog *ptxt)
NodeList *l; NodeList *l;
Node *n; Node *n;
// fill in argument size // fill in argument size, stack size
ptxt->to.type = TYPE_TEXTSIZE; ptxt->to.type = TYPE_TEXTSIZE;
ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr); ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr);
frame = rnd(stksize+maxarg, widthreg);
// fill in final stack size
frame = rnd(stksize+maxarg, widthptr);
ptxt->to.offset = frame; ptxt->to.offset = frame;
// insert code to contain ambiguously live variables // insert code to contain ambiguously live variables

View File

@ -149,6 +149,7 @@ enum
C_HREG, C_HREG,
C_ADDR, /* reference to relocatable address */ C_ADDR, /* reference to relocatable address */
C_TEXTSIZE,
C_GOK, C_GOK,

View File

@ -57,8 +57,8 @@
%token <dval> LFCONST %token <dval> LFCONST
%token <sval> LSCONST LSP %token <sval> LSCONST LSP
%token <sym> LNAME LLAB LVAR %token <sym> LNAME LLAB LVAR
%type <lval> con con2 expr pointer offset %type <lval> con expr pointer offset
%type <addr> mem imm imm2 reg nam rel rem rim rom omem nmem %type <addr> mem imm reg nam rel rem rim rom omem nmem textsize
%type <addr2> nonnon nonrel nonrem rimnon rimrem remrim %type <addr2> nonnon nonrel nonrem rimnon rimrem remrim
%type <addr2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 %type <addr2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%type <addr2> spec10 spec11 spec12 spec13 %type <addr2> spec10 spec11 spec12 spec13
@ -191,18 +191,18 @@ spec1: /* DATA */
} }
spec2: /* TEXT */ spec2: /* TEXT */
mem ',' imm2 mem ',' '$' textsize
{ {
settext($1.sym); settext($1.sym);
$$.from = $1; $$.from = $1;
$$.to = $3; $$.to = $4;
} }
| mem ',' con ',' imm2 | mem ',' con ',' '$' textsize
{ {
settext($1.sym); settext($1.sym);
$$.from = $1; $$.from = $1;
$$.from.scale = $3; $$.from.scale = $3;
$$.to = $5; $$.to = $6;
} }
spec3: /* JMP/CALL */ spec3: /* JMP/CALL */
@ -412,13 +412,6 @@ reg:
$$.type = TYPE_REG; $$.type = TYPE_REG;
$$.reg = $1; $$.reg = $1;
} }
imm2:
'$' con2
{
$$ = nullgen;
$$.type = TYPE_CONST;
$$.offset = $2;
}
imm: imm:
'$' con '$' con
@ -634,26 +627,30 @@ con:
$$ = $2; $$ = $2;
} }
con2: textsize:
LCONST LCONST
{ {
$$ = ($1 & 0xffffffffLL) + $$.type = TYPE_TEXTSIZE;
((vlong)ArgsSizeUnknown << 32); $$.offset = $1;
$$.u.argsize = ArgsSizeUnknown;
} }
| '-' LCONST | '-' LCONST
{ {
$$ = (-$2 & 0xffffffffLL) + $$.type = TYPE_TEXTSIZE;
((vlong)ArgsSizeUnknown << 32); $$.offset = -$2;
$$.u.argsize = ArgsSizeUnknown;
} }
| LCONST '-' LCONST | LCONST '-' LCONST
{ {
$$ = ($1 & 0xffffffffLL) + $$.type = TYPE_TEXTSIZE;
(($3 & 0xffffLL) << 32); $$.offset = $1;
$$.u.argsize = $3;
} }
| '-' LCONST '-' LCONST | '-' LCONST '-' LCONST
{ {
$$ = (-$2 & 0xffffffffLL) + $$.type = TYPE_TEXTSIZE;
(($4 & 0xffffLL) << 32); $$.offset = -$2;
$$.u.argsize = $4;
} }
expr: expr:

File diff suppressed because it is too large Load Diff

View File

@ -21,13 +21,11 @@ defframe(Prog *ptxt)
NodeList *l; NodeList *l;
Node *n; Node *n;
// fill in argument size // fill in argument size, stack size
ptxt->to.offset = rnd(curfn->type->argwid, widthptr); ptxt->to.type = TYPE_TEXTSIZE;
ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr);
// fill in final stack size
ptxt->to.offset <<= 32;
frame = rnd(stksize+maxarg, widthreg); frame = rnd(stksize+maxarg, widthreg);
ptxt->to.offset |= frame; ptxt->to.offset = frame;
// insert code to zero ambiguously live variables // insert code to zero ambiguously live variables
// so that the garbage collector only sees initialized values // so that the garbage collector only sees initialized values

View File

@ -38,10 +38,6 @@
%union { %union {
Sym *sym; Sym *sym;
int32 lval; int32 lval;
struct {
int32 v1;
int32 v2;
} con2;
double dval; double dval;
char sval[8]; char sval[8];
Addr addr; Addr addr;
@ -61,8 +57,7 @@
%token <sval> LSCONST LSP %token <sval> LSCONST LSP
%token <sym> LNAME LLAB LVAR %token <sym> LNAME LLAB LVAR
%type <lval> con expr pointer offset %type <lval> con expr pointer offset
%type <con2> con2 %type <addr> mem imm reg nam rel rem rim rom omem nmem textsize
%type <addr> mem imm imm2 reg nam rel rem rim rom omem nmem
%type <addr2> nonnon nonrel nonrem rimnon rimrem remrim %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 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 spec10 spec11 spec12
%% %%
@ -193,18 +188,18 @@ spec1: /* DATA */
} }
spec2: /* TEXT */ spec2: /* TEXT */
mem ',' imm2 mem ',' '$' textsize
{ {
settext($1.sym); settext($1.sym);
$$.from = $1; $$.from = $1;
$$.to = $3; $$.to = $4;
} }
| mem ',' con ',' imm2 | mem ',' con ',' '$' textsize
{ {
settext($1.sym); settext($1.sym);
$$.from = $1; $$.from = $1;
$$.from.scale = $3; $$.from.scale = $3;
$$.to = $5; $$.to = $6;
} }
spec3: /* JMP/CALL */ spec3: /* JMP/CALL */
@ -453,35 +448,30 @@ imm:
$$.u.dval = -$3; $$.u.dval = -$3;
} }
imm2: textsize:
'$' con2
{
$$ = nullgen;
$$.type = TYPE_TEXTSIZE;
$$.offset = $2.v1;
$$.u.argsize = $2.v2;
}
con2:
LCONST LCONST
{ {
$$.v1 = $1; $$.type = TYPE_TEXTSIZE;
$$.v2 = ArgsSizeUnknown; $$.offset = $1;
$$.u.argsize = ArgsSizeUnknown;
} }
| '-' LCONST | '-' LCONST
{ {
$$.v1 = -$2; $$.type = TYPE_TEXTSIZE;
$$.v2 = ArgsSizeUnknown; $$.offset = -$2;
$$.u.argsize = ArgsSizeUnknown;
} }
| LCONST '-' LCONST | LCONST '-' LCONST
{ {
$$.v1 = $1; $$.type = TYPE_TEXTSIZE;
$$.v2 = $3; $$.offset = $1;
$$.u.argsize = $3;
} }
| '-' LCONST '-' LCONST | '-' LCONST '-' LCONST
{ {
$$.v1 = -$2; $$.type = TYPE_TEXTSIZE;
$$.v2 = $4; $$.offset = -$2;
$$.u.argsize = $4;
} }
mem: mem:

File diff suppressed because it is too large Load Diff

View File

@ -118,17 +118,13 @@ typedef union YYSTYPE
{ {
Sym *sym; Sym *sym;
int32 lval; int32 lval;
struct {
int32 v1;
int32 v2;
} con2;
double dval; double dval;
char sval[8]; char sval[8];
Addr addr; Addr addr;
Addr2 addr2; Addr2 addr2;
} }
/* Line 1529 of yacc.c. */ /* Line 1529 of yacc.c. */
#line 132 "y.tab.h" #line 128 "y.tab.h"
YYSTYPE; YYSTYPE;
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_DECLARED 1

View File

@ -21,11 +21,10 @@ defframe(Prog *ptxt)
NodeList *l; NodeList *l;
Node *n; Node *n;
// fill in argument size // fill in argument size, stack size
ptxt->to.type = TYPE_TEXTSIZE;
ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr); ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr);
frame = rnd(stksize+maxarg, widthreg);
// fill in final stack size
frame = rnd(stksize+maxarg, widthptr);
ptxt->to.offset = frame; ptxt->to.offset = frame;
// insert code to zero ambiguously live variables // insert code to zero ambiguously live variables

View File

@ -60,7 +60,7 @@
%token <sval> LSCONST %token <sval> LSCONST
%token <sym> LNAME LLAB LVAR %token <sym> LNAME LLAB LVAR
%type <lval> con expr pointer offset sreg %type <lval> con expr pointer offset sreg
%type <addr> addr rreg regaddr name creg freg xlreg lr ctr %type <addr> addr rreg regaddr name creg freg xlreg lr ctr textsize
%type <addr> imm ximm fimm rel psr lcr cbit fpscr msr mask %type <addr> imm ximm fimm rel psr lcr cbit fpscr msr mask
%% %%
prog: prog:
@ -613,24 +613,15 @@ inst:
/* /*
* TEXT * TEXT
*/ */
| LTEXT name ',' imm | LTEXT name ',' '$' textsize
{ {
settext($2.sym); settext($2.sym);
outcode($1, &$2, 0, &$4); outcode($1, &$2, 0, &$5);
} }
| LTEXT name ',' con ',' imm | LTEXT name ',' con ',' '$' textsize
{ {
settext($2.sym); settext($2.sym);
$6.offset &= 0xffffffffull; outcode($1, &$2, $4, &$7);
$6.offset |= (vlong)ArgsSizeUnknown << 32;
outcode($1, &$2, $4, &$6);
}
| LTEXT name ',' con ',' imm '-' con
{
settext($2.sym);
$6.offset &= 0xffffffffull;
$6.offset |= ($8 & 0xffffffffull) << 32;
outcode($1, &$2, $4, &$6);
} }
/* /*
* GLOBL * GLOBL
@ -812,6 +803,32 @@ mask:
$$.offset = v; $$.offset = v;
} }
textsize:
LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = $1;
$$.u.argsize = ArgsSizeUnknown;
}
| '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = -$2;
$$.u.argsize = ArgsSizeUnknown;
}
| LCONST '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = $1;
$$.u.argsize = $3;
}
| '-' LCONST '-' LCONST
{
$$.type = TYPE_TEXTSIZE;
$$.offset = -$2;
$$.u.argsize = $4;
}
ximm: ximm:
'$' addr '$' addr
{ {

File diff suppressed because it is too large Load Diff

View File

@ -21,13 +21,11 @@ defframe(Prog *ptxt)
NodeList *l; NodeList *l;
Node *n; Node *n;
// fill in argument size // fill in argument size, stack size
ptxt->to.offset = rnd(curfn->type->argwid, widthptr); ptxt->to.type = TYPE_TEXTSIZE;
ptxt->to.u.argsize = rnd(curfn->type->argwid, widthptr);
// fill in final stack size
ptxt->to.offset <<= 32;
frame = rnd(stksize+maxarg, widthreg); frame = rnd(stksize+maxarg, widthreg);
ptxt->to.offset |= frame; ptxt->to.offset = frame;
// insert code to zero ambiguously live variables // insert code to zero ambiguously live variables
// so that the garbage collector only sees initialized values // so that the garbage collector only sees initialized values

View File

@ -286,6 +286,7 @@ enum
C_ANY, C_ANY,
C_GOK, C_GOK,
C_ADDR, C_ADDR,
C_TEXTSIZE,
C_NCLASS, /* must be the last */ C_NCLASS, /* must be the last */
}; };

View File

@ -71,8 +71,8 @@ static Optab optab[] =
{ {
/* struct Optab: /* struct Optab:
OPCODE, from, prog->reg, to, type,size,param,flag */ OPCODE, from, prog->reg, to, type,size,param,flag */
{ ATEXT, C_ADDR, C_NONE, C_LCON, 0, 0, 0 }, { ATEXT, C_ADDR, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_LCON, 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_REG, C_REG, 1, 4, 0 },
{ AADD, C_REG, C_NONE, C_REG, 1, 4, 0 }, { AADD, C_REG, C_NONE, C_REG, 1, 4, 0 },
@ -1122,8 +1122,10 @@ aclass(Link *ctxt, Addr *a)
return C_SFCON; return C_SFCON;
return C_LFCON; return C_LFCON;
case TYPE_CONST:
case TYPE_TEXTSIZE: case TYPE_TEXTSIZE:
return C_TEXTSIZE;
case TYPE_CONST:
switch(a->name) { switch(a->name) {
case TYPE_NONE: case TYPE_NONE:

View File

@ -113,6 +113,7 @@ enum
Ymr, Ymm, Ymr, Ymm,
Yxr, Yxm, Yxr, Yxm,
Ytls, Ytls,
Ytextsize,
Ymax, Ymax,
Zxxx = 0, Zxxx = 0,
@ -197,7 +198,7 @@ static uchar ynone[] =
}; };
static uchar ytext[] = static uchar ytext[] =
{ {
Ymb, Yi64, Zpseudo,1, Ymb, Ytextsize, Zpseudo,1,
0 0
}; };
static uchar ynop[] = static uchar ynop[] =
@ -1998,6 +1999,9 @@ oclass(Link *ctxt, Addr *a)
if((v>>32) == 0) if((v>>32) == 0)
return Yi32; /* unsigned */ return Yi32; /* unsigned */
return Yi64; return Yi64;
case TYPE_TEXTSIZE:
return Ytextsize;
} }
if(a->type != TYPE_REG) { if(a->type != TYPE_REG) {

View File

@ -76,6 +76,7 @@ enum
Ym, Ym,
Ybr, Ybr,
Ycol, Ycol,
Ytextsize,
Ytls, Ytls,
Ycs, Yss, Yds, Yes, Yfs, Ygs, Ycs, Yss, Yds, Yes, Yfs, Ygs,
@ -150,7 +151,7 @@ static uchar ynone[] =
}; };
static uchar ytext[] = static uchar ytext[] =
{ {
Ymb, Yi32, Zpseudo,1, Ymb, Ytextsize, Zpseudo,1,
0 0
}; };
static uchar ynop[] = static uchar ynop[] =
@ -1538,7 +1539,6 @@ oclass(Link *ctxt, Addr *a)
// fall through // fall through
case TYPE_CONST: case TYPE_CONST:
case TYPE_TEXTSIZE:
if(a->sym != nil) if(a->sym != nil)
ctxt->diag("TYPE_CONST with symbol: %D", a); ctxt->diag("TYPE_CONST with symbol: %D", a);
@ -1550,6 +1550,9 @@ oclass(Link *ctxt, Addr *a)
if(v >= -128 && v <= 127) if(v >= -128 && v <= 127)
return Yi8; return Yi8;
return Yi32; return Yi32;
case TYPE_TEXTSIZE:
return Ytextsize;
} }
if(a->type != TYPE_REG) { if(a->type != TYPE_REG) {

View File

@ -59,14 +59,14 @@ struct Optab
}; };
static Optab optab[] = { static Optab optab[] = {
{ ATEXT, C_LEXT, C_NONE, C_NONE, C_LCON, 0, 0, 0 }, { ATEXT, C_LEXT, C_NONE, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_REG, C_NONE, C_LCON, 0, 0, 0 }, { ATEXT, C_LEXT, C_REG, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_NONE, C_LCON, C_LCON, 0, 0, 0 }, { ATEXT, C_LEXT, C_NONE, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_LEXT, C_REG, C_LCON, C_LCON, 0, 0, 0 }, { ATEXT, C_LEXT, C_REG, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_NONE, C_NONE, C_LCON, 0, 0, 0 }, { ATEXT, C_ADDR, C_NONE, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_NONE, C_LCON, 0, 0, 0 }, { ATEXT, C_ADDR, C_REG, C_NONE, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_NONE, C_LCON, C_LCON, 0, 0, 0 }, { ATEXT, C_ADDR, C_NONE, C_LCON, C_TEXTSIZE, 0, 0, 0 },
{ ATEXT, C_ADDR, C_REG, C_LCON, C_LCON, 0, 0, 0 }, { ATEXT, C_ADDR, C_REG, C_LCON, C_TEXTSIZE, 0, 0, 0 },
/* move register */ /* move register */
{ AMOVD, C_REG, C_NONE, C_NONE, C_REG, 1, 4, 0 }, { AMOVD, C_REG, C_NONE, C_NONE, C_REG, 1, 4, 0 },
@ -497,7 +497,7 @@ span9(Link *ctxt, LSym *cursym)
if(p == nil || p->link == nil) // handle external functions and ELF section symbols if(p == nil || p->link == nil) // handle external functions and ELF section symbols
return; return;
ctxt->cursym = cursym; ctxt->cursym = cursym;
ctxt->autosize = (int32)(p->to.offset & 0xffffffffll) + 8; ctxt->autosize = p->to.offset + 8;
if(oprange[AANDN].start == nil) if(oprange[AANDN].start == nil)
buildop(ctxt); buildop(ctxt);
@ -673,6 +673,9 @@ aclass(Link *ctxt, Addr *a)
} }
return C_GOK; return C_GOK;
case TYPE_TEXTSIZE:
return C_TEXTSIZE;
case TYPE_CONST: case TYPE_CONST:
switch(a->name) { switch(a->name) {
case TYPE_NONE: case TYPE_NONE:

View File

@ -33,6 +33,7 @@
#include <bio.h> #include <bio.h>
#include <link.h> #include <link.h>
#include "../cmd/5l/5.out.h" #include "../cmd/5l/5.out.h"
#include "../runtime/funcdata.h"
enum enum
{ {
@ -163,7 +164,10 @@ Dconv(Fmt *fp)
break; break;
case TYPE_TEXTSIZE: case TYPE_TEXTSIZE:
sprint(str, "$%lld-%d", a->offset, a->u.argsize); if(a->u.argsize == ArgsSizeUnknown)
sprint(str, "$%lld", a->offset);
else
sprint(str, "$%lld-%lld", a->offset, a->u.argsize);
break; break;
case TYPE_SHIFT: case TYPE_SHIFT:

View File

@ -33,13 +33,13 @@
#include <bio.h> #include <bio.h>
#include <link.h> #include <link.h>
#include "../cmd/6l/6.out.h" #include "../cmd/6l/6.out.h"
#include "../runtime/funcdata.h"
// //
// Format conversions // Format conversions
// %A int Opcodes (instruction mnemonics) // %A int Opcodes (instruction mnemonics)
// //
// %D Addr* Addresses (instruction operands) // %D Addr* Addresses (instruction operands)
// Flags: "%lD": seperate the high and low words of a constant by "-"
// //
// %P Prog* Instructions // %P Prog* Instructions
// //
@ -91,11 +91,11 @@ Pconv(Fmt *fp)
case ATEXT: case ATEXT:
if(p->from.scale) { if(p->from.scale) {
sprint(str, "%.5lld (%L) %A %D,%d,%lD", sprint(str, "%.5lld (%L) %A %D,%d,%D",
p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to); p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
sprint(str, "%.5lld (%L) %A %D,%lD", sprint(str, "%.5lld (%L) %A %D,%D",
p->pc, p->lineno, p->as, &p->from, &p->to); p->pc, p->lineno, p->as, &p->from, &p->to);
break; break;
@ -194,10 +194,6 @@ Dconv(Fmt *fp)
break; break;
case TYPE_CONST: case TYPE_CONST:
if(fp->flags & FmtLong) {
sprint(str, "$%lld-%lld", a->offset&0xffffffffLL, a->offset>>32);
break;
}
sprint(str, "$%lld", a->offset); sprint(str, "$%lld", a->offset);
// TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as // TODO(rsc): This special case is for SHRQ $32, AX:DX, which encodes as
// SHRQ $32(DX*0), AX // SHRQ $32(DX*0), AX
@ -207,6 +203,13 @@ Dconv(Fmt *fp)
strcat(str, s); strcat(str, s);
} }
break; break;
case TYPE_TEXTSIZE:
if(a->u.argsize == ArgsSizeUnknown)
sprint(str, "$%lld", a->offset);
else
sprint(str, "$%lld-%lld", a->offset, a->u.argsize);
break;
case TYPE_FCONST: case TYPE_FCONST:
sprint(str, "$(%.17g)", a->u.dval); sprint(str, "$(%.17g)", a->u.dval);

View File

@ -33,6 +33,7 @@
#include <bio.h> #include <bio.h>
#include <link.h> #include <link.h>
#include "../cmd/8l/8.out.h" #include "../cmd/8l/8.out.h"
#include "../runtime/funcdata.h"
static int Aconv(Fmt *fp); static int Aconv(Fmt *fp);
static int Dconv(Fmt *fp); static int Dconv(Fmt *fp);
@ -77,11 +78,11 @@ Pconv(Fmt *fp)
case ATEXT: case ATEXT:
if(p->from.scale) { if(p->from.scale) {
sprint(str, "%.5lld (%L) %A %D,%d,%lD", sprint(str, "%.5lld (%L) %A %D,%d,%D",
p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to); p->pc, p->lineno, p->as, &p->from, p->from.scale, &p->to);
break; break;
} }
sprint(str, "%.5lld (%L) %A %D,%lD", sprint(str, "%.5lld (%L) %A %D,%D",
p->pc, p->lineno, p->as, &p->from, &p->to); p->pc, p->lineno, p->as, &p->from, &p->to);
break; break;
@ -198,7 +199,10 @@ Dconv(Fmt *fp)
break; break;
case TYPE_TEXTSIZE: case TYPE_TEXTSIZE:
sprint(str, "$%lld-%d", a->offset, a->u.argsize); if(a->u.argsize == ArgsSizeUnknown)
sprint(str, "$%lld", a->offset);
else
sprint(str, "$%lld-%lld", a->offset, a->u.argsize);
break; break;
case TYPE_FCONST: case TYPE_FCONST:

View File

@ -32,6 +32,7 @@
#include <bio.h> #include <bio.h>
#include <link.h> #include <link.h>
#include "../cmd/9l/9.out.h" #include "../cmd/9l/9.out.h"
#include "../runtime/funcdata.h"
enum enum
{ {
@ -51,7 +52,6 @@ static int DRconv(Fmt*);
// %A int Opcodes (instruction mnemonics) // %A int Opcodes (instruction mnemonics)
// //
// %D Addr* Addresses (instruction operands) // %D Addr* Addresses (instruction operands)
// Flags: "%lD": seperate the high and low words of a constant by "-"
// //
// %P Prog* Instructions // %P Prog* Instructions
// //
@ -97,9 +97,9 @@ Pconv(Fmt *fp)
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/%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else if(a == ATEXT) { else if(a == ATEXT) {
if(p->reg != 0) if(p->reg != 0)
sprint(str, "%.5lld (%L) %A %D,%d,%lD", p->pc, p->lineno, a, &p->from, p->reg, &p->to); sprint(str, "%.5lld (%L) %A %D,%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
else else
sprint(str, "%.5lld (%L) %A %D,%lD", p->pc, p->lineno, a, &p->from, &p->to); sprint(str, "%.5lld (%L) %A %D,%D", p->pc, p->lineno, a, &p->from, &p->to);
} else if(a == AGLOBL) { } else if(a == AGLOBL) {
if(p->reg != 0) if(p->reg != 0)
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,%d,%D", p->pc, p->lineno, a, &p->from, p->reg, &p->to);
@ -154,16 +154,6 @@ Dconv(Fmt *fp)
a = va_arg(fp->args, Addr*); a = va_arg(fp->args, Addr*);
if(fp->flags & FmtLong) {
if(a->type == TYPE_CONST)
sprint(str, "$%d-%d", (int32)a->offset, (int32)(a->offset>>32));
else {
// ATEXT dst is not constant
sprint(str, "!!%D", a);
}
goto ret;
}
switch(a->type) { switch(a->type) {
default: default:
sprint(str, "GOK-type(%d)", a->type); sprint(str, "GOK-type(%d)", a->type);
@ -182,6 +172,13 @@ Dconv(Fmt *fp)
sprint(str, "$%M", a); sprint(str, "$%M", a);
break; break;
case TYPE_TEXTSIZE:
if(a->u.argsize == ArgsSizeUnknown)
sprint(str, "$%lld", a->offset);
else
sprint(str, "$%lld-%lld", a->offset, a->u.argsize);
break;
case TYPE_MEM: case TYPE_MEM:
if(a->reg != 0) if(a->reg != 0)
sprint(str, "%M(%R)", a, a->reg); sprint(str, "%M(%R)", a, a->reg);
@ -222,7 +219,6 @@ Dconv(Fmt *fp)
break; break;
} }
ret:
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
} }

View File

@ -361,26 +361,13 @@ static Prog* load_g_cx(Link*, Prog*);
static Prog* stacksplit(Link*, Prog*, int32, int32, int, Prog**); static Prog* stacksplit(Link*, Prog*, int32, int32, int, Prog**);
static void indir_cx(Link*, Addr*); static void indir_cx(Link*, Addr*);
static void
parsetextconst(vlong arg, vlong *textstksiz, vlong *textarg)
{
*textstksiz = arg & 0xffffffffLL;
if(*textstksiz & 0x80000000LL)
*textstksiz = -(-*textstksiz & 0xffffffffLL);
*textarg = (arg >> 32) & 0xffffffffLL;
if(*textarg & 0x80000000LL)
*textarg = 0;
*textarg = (*textarg+7) & ~7LL;
}
static void static void
preprocess(Link *ctxt, LSym *cursym) preprocess(Link *ctxt, LSym *cursym)
{ {
Prog *p, *q, *p1, *p2; Prog *p, *q, *p1, *p2;
int32 autoffset, deltasp; int32 autoffset, deltasp;
int a, pcsize, bpsize; int a, pcsize, bpsize;
vlong textstksiz, textarg; vlong textarg;
if(ctxt->tlsg == nil) if(ctxt->tlsg == nil)
ctxt->tlsg = linklookup(ctxt, "runtime.tlsg", 0); ctxt->tlsg = linklookup(ctxt, "runtime.tlsg", 0);
@ -398,8 +385,7 @@ preprocess(Link *ctxt, LSym *cursym)
return; return;
p = cursym->text; p = cursym->text;
parsetextconst(p->to.offset, &textstksiz, &textarg); autoffset = p->to.offset;
autoffset = textstksiz;
if(autoffset < 0) if(autoffset < 0)
autoffset = 0; autoffset = 0;
@ -409,14 +395,14 @@ preprocess(Link *ctxt, LSym *cursym)
// another function, so in that case we omit this. // another function, so in that case we omit this.
bpsize = ctxt->arch->ptrsize; bpsize = ctxt->arch->ptrsize;
autoffset += bpsize; autoffset += bpsize;
textstksiz += bpsize; p->to.offset += bpsize;
p->to.offset = ((uint64)p->to.offset & (0xffffffffull<<32)) | (uint32)autoffset;
} else { } else {
bpsize = 0; bpsize = 0;
} }
cursym->args = p->to.offset>>32; textarg = p->to.u.argsize;
cursym->locals = textstksiz; cursym->args = textarg;
cursym->locals = p->to.offset;
if(autoffset < StackSmall && !(p->from.scale & NOSPLIT)) { if(autoffset < StackSmall && !(p->from.scale & NOSPLIT)) {
for(q = p; q != nil; q = q->link) { for(q = p; q != nil; q = q->link) {

View File

@ -162,25 +162,12 @@ progedit(Link *ctxt, Prog *p)
static Prog* stacksplit(Link*, Prog*, int32, int); static Prog* stacksplit(Link*, Prog*, int32, int);
static void
parsetextconst(vlong arg, vlong *textstksiz, vlong *textarg)
{
*textstksiz = arg & 0xffffffffLL;
if(*textstksiz & 0x80000000LL)
*textstksiz = -(-*textstksiz & 0xffffffffLL);
*textarg = (arg >> 32) & 0xffffffffLL;
if(*textarg & 0x80000000LL)
*textarg = 0;
*textarg = (*textarg+7) & ~7LL;
}
static void static void
preprocess(Link *ctxt, LSym *cursym) preprocess(Link *ctxt, LSym *cursym)
{ {
Prog *p, *q, *p1, *p2, *q1; Prog *p, *q, *p1, *p2, *q1;
int o, mov, aoffset; int o, mov, aoffset;
vlong textstksiz, textarg; vlong textstksiz;
int32 autosize; int32 autosize;
if(ctxt->symmorestack[0] == nil) { if(ctxt->symmorestack[0] == nil) {
@ -195,9 +182,9 @@ preprocess(Link *ctxt, LSym *cursym)
return; return;
p = cursym->text; p = cursym->text;
parsetextconst(p->to.offset, &textstksiz, &textarg); textstksiz = p->to.offset;
cursym->args = p->to.offset>>32; cursym->args = p->to.u.argsize;
cursym->locals = textstksiz; cursym->locals = textstksiz;
/* /*
@ -378,7 +365,7 @@ preprocess(Link *ctxt, LSym *cursym)
else else
if(autosize & 4) if(autosize & 4)
autosize += 4; autosize += 4;
p->to.offset = ((uint64)p->to.offset & (0xffffffffull<<32)) | (uint32)(autosize-8); p->to.offset = autosize-8;
if(!(p->reg & NOSPLIT)) if(!(p->reg & NOSPLIT))
p = stacksplit(ctxt, p, autosize, !(cursym->text->reg&NEEDCTXT)); // emit split check p = stacksplit(ctxt, p, autosize, !(cursym->text->reg&NEEDCTXT)); // emit split check