x86_64: Add tests for CMPXCHG (without LOCK prefix).
For 8/32/64-bit variants LOCK CMPXCHG is implemented via CMPXCHG, so the
tests for LOCK CMPXCHG cover CMPXCHG as well. But the 16-bit variant of
LOCK CMPXCHG does not use CMPXCHG, because it has to reorder prefixes:
the operand size override prefix must go before the LOCK prefix to match
clang order. Therefore 16-bit CMPXCHG was not tested previously.
Bug: 65872996
Test: m test-art-host-gtest # new test cases for CMPXCHG
Change-Id: I6d021bb40cfc767143db914ff64276a23243e046
diff --git a/compiler/utils/x86_64/assembler_x86_64_test.cc b/compiler/utils/x86_64/assembler_x86_64_test.cc
index 97c3fa0..7785511 100644
--- a/compiler/utils/x86_64/assembler_x86_64_test.cc
+++ b/compiler/utils/x86_64/assembler_x86_64_test.cc
@@ -961,6 +961,22 @@
// DriverStr(Repeatrr(&x86_64::X86_64Assembler::xchgl, "xchgl %{reg2}, %{reg1}"), "xchgl");
}
+TEST_F(AssemblerX86_64Test, Cmpxchgb) {
+ DriverStr(RepeatAb(&x86_64::X86_64Assembler::cmpxchgb, "cmpxchgb %{reg}, {mem}"), "cmpxchgb");
+}
+
+TEST_F(AssemblerX86_64Test, Cmpxchgw) {
+ DriverStr(RepeatAw(&x86_64::X86_64Assembler::cmpxchgw, "cmpxchgw %{reg}, {mem}"), "cmpxchgw");
+}
+
+TEST_F(AssemblerX86_64Test, Cmpxchgl) {
+ DriverStr(RepeatAr(&x86_64::X86_64Assembler::cmpxchgl, "cmpxchgl %{reg}, {mem}"), "cmpxchgl");
+}
+
+TEST_F(AssemblerX86_64Test, Cmpxchgq) {
+ DriverStr(RepeatAR(&x86_64::X86_64Assembler::cmpxchgq, "cmpxchg %{reg}, {mem}"), "cmpxchg");
+}
+
TEST_F(AssemblerX86_64Test, LockCmpxchgb) {
DriverStr(RepeatAb(&x86_64::X86_64Assembler::LockCmpxchgb,
"lock cmpxchgb %{reg}, {mem}"), "lock_cmpxchgb");