]> Cypherpunks repositories - gostls13.git/commitdiff
liblink: adjust format verbs to avoid collisions
authorAnthony Martin <ality@pbrane.org>
Fri, 10 Jan 2014 03:01:08 +0000 (19:01 -0800)
committerAnthony Martin <ality@pbrane.org>
Fri, 10 Jan 2014 03:01:08 +0000 (19:01 -0800)
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

src/liblink/list5.c
src/liblink/list6.c
src/liblink/list8.c

index 5a50a9329eaded66c83903b49bc22ed5f571552f..ec954f6461cb1046356fb4582d8d56480a0b1016 100644 (file)
@@ -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;
index c7761949ca05d1e9d542c720f5da8f47da83867e..34a877e4ea8d72d73be9344115e34eba69b11462 100644 (file)
 #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;
index cdc97515b885797866bc521cae8ed4d445007556..3d78d781d03388521b32b607954f4fd5809ec6ea 100644 (file)
@@ -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;