mirror of https://github.com/golang/go.git
liblink: adjust format verbs to avoid collisions
The %S and %N format verbs are used by cmd/gc to represent Sym and Node structures, respectively. In liblink, these two verbs are used only by the %D format routine and never referenced externally. This change will allow us to delete the duplicated code for the %A, %D, %P, and %R format routines in both the compiler and linker. R=golang-codereviews, rsc CC=golang-codereviews https://golang.org/cl/49720043
This commit is contained in:
parent
f739dae7db
commit
d155f6a309
|
|
@ -41,18 +41,18 @@ enum
|
|||
|
||||
static int Aconv(Fmt *fp);
|
||||
static int Dconv(Fmt *fp);
|
||||
static int Nconv(Fmt *fp);
|
||||
static int Mconv(Fmt *fp);
|
||||
static int Pconv(Fmt *fp);
|
||||
static int Rconv(Fmt *fp);
|
||||
static int Sconv(Fmt *fp);
|
||||
static int DSconv(Fmt *fp);
|
||||
|
||||
void
|
||||
listinit5(void)
|
||||
{
|
||||
fmtinstall('A', Aconv);
|
||||
fmtinstall('P', Pconv);
|
||||
fmtinstall('S', Sconv);
|
||||
fmtinstall('N', Nconv);
|
||||
fmtinstall('$', DSconv);
|
||||
fmtinstall('M', Mconv);
|
||||
fmtinstall('D', Dconv);
|
||||
fmtinstall('R', Rconv);
|
||||
}
|
||||
|
|
@ -139,14 +139,14 @@ Dconv(Fmt *fp)
|
|||
case D_NONE:
|
||||
str[0] = 0;
|
||||
if(a->name != D_NONE || a->reg != NREG || a->sym != nil)
|
||||
sprint(str, "%N(R%d)(NONE)", a, a->reg);
|
||||
sprint(str, "%M(R%d)(NONE)", a, a->reg);
|
||||
break;
|
||||
|
||||
case D_CONST:
|
||||
if(a->reg != NREG)
|
||||
sprint(str, "$%N(R%d)", a, a->reg);
|
||||
sprint(str, "$%M(R%d)", a, a->reg);
|
||||
else
|
||||
sprint(str, "$%N", a);
|
||||
sprint(str, "$%M", a);
|
||||
break;
|
||||
|
||||
case D_CONST2:
|
||||
|
|
@ -166,27 +166,27 @@ Dconv(Fmt *fp)
|
|||
|
||||
case D_OREG:
|
||||
if(a->reg != NREG)
|
||||
sprint(str, "%N(R%d)", a, a->reg);
|
||||
sprint(str, "%M(R%d)", a, a->reg);
|
||||
else
|
||||
sprint(str, "%N", a);
|
||||
sprint(str, "%M", a);
|
||||
break;
|
||||
|
||||
case D_REG:
|
||||
sprint(str, "R%d", a->reg);
|
||||
if(a->name != D_NONE || a->sym != nil)
|
||||
sprint(str, "%N(R%d)(REG)", a, a->reg);
|
||||
sprint(str, "%M(R%d)(REG)", a, a->reg);
|
||||
break;
|
||||
|
||||
case D_FREG:
|
||||
sprint(str, "F%d", a->reg);
|
||||
if(a->name != D_NONE || a->sym != nil)
|
||||
sprint(str, "%N(R%d)(REG)", a, a->reg);
|
||||
sprint(str, "%M(R%d)(REG)", a, a->reg);
|
||||
break;
|
||||
|
||||
case D_PSR:
|
||||
sprint(str, "PSR");
|
||||
if(a->name != D_NONE || a->sym != nil)
|
||||
sprint(str, "%N(PSR)(REG)", a);
|
||||
sprint(str, "%M(PSR)(REG)", a);
|
||||
break;
|
||||
|
||||
case D_BRANCH:
|
||||
|
|
@ -203,7 +203,7 @@ Dconv(Fmt *fp)
|
|||
break;
|
||||
|
||||
case D_SCONST:
|
||||
sprint(str, "$\"%S\"", a->u.sval);
|
||||
sprint(str, "$\"%$\"", a->u.sval);
|
||||
break;
|
||||
}
|
||||
return fmtstrcpy(fp, str);
|
||||
|
|
@ -242,7 +242,7 @@ Rconv(Fmt *fp)
|
|||
}
|
||||
|
||||
static int
|
||||
Sconv(Fmt *fp)
|
||||
DSconv(Fmt *fp)
|
||||
{
|
||||
int i, c;
|
||||
char str[STRINGSZ], *p, *a;
|
||||
|
|
@ -289,7 +289,7 @@ Sconv(Fmt *fp)
|
|||
}
|
||||
|
||||
static int
|
||||
Nconv(Fmt *fp)
|
||||
Mconv(Fmt *fp)
|
||||
{
|
||||
char str[STRINGSZ];
|
||||
Addr *a;
|
||||
|
|
|
|||
|
|
@ -34,11 +34,24 @@
|
|||
#include <link.h>
|
||||
#include "../cmd/6l/6.out.h"
|
||||
|
||||
//
|
||||
// Format conversions
|
||||
// %A int Opcodes (instruction mnemonics)
|
||||
//
|
||||
// %D Addr* Addresses (instruction operands)
|
||||
// Flags: "%lD": seperate the high and low words of a constant by "-"
|
||||
//
|
||||
// %P Prog* Instructions
|
||||
//
|
||||
// %R int Registers
|
||||
//
|
||||
// %$ char* String constant addresses (for internal use only)
|
||||
|
||||
static int Aconv(Fmt *fp);
|
||||
static int Dconv(Fmt *fp);
|
||||
static int Pconv(Fmt *fp);
|
||||
static int Rconv(Fmt *fp);
|
||||
static int Sconv(Fmt *fp);
|
||||
static int DSconv(Fmt *fp);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
@ -50,7 +63,7 @@ listinit6(void)
|
|||
{
|
||||
fmtinstall('A', Aconv);
|
||||
fmtinstall('P', Pconv);
|
||||
fmtinstall('S', Sconv);
|
||||
fmtinstall('$', DSconv);
|
||||
fmtinstall('D', Dconv);
|
||||
fmtinstall('R', Rconv);
|
||||
}
|
||||
|
|
@ -174,7 +187,7 @@ Dconv(Fmt *fp)
|
|||
break;
|
||||
|
||||
case D_SCONST:
|
||||
sprint(str, "$\"%S\"", a->u.sval);
|
||||
sprint(str, "$\"%$\"", a->u.sval);
|
||||
break;
|
||||
|
||||
case D_ADDR:
|
||||
|
|
@ -337,7 +350,7 @@ Rconv(Fmt *fp)
|
|||
}
|
||||
|
||||
static int
|
||||
Sconv(Fmt *fp)
|
||||
DSconv(Fmt *fp)
|
||||
{
|
||||
int i, c;
|
||||
char str[STRINGSZ], *p, *a;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ static int Aconv(Fmt *fp);
|
|||
static int Dconv(Fmt *fp);
|
||||
static int Pconv(Fmt *fp);
|
||||
static int Rconv(Fmt *fp);
|
||||
static int Sconv(Fmt *fp);
|
||||
static int DSconv(Fmt *fp);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
@ -50,7 +50,7 @@ listinit8(void)
|
|||
{
|
||||
fmtinstall('A', Aconv);
|
||||
fmtinstall('P', Pconv);
|
||||
fmtinstall('S', Sconv);
|
||||
fmtinstall('$', DSconv);
|
||||
fmtinstall('D', Dconv);
|
||||
fmtinstall('R', Rconv);
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ Dconv(Fmt *fp)
|
|||
break;
|
||||
|
||||
case D_SCONST:
|
||||
sprint(str, "$\"%S\"", a->u.sval);
|
||||
sprint(str, "$\"%$\"", a->u.sval);
|
||||
break;
|
||||
|
||||
case D_ADDR:
|
||||
|
|
@ -298,7 +298,7 @@ Rconv(Fmt *fp)
|
|||
}
|
||||
|
||||
static int
|
||||
Sconv(Fmt *fp)
|
||||
DSconv(Fmt *fp)
|
||||
{
|
||||
int i, c;
|
||||
char str[STRINGSZ], *p, *a;
|
||||
|
|
|
|||
Loading…
Reference in New Issue