testEndToEnd(t, "amd64", "amd64")
}
+func Test386Encoder(t *testing.T) {
+ testEndToEnd(t, "386", "386enc")
+}
+
func TestAMD64Encoder(t *testing.T) {
testEndToEnd(t, "amd64", "amd64enc")
testEndToEnd(t, "amd64", "amd64enc_extra")
--- /dev/null
+// Copyright 2018 The Go Authors. All rights reserved.\r
+// Use of this source code is governed by a BSD-style\r
+// license that can be found in the LICENSE file.\r
+\r
+#include "../../../../../runtime/textflag.h"\r
+\r
+TEXT asmtest(SB),DUPOK|NOSPLIT,$0\r
+ // Instructions that were encoded with BYTE sequences.\r
+ // Included to simplify validation of CL that fixed that.\r
+ MOVQ (AX), M0 // 0f6f00\r
+ MOVQ M0, 8(SP) // 0f7f442408\r
+ MOVQ 8(SP), M0 // 0f6f442408\r
+ MOVQ M0, (AX) // 0f7f00\r
+ MOVQ M0, (BX) // 0f7f03\r
+ // End of tests.\r
+ RET\r
JNE done
CMPB runtime·lfenceBeforeRdtsc(SB), $1
JNE mfence
- BYTE $0x0f; BYTE $0xae; BYTE $0xe8 // LFENCE
+ LFENCE
JMP done
mfence:
- BYTE $0x0f; BYTE $0xae; BYTE $0xf0 // MFENCE
+ MFENCE
done:
RDTSC
MOVL AX, ret_lo+0(FP)
JZ 2(PC)
MOVL 0, AX // crash with nil ptr deref
LEAL ret_lo+4(FP), BX
- // MOVQ (%EAX), %MM0
- BYTE $0x0f; BYTE $0x6f; BYTE $0x00
- // MOVQ %MM0, 0(%EBX)
- BYTE $0x0f; BYTE $0x7f; BYTE $0x03
- // EMMS
- BYTE $0x0F; BYTE $0x77
+ MOVQ (AX), M0
+ MOVQ M0, (BX)
+ EMMS
RET
// void runtime∕internal∕atomic·Store64(uint64 volatile* addr, uint64 v);
JZ 2(PC)
MOVL 0, AX // crash with nil ptr deref
// MOVQ and EMMS were introduced on the Pentium MMX.
- // MOVQ 0x8(%ESP), %MM0
- BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08
- // MOVQ %MM0, (%EAX)
- BYTE $0x0f; BYTE $0x7f; BYTE $0x00
- // EMMS
- BYTE $0x0F; BYTE $0x77
+ MOVQ val+4(FP), M0
+ MOVQ M0, (AX)
+ EMMS
// This is essentially a no-op, but it provides required memory fencing.
// It can be replaced with MFENCE, but MFENCE was introduced only on the Pentium4 (SSE2).
MOVL $0, AX
TEXT runtime·sysenter(SB),NOSPLIT,$0
POPL DX
MOVL SP, CX
- BYTE $0x0F; BYTE $0x34; // SYSENTER
+ SYSENTER
// returns to DX with SP set to CX
TEXT runtime·mach_msg_trap(SB),NOSPLIT,$0
JZ 2(PC)
MOVL 0, AX // crash with nil ptr deref
// MOVQ and EMMS were introduced on the Pentium MMX.
- // MOVQ (%EAX), %MM0
- BYTE $0x0f; BYTE $0x6f; BYTE $0x00
- // MOVQ %MM0, 0x8(%ESP)
- BYTE $0x0f; BYTE $0x7f; BYTE $0x44; BYTE $0x24; BYTE $0x08
+ MOVQ (AX), M0
+ MOVQ M0, val+4(FP)
EMMS
RET
JZ 2(PC)
MOVL 0, AX // crash with nil ptr deref
// MOVQ and EMMS were introduced on the Pentium MMX.
- // MOVQ 0x8(%ESP), %MM0
- BYTE $0x0f; BYTE $0x6f; BYTE $0x44; BYTE $0x24; BYTE $0x08
- // MOVQ %MM0, (%EAX)
- BYTE $0x0f; BYTE $0x7f; BYTE $0x00
+ MOVQ val+4(FP), M0
+ MOVQ M0, (AX)
EMMS
// This is essentially a no-op, but it provides required memory fencing.
// It can be replaced with MFENCE, but MFENCE was introduced only on the Pentium4 (SSE2).