summaryrefslogtreecommitdiff
path: root/src
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
commit67daf5190382a49a4be780eb18613a8e1535532d (patch)
treef45acef37272c9bee2fda39a1abeb1145c6d217a /src
parent24bbb4db940f47782887040a2fd985adb0f04634 (diff)
downloadgolang-67daf5190382a49a4be780eb18613a8e1535532d.tar.gz
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 issue 896. R=ken2 CC=golang-dev http://codereview.appspot.com/1733046
Diffstat (limited to 'src')
-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 4aadf7a2c..c8aa0b529 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 },