aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2010-07-01 12:18:35 -0700
committerRuss Cox <rsc@golang.org>2010-07-01 12:18:35 -0700
commitbf1098273923e897184e70ab2488cecf15a4c8c1 (patch)
tree9c45a0e9939a18d24a7b44d8a5b067e0cdf41911
parent9038de0373b7d7210348685f34cda7a6e4ce94d9 (diff)
downloadgo-bf1098273923e897184e70ab2488cecf15a4c8c1.tar.gz
go-bf1098273923e897184e70ab2488cecf15a4c8c1.zip
6l: implement MOVLQZX as "mov", not "movsxd"
(Here, quoted strings are the official AMD names.) The amd64 "movsxd" instruction, when invoked with a 64-bit REX prefix, moves and sign extends a 32-bit value from register or memory into a 64-bit register. 6.out.h spells this MOVLQSX. 6.out.h also includes MOVLQZX, the zero extending version, which it implements as "movsxd" without the REX prefix. Without the REX prefix it's only sign extending 32 bits to 32 bits (i.e., not doing anything to the bits) and then storing in a 32-bit register. Any write to a 32-bit register zeros the top half of the corresponding 64-bit register, giving the advertised effect. This particular implementation of the functionality is non-standard, because an ordinary 32-bit "mov" would do the same thing. Because it is non-standard, it is often mishandled or not handled by binary translation tools like valgrind. Switching to the standard "mov" makes the binaries work better with those tools. It's probably useful in 6c and 6g to have an explicit instruction, though, so that the intent of the size change is clear. Thus we leave the concept of MOVLQZX and just implement it by the standard "mov" instead of the non-standard 32-bit "movsxd". Fixes #896. R=ken2 CC=golang-dev https://golang.org/cl/1733046
-rw-r--r--src/cmd/6l/optab.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cmd/6l/optab.c b/src/cmd/6l/optab.c
index 4aadf7a2c0..c8aa0b5290 100644
--- a/src/cmd/6l/optab.c
+++ b/src/cmd/6l/optab.c
@@ -792,7 +792,7 @@ Optab optab[] =
{ AMOVLPD, yxmov, Pe, 0x12,0x13 },
{ AMOVLPS, yxmov, Pm, 0x12,0x13 },
{ AMOVLQSX, yml_rl, Pw, 0x63 },
- { AMOVLQZX, yml_rl, Px, 0x63 },
+ { AMOVLQZX, yml_rl, Px, 0x8b }, /* not 0x63 - MOVL (0x8b) is more widely understood and has same effect */
{ AMOVMSKPD, yxrrl, Pq, 0x50 },
{ AMOVMSKPS, yxrrl, Pm, 0x50 },
{ AMOVNTO, yxr_ml, Pe, 0xe7 },