Commit d155f6a3 authored by Anthony Martin's avatar Anthony Martin

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
parent f739dae7
...@@ -41,18 +41,18 @@ enum ...@@ -41,18 +41,18 @@ enum
static int Aconv(Fmt *fp); static int Aconv(Fmt *fp);
static int Dconv(Fmt *fp); static int Dconv(Fmt *fp);
static int Nconv(Fmt *fp); static int Mconv(Fmt *fp);
static int Pconv(Fmt *fp); static int Pconv(Fmt *fp);
static int Rconv(Fmt *fp); static int Rconv(Fmt *fp);
static int Sconv(Fmt *fp); static int DSconv(Fmt *fp);
void void
listinit5(void) listinit5(void)
{ {
fmtinstall('A', Aconv); fmtinstall('A', Aconv);
fmtinstall('P', Pconv); fmtinstall('P', Pconv);
fmtinstall('S', Sconv); fmtinstall('$', DSconv);
fmtinstall('N', Nconv); fmtinstall('M', Mconv);
fmtinstall('D', Dconv); fmtinstall('D', Dconv);
fmtinstall('R', Rconv); fmtinstall('R', Rconv);
} }
...@@ -139,14 +139,14 @@ Dconv(Fmt *fp) ...@@ -139,14 +139,14 @@ Dconv(Fmt *fp)
case D_NONE: case D_NONE:
str[0] = 0; str[0] = 0;
if(a->name != D_NONE || a->reg != NREG || a->sym != nil) 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; break;
case D_CONST: case D_CONST:
if(a->reg != NREG) if(a->reg != NREG)
sprint(str, "$%N(R%d)", a, a->reg); sprint(str, "$%M(R%d)", a, a->reg);
else else
sprint(str, "$%N", a); sprint(str, "$%M", a);
break; break;
case D_CONST2: case D_CONST2:
...@@ -166,27 +166,27 @@ Dconv(Fmt *fp) ...@@ -166,27 +166,27 @@ Dconv(Fmt *fp)
case D_OREG: case D_OREG:
if(a->reg != NREG) if(a->reg != NREG)
sprint(str, "%N(R%d)", a, a->reg); sprint(str, "%M(R%d)", a, a->reg);
else else
sprint(str, "%N", a); sprint(str, "%M", a);
break; break;
case D_REG: case D_REG:
sprint(str, "R%d", a->reg); sprint(str, "R%d", a->reg);
if(a->name != D_NONE || a->sym != nil) 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; break;
case D_FREG: case D_FREG:
sprint(str, "F%d", a->reg); sprint(str, "F%d", a->reg);
if(a->name != D_NONE || a->sym != nil) 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; break;
case D_PSR: case D_PSR:
sprint(str, "PSR"); sprint(str, "PSR");
if(a->name != D_NONE || a->sym != nil) if(a->name != D_NONE || a->sym != nil)
sprint(str, "%N(PSR)(REG)", a); sprint(str, "%M(PSR)(REG)", a);
break; break;
case D_BRANCH: case D_BRANCH:
...@@ -203,7 +203,7 @@ Dconv(Fmt *fp) ...@@ -203,7 +203,7 @@ Dconv(Fmt *fp)
break; break;
case D_SCONST: case D_SCONST:
sprint(str, "$\"%S\"", a->u.sval); sprint(str, "$\"%$\"", a->u.sval);
break; break;
} }
return fmtstrcpy(fp, str); return fmtstrcpy(fp, str);
...@@ -242,7 +242,7 @@ Rconv(Fmt *fp) ...@@ -242,7 +242,7 @@ Rconv(Fmt *fp)
} }
static int static int
Sconv(Fmt *fp) DSconv(Fmt *fp)
{ {
int i, c; int i, c;
char str[STRINGSZ], *p, *a; char str[STRINGSZ], *p, *a;
...@@ -289,7 +289,7 @@ Sconv(Fmt *fp) ...@@ -289,7 +289,7 @@ Sconv(Fmt *fp)
} }
static int static int
Nconv(Fmt *fp) Mconv(Fmt *fp)
{ {
char str[STRINGSZ]; char str[STRINGSZ];
Addr *a; Addr *a;
......
...@@ -34,11 +34,24 @@ ...@@ -34,11 +34,24 @@
#include <link.h> #include <link.h>
#include "../cmd/6l/6.out.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 Aconv(Fmt *fp);
static int Dconv(Fmt *fp); static int Dconv(Fmt *fp);
static int Pconv(Fmt *fp); static int Pconv(Fmt *fp);
static int Rconv(Fmt *fp); static int Rconv(Fmt *fp);
static int Sconv(Fmt *fp); static int DSconv(Fmt *fp);
enum enum
{ {
...@@ -50,7 +63,7 @@ listinit6(void) ...@@ -50,7 +63,7 @@ listinit6(void)
{ {
fmtinstall('A', Aconv); fmtinstall('A', Aconv);
fmtinstall('P', Pconv); fmtinstall('P', Pconv);
fmtinstall('S', Sconv); fmtinstall('$', DSconv);
fmtinstall('D', Dconv); fmtinstall('D', Dconv);
fmtinstall('R', Rconv); fmtinstall('R', Rconv);
} }
...@@ -174,7 +187,7 @@ Dconv(Fmt *fp) ...@@ -174,7 +187,7 @@ Dconv(Fmt *fp)
break; break;
case D_SCONST: case D_SCONST:
sprint(str, "$\"%S\"", a->u.sval); sprint(str, "$\"%$\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
...@@ -337,7 +350,7 @@ Rconv(Fmt *fp) ...@@ -337,7 +350,7 @@ Rconv(Fmt *fp)
} }
static int static int
Sconv(Fmt *fp) DSconv(Fmt *fp)
{ {
int i, c; int i, c;
char str[STRINGSZ], *p, *a; char str[STRINGSZ], *p, *a;
......
...@@ -38,7 +38,7 @@ static int Aconv(Fmt *fp); ...@@ -38,7 +38,7 @@ static int Aconv(Fmt *fp);
static int Dconv(Fmt *fp); static int Dconv(Fmt *fp);
static int Pconv(Fmt *fp); static int Pconv(Fmt *fp);
static int Rconv(Fmt *fp); static int Rconv(Fmt *fp);
static int Sconv(Fmt *fp); static int DSconv(Fmt *fp);
enum enum
{ {
...@@ -50,7 +50,7 @@ listinit8(void) ...@@ -50,7 +50,7 @@ listinit8(void)
{ {
fmtinstall('A', Aconv); fmtinstall('A', Aconv);
fmtinstall('P', Pconv); fmtinstall('P', Pconv);
fmtinstall('S', Sconv); fmtinstall('$', DSconv);
fmtinstall('D', Dconv); fmtinstall('D', Dconv);
fmtinstall('R', Rconv); fmtinstall('R', Rconv);
} }
...@@ -181,7 +181,7 @@ Dconv(Fmt *fp) ...@@ -181,7 +181,7 @@ Dconv(Fmt *fp)
break; break;
case D_SCONST: case D_SCONST:
sprint(str, "$\"%S\"", a->u.sval); sprint(str, "$\"%$\"", a->u.sval);
break; break;
case D_ADDR: case D_ADDR:
...@@ -298,7 +298,7 @@ Rconv(Fmt *fp) ...@@ -298,7 +298,7 @@ Rconv(Fmt *fp)
} }
static int static int
Sconv(Fmt *fp) DSconv(Fmt *fp)
{ {
int i, c; int i, c;
char str[STRINGSZ], *p, *a; char str[STRINGSZ], *p, *a;
......
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