Commit 72521319 authored by Russ Cox's avatar Russ Cox

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

Change-Id: I3417a8c5ddd7f405939edc9fdef086e4741495a1
Reviewed-on: https://go-review.googlesource.com/3571Reviewed-by: default avatarAustin Clements <austin@google.com>
parent a293c7e6
...@@ -62,7 +62,7 @@ ...@@ -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: ...@@ -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: ...@@ -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;
......
This diff is collapsed.
...@@ -21,12 +21,10 @@ defframe(Prog *ptxt) ...@@ -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
......
...@@ -149,6 +149,7 @@ enum ...@@ -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,
......
...@@ -57,8 +57,8 @@ ...@@ -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 */ ...@@ -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: ...@@ -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: ...@@ -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:
......
This diff is collapsed.
...@@ -21,13 +21,11 @@ defframe(Prog *ptxt) ...@@ -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
......
...@@ -38,10 +38,6 @@ ...@@ -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 @@ ...@@ -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 */ ...@@ -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: ...@@ -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:
......
This diff is collapsed.
...@@ -118,17 +118,13 @@ typedef union YYSTYPE ...@@ -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
......
...@@ -21,11 +21,10 @@ defframe(Prog *ptxt) ...@@ -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
......
...@@ -60,7 +60,7 @@ ...@@ -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: ...@@ -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
{
settext($2.sym);
$6.offset &= 0xffffffffull;
$6.offset |= (vlong)ArgsSizeUnknown << 32;
outcode($1, &$2, $4, &$6);
} }
| LTEXT name ',' con ',' imm '-' con | LTEXT name ',' con ',' '$' textsize
{ {
settext($2.sym); settext($2.sym);
$6.offset &= 0xffffffffull; outcode($1, &$2, $4, &$7);
$6.offset |= ($8 & 0xffffffffull) << 32;
outcode($1, &$2, $4, &$6);
} }
/* /*
* GLOBL * GLOBL
...@@ -812,6 +803,32 @@ mask: ...@@ -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
{ {
......
This diff is collapsed.
...@@ -21,13 +21,11 @@ defframe(Prog *ptxt) ...@@ -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
......
...@@ -286,6 +286,7 @@ enum ...@@ -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 */
}; };
......
...@@ -71,8 +71,8 @@ static Optab optab[] = ...@@ -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) ...@@ -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:
......
...@@ -113,6 +113,7 @@ enum ...@@ -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[] = ...@@ -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) ...@@ -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) {
......
...@@ -76,6 +76,7 @@ enum ...@@ -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[] = ...@@ -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) ...@@ -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) ...@@ -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) {
......
...@@ -59,14 +59,14 @@ struct Optab ...@@ -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) ...@@ -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) ...@@ -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:
......
...@@ -33,6 +33,7 @@ ...@@ -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) ...@@ -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:
......
...@@ -33,13 +33,13 @@ ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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);
......
...@@ -33,6 +33,7 @@ ...@@ -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) ...@@ -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) ...@@ -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:
......
...@@ -32,6 +32,7 @@ ...@@ -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*); ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -222,7 +219,6 @@ Dconv(Fmt *fp)
break; break;
} }
ret:
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
} }
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment