aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/mips
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2017-07-18 08:35:00 -0400
committerCherry Zhang <cherryyz@google.com>2017-08-02 12:24:02 +0000
commitf20944de78012a257d1e66b8209e2990a14673a7 (patch)
treedd1d328103906c5c0799d0d633ffe1d8fce8e0f0 /src/cmd/compile/internal/mips
parent623e2c4603053c8e2ecf4cd7ed5f8242a7a02226 (diff)
downloadgo-f20944de78012a257d1e66b8209e2990a14673a7.tar.gz
go-f20944de78012a257d1e66b8209e2990a14673a7.zip
cmd/compile: set/unset base register for better assembly print
For address of an auto or arg, on all non-x86 architectures the assembler backend encodes the actual SP offset in the instruction but leaves the offset in Prog unchanged. When the assembly is printed in compile -S, it shows an offset relative to pseudo FP/SP with an actual hardware SP base register (e.g. R13 on ARM). This is confusing. Unset the base register if it is indeed SP, so the assembly output is consistent. If the base register isn't SP, it should be an error and the error output contains the actual base register. For address loading instructions, the base register isn't set in the compiler on non-x86 architectures. Set it. Normally it is SP and will be unset in the change mentioned above for printing. If it is not, it will be an error and the error output contains the actual base register. No change in generated binary, only printed assembly. Passes "go build -a -toolexec 'toolstash -cmp' std cmd" on all architectures. Fixes #21064. Change-Id: Ifafe8d5f9b437efbe824b63b3cbc2f5f6cdc1fd5 Reviewed-on: https://go-review.googlesource.com/49432 Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/mips')
-rw-r--r--src/cmd/compile/internal/mips/ssa.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/mips/ssa.go b/src/cmd/compile/internal/mips/ssa.go
index d2b4885eaa..e65515a85b 100644
--- a/src/cmd/compile/internal/mips/ssa.go
+++ b/src/cmd/compile/internal/mips/ssa.go
@@ -273,6 +273,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case ssa.OpMIPSMOVWaddr:
p := s.Prog(mips.AMOVW)
p.From.Type = obj.TYPE_ADDR
+ p.From.Reg = v.Args[0].Reg()
var wantreg string
// MOVW $sym+off(base), R
// the assembler expands it as the following:
@@ -291,7 +292,6 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
case nil:
// No sym, just MOVW $off(SP), R
wantreg = "SP"
- p.From.Reg = mips.REGSP
p.From.Offset = v.AuxInt
}
if reg := v.Args[0].RegName(); reg != wantreg {