cmd/internal/obj: print g for the g register on arm and ppc64

The name g is an alias for R10 and R30, respectively. Have Rconv
print the alias, for consistency with the input language.

Change-Id: Ic3f40037884a0c8de5089d8c8a8efbcdc38c0d56
Reviewed-on: https://go-review.googlesource.com/6630
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Rob Pike 2015-03-03 09:14:31 -08:00
parent d5f690609f
commit f05f273525
3 changed files with 12 additions and 4 deletions

View File

@ -289,7 +289,7 @@ var armOperandTests = []operandTest{
{"$256", "$256"},
{"(R0)", "(R0)"},
{"(R11)", "(R11)"},
{"(g)", "(R10)"}, // TODO: Should print 0(g).
{"(g)", "(g)"},
{"-12(R4)", "-12(R4)"},
{"0(PC)", "0(PC)"},
{"1024", "1024"},
@ -324,7 +324,7 @@ var armOperandTests = []operandTest{
{"armCAS64(SB)", "armCAS64(SB)"},
{"asmcgocall<>(SB)", "asmcgocall<>(SB)"},
{"c+28(FP)", "c+28(FP)"},
{"g", "R10"}, // TODO: Should print g.
{"g", "g"},
{"gosave<>(SB)", "gosave<>(SB)"},
{"retlo+12(FP)", "retlo+12(FP)"},
{"runtime·_sfloat2(SB)", "runtime._sfloat2(SB)"},
@ -349,7 +349,7 @@ var ppc64OperandTests = []operandTest{
{"$~3", "$-4"},
{"(-288-3*8)(R1)", "-312(R1)"},
{"(16)(R7)", "16(R7)"},
{"(8)(g)", "8(R30)"}, // TODO: Should print 8(g)
{"(8)(g)", "8(g)"},
{"(CTR)", "(CTR)"},
{"(R0)", "(R0)"},
{"(R3)", "(R3)"},
@ -411,7 +411,7 @@ var ppc64OperandTests = []operandTest{
{"R9", "R9"},
{"SPR(269)", "SPR(269)"},
{"a(FP)", "a(FP)"},
{"g", "R30"}, // TODO: Should print g.
{"g", "g"},
{"ret+8(FP)", "ret+8(FP)"},
{"runtime·abort(SB)", "runtime.abort(SB)"},
{"·AddUint32(SB)", "\"\".AddUint32(SB)"},

View File

@ -105,6 +105,10 @@ func Rconv(r int) string {
if r == 0 {
return "NONE"
}
if r == REGG {
// Special case.
return "g"
}
if REG_R0 <= r && r <= REG_R15 {
return fmt.Sprintf("R%d", r-REG_R0)
}

View File

@ -122,6 +122,10 @@ func Rconv(r int) string {
if r == 0 {
return "NONE"
}
if r == REGG {
// Special case.
return "g"
}
if REG_R0 <= r && r <= REG_R31 {
return fmt.Sprintf("R%d", r-REG_R0)
}