From b50ceebb814f28a6ade94974d3e8614c8585760e Mon Sep 17 00:00:00 2001 From: Ulya Trafimovich Date: Mon, 12 Jul 2021 14:20:16 +0100 Subject: x86: Add missing variants for XCHG and tests for this instruction. Add XCHG variants when both operands are registers. Handle the special case when at least one of the register operands is EAX/AX. Add tests for the new variants and for other variants that previously weren't tested. Bug: 65872996 Test: m test-art-host-gtest Change-Id: I1e80d1b86f3d2e804b90c2a181e4eabded30d8ae --- compiler/utils/x86/assembler_x86.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'compiler/utils/x86/assembler_x86.h') diff --git a/compiler/utils/x86/assembler_x86.h b/compiler/utils/x86/assembler_x86.h index db92a80a4e..f6e7fbc8cd 100644 --- a/compiler/utils/x86/assembler_x86.h +++ b/compiler/utils/x86/assembler_x86.h @@ -736,8 +736,14 @@ class X86Assembler final : public Assembler { void fptan(); void fprem(); + void xchgb(ByteRegister dst, ByteRegister src); void xchgb(ByteRegister reg, const Address& address); + + // Wrappers for `xchgb` that accept `Register` instead of `ByteRegister` (used for testing). + void xchgb(Register dst, Register src); void xchgb(Register reg, const Address& address); + + void xchgw(Register dst, Register src); void xchgw(Register reg, const Address& address); void xchgl(Register dst, Register src); @@ -1044,6 +1050,10 @@ class X86Assembler final : public Assembler { uint8_t EmitVexPrefixByteTwo(bool W, int SET_VEX_L, int SET_VEX_PP); + + // Helper function to emit a shorter variant of XCHG for when at least one operand is EAX/AX. + bool try_xchg_eax(Register dst, Register src); + ConstantArea constant_area_; bool has_AVX_; // x86 256bit SIMD AVX. bool has_AVX2_; // x86 256bit SIMD AVX 2.0. -- cgit v1.2.3-59-g8ed1b